Add sample config, gitignore, base template

This commit is contained in:
Ceda EI 2018-11-09 01:17:24 +05:30
parent 6e42868656
commit e11a0e17aa
3 changed files with 44 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
config.py
__pycache__/

25
bot.py Normal file
View File

@ -0,0 +1,25 @@
#!/usr/bin/env python3
import config
import logging
from telegram.ext import Updater, CommandHandler
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - \
%(message)s', level=logging.INFO)
def nuke(bot, update):
pass
updater = Updater(token=config.api_key)
dispatcher = updater.dispatcher
nuke_handler = CommandHandler('nuke', nuke)
dispatcher.add_handler(nuke_handler)
if config.update_method == "polling":
updater.start_polling()
elif config.update_method == "webhook":
updater.start_webhook(listen=config.webhook["listen"],
url_path=config.webhook["url_path"],
port=config.webhook["port"])
updater.bot.set_webhook(url=config.webhook["url"])

17
sample.config.py Normal file
View File

@ -0,0 +1,17 @@
# Create a new bot by messaging @BotFather and follow the instructions
# Replace the key by the actual token recieved from BotFather
api_key = "123456789:xxxxxxxxxxxxxxxxxxxxxxxxxxxx"
# Update method
# Available Modes: "polling", "webhook"
update_method = "polling"
# Webhook Config
# Check the following urls for more details
# https://github.com/python-telegram-bot/python-telegram-bot/wiki/Webhooks
webhook = {"listen": "0.0.0.0",
"url": "https://example.com/" + api_key,
"url_path": api_key,
"port": 9999,
}