Skip to content

Instantly share code, notes, and snippets.

@BluLupo
Last active July 9, 2021 14:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BluLupo/ecb3ce7ea688205d54f5ae4d5e6ffdc0 to your computer and use it in GitHub Desktop.
Save BluLupo/ecb3ce7ea688205d54f5ae4d5e6ffdc0 to your computer and use it in GitHub Desktop.
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