[+] Create start command

This commit is contained in:
Hykilpikonna
2020-11-22 12:03:39 -05:00
parent 8a1aff98ff
commit 83a9276478
2 changed files with 37 additions and 20 deletions
+13 -20
View File
@@ -1,26 +1,13 @@
import telegram import telegram
from telegram.ext import CommandHandler
from telegram.ext import Updater
import logging import logging
import os import os
helpMsg = """ from src.commands import start
Welcome! This bot monitors http changes!
/start - Start the bot # Read token from an environment variable
token=os.environ['TG_TOKEN']
**Management Commands**
/ls - List the http requests you've created
/touch - Create a http request
/rm - Delete a http request
/mv - Rename a http request
**Configuration Commands**
/nano - Edit a http request
/interval - Change the interval between the updates of a http request
**Start/Stop Commands**
/enable - Start listening to a http request
/stop - Stop listening to a http request
"""
# Main # Main
if __name__ == '__main__': if __name__ == '__main__':
@@ -28,9 +15,15 @@ if __name__ == '__main__':
# Initialize logger # Initialize logger
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO) logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO)
# Create bot with configurable token # Create bot
bot = telegram.Bot(token=os.environ['TG_TOKEN']) bot = telegram.Bot(token=os.environ['TG_TOKEN'])
# Print bot info # Print bot info
print("Bot info: ", bot.getMe()) print("Bot created: ", bot.getMe())
# Create updater
updater = Updater(bot=bot)
dispatcher = updater.dispatcher
# Register commands
dispatcher.add_handler(CommandHandler('start', start))
+24
View File
@@ -0,0 +1,24 @@
# Help message
helpMsg = """
Welcome! This bot monitors http changes!
/start - Start the bot
**Management Commands**
/ls - List the http requests you've created
/touch - Create a http request
/rm - Delete a http request
/mv - Rename a http request
**Configuration Commands**
/nano - Edit a http request
/interval - Change the interval between the updates of a http request
**Start/Stop Commands**
/enable - Start listening to a http request
/stop - Stop listening to a http request
"""
def start(update, context):
context.bot.send_message(chat_id=update.effective_chat.id, text=helpMsg)