Last active
July 9, 2021 14:31
-
-
Save BluLupo/ecb3ce7ea688205d54f5ae4d5e6ffdc0 to your computer and use it in GitHub Desktop.
Send Message with Telegram Bot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib.request | |
import requests | |
MAIN_URL = "https://api.telegram.org/" | |
TOKEN = "Your Bot Token" | |
CHAT_ID = -100123456789 | |
def send_message(text, chat_id): | |
text = urllib.parse.quote_plus(text) | |
url = MAIN_URL + "bot{}/sendmessage?chat_id={}&text={}&parse_mode=HTML".format(TOKEN, chat_id, text) | |
send = requests.get(url) | |
return send | |
while True: | |
print('Enter your message:') | |
x = input() | |
send_message(x,CHAT_ID) | |
print("Your Message is: {}\nin Chat: {}".format(x, CHAT_ID)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment