def action(bot, update): """ Loads dynamically the commands as it parses the string """ if(is_allowed(update.effective_user.id, COMMAND_NAME)): arguments = parse_command(COMMAND_NAME, update.message.text) for command in commands: if command in arguments: commands[command](bot, update) arguments.remove(command)
def action(bot, update): """ /ping - Answers the user the ping query. """ if (is_allowed(update.effective_user.id, COMMAND_NAME)): # Print help case if (update.message.text.lower() == ('/%s help' % COMMAND_NAME).lower()): help(bot, update) return 0 bot.send_message(chat_id=update.effective_user.id, text='Pong!')
def action(bot, update): """ Requests the engel to restart itself. """ if (is_allowed(update.effective_user.id, COMMAND_NAME)): # Print help case if (update.message.text.lower() == ('/%s help' % COMMAND_NAME).lower()): help(bot, update) return 0 bot.send_message(chat_id=update.message.chat_id, text='Rebooting.') run(['reboot'])
def action(bot, update): """ Requests the engel to shutdown itself. """ if (is_allowed(update.effective_user.id, COMMAND_NAME)): # Print help case if (update.message.text.lower() == ('/%s help' % COMMAND_NAME).lower()): help(bot, update) return 0 bot.send_message(chat_id=update.message.chat_id, text='Shutting down.') run(['poweroff', '-p'])
def action(bot, update): """ Returns all available commands. """ if (is_allowed(update.effective_user.id, COMMAND_NAME)): # Print help case if (update.message.text.lower() == ('/%s help' % COMMAND_NAME).lower()): help(bot, update) return 0 commands = scan_modules('commands') commands.remove('commands.help') keyboard_buttons = [] for command in commands: trimmed_command = command.replace('commands.', '') keyboard_buttons.append( [KeyboardButton(text='/%s help' % trimmed_command)]) help_arguments = ReplyKeyboardMarkup(keyboard=keyboard_buttons, one_time_keyboard=True) bot.send_message(chat_id=update.effective_user.id, text="These are the available commands.", reply_markup=help_arguments)
def action(bot, update): """ Requests the engel to restart itself. """ if (is_allowed(update.effective_user.id, COMMAND_NAME)): # Print help case if (update.message.text.lower() == ('/%s help' % COMMAND_NAME).lower()): help(bot, update) return 0 bot.send_message(chat_id=update.effective_user.id, text='Update in progress.') Popen( [ '/usr/bin/at now -f /opt/engel/integrations/updater/update_wrapper.sh' ], env={ 'TERM': 'xterm-256color', 'PATH': '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' }, shell=True)