main
Bandie 1 year ago
parent 61d3e462fb
commit 463fd8a629
Signed by: Bandie
GPG Key ID: 843D7FA93BA46312
  1. 36
      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))

Loading…
Cancel
Save