From e11a0e17aa491a7dab8deeeaa7f5747f862b253d Mon Sep 17 00:00:00 2001 From: Ceda EI Date: Fri, 9 Nov 2018 01:17:24 +0530 Subject: [PATCH] Add sample config, gitignore, base template --- .gitignore | 2 ++ bot.py | 25 +++++++++++++++++++++++++ sample.config.py | 17 +++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 .gitignore create mode 100644 bot.py create mode 100644 sample.config.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..225083f --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +config.py +__pycache__/ diff --git a/bot.py b/bot.py new file mode 100644 index 0000000..ad69c16 --- /dev/null +++ b/bot.py @@ -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"]) diff --git a/sample.config.py b/sample.config.py new file mode 100644 index 0000000..c06b716 --- /dev/null +++ b/sample.config.py @@ -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, + }