Created
October 13, 2019 01:02
-
-
Save JuanjoSalvador/81e85c023365c826d2eb0a32d20bb2fe to your computer and use it in GitHub Desktop.
Telegram's channel admin 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
[DEFAULT] | |
API_KEY = SET YOUR BOT API KEY HERE | |
CHANNEL_NAME = SET YOUR @channelname HERE |
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
#!/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