From 463fd8a62985e81e7fc87fe84efd1aa0eb52b152 Mon Sep 17 00:00:00 2001 From: Bandie Date: Fri, 11 Jun 2021 23:49:21 +0200 Subject: [PATCH] run start --- TelegramContactProtectionBot.py | 36 ++++++++++++++++----------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/TelegramContactProtectionBot.py b/TelegramContactProtectionBot.py index a290ca1..393f3f0 100755 --- a/TelegramContactProtectionBot.py +++ b/TelegramContactProtectionBot.py @@ -40,6 +40,7 @@ def setup(update: Update, context: CallbackContext): loadConfig() logging.info("Bot claimed by " + config['name'] + ".") context.bot.sendMessage(chat_id=update.effective_chat.id, text='You just claimed this bot, ' + config['name'] + '.') + start(update, context) def setName(update: Update, context: CallbackContext): if(context.args): @@ -104,7 +105,24 @@ def unblock(update: Update, context: CallbackContext): def start(update: Update, context: CallbackContext): + commandsList = [] + commandsList.append(BotCommand(command='start', description='Information about this bot.')) + if('name' in config): + commandsList.append(BotCommand(command='request', description='Send a contact request to ' + config['name'])) + if(isAdmin): + commandsList.append(BotCommand(command='block', description='Admin: Block a user. ID required. /block {ID}')) + commandsList.append(BotCommand(command='unblock', description='Admin: Unblock a user. ID required. /unblock {ID}')) + commandsList.append(BotCommand(command='blocklist', description='Admin: List the blocked IDs.')) + commandsList.append(BotCommand(command='setname', description='Admin: Set your name for information purposes. /setname {name}')) + + if('adminID' not in config): + dispatcher.add_handler(CommandHandler('setup', setup)) + commandsList.append(BotCommand(command='setup', description='Set yourself up as owner.')) + + bot.set_my_commands(commands=commandsList) + reply_markup=telegram.ReplyKeyboardRemove() + if('name' in config): context.bot.sendMessage(chat_id=update.effective_chat.id, text="Hello! " + config['name'] + " has set up a contact protection bot. To request contact, type /request.", reply_markup=reply_markup) else: @@ -153,24 +171,6 @@ def request(update: Update, context: CallbackContext): loadConfig() -commandsList = [] -commandsList.append(BotCommand(command='start', description='Information about this bot.')) -if('name' in config): - commandsList.append(BotCommand(command='request', description='Send a contact request to ' + config['name'])) - commandsList.append(BotCommand(command='block', description='Admin: Block a user. ID required. /block {ID}')) - commandsList.append(BotCommand(command='unblock', description='Admin: Unblock a user. ID required. /unblock {ID}')) - commandsList.append(BotCommand(command='blocklist', description='Admin: List the blocked IDs.')) - commandsList.append(BotCommand(command='setname', description='Admin: Set your name for information purposes. /setname {name}')) - - - - -if('adminID' not in config): - dispatcher.add_handler(CommandHandler('setup', setup)) - commandsList.append(BotCommand(command='setup', description='Set yourself up as owner.')) - -bot.set_my_commands(commands=commandsList) - dispatcher.add_handler(CommandHandler('start', start)) dispatcher.add_handler(CommandHandler('block', block)) dispatcher.add_handler(CommandHandler('blocklist', listBlacklist))