Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Send Message with Telegram Bot
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