Skip to content

Instantly share code, notes, and snippets.

@JuanjoSalvador
Created October 13, 2019 01:02
Show Gist options
  • Save JuanjoSalvador/81e85c023365c826d2eb0a32d20bb2fe to your computer and use it in GitHub Desktop.
Save JuanjoSalvador/81e85c023365c826d2eb0a32d20bb2fe to your computer and use it in GitHub Desktop.
Telegram's channel admin bot
[DEFAULT]
API_KEY = SET YOUR BOT API KEY HERE
CHANNEL_NAME = SET YOUR @channelname HERE
#!/usr/bin/env python3
import urllib3
import configparser
import os
config = configparser.ConfigParser()
config.read(os.path.join(os.path.dirname(__file__), 'settings.ini'))
http = urllib3.PoolManager()
message = "ENTER YOUR MESSAGE HERE"
URL = "https://api.telegram.org/bot{}/sendMessage?chat_id={}&text={}".format(
config['DEFAULT']['API_KEY'],
config['DEFAULT']['CHANNEL_NAME'],
message
)
try:
http.request('GET', URL)
except Exception as ex:
print("Something went wrong: \n {}".format(ex))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment