예제 #1
0
파일: disable.py 프로젝트: kirebyte/Engel
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)
예제 #2
0
파일: ping.py 프로젝트: kirebyte/Engel
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!')
예제 #3
0
파일: restart.py 프로젝트: kirebyte/Engel
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'])
예제 #4
0
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'])
예제 #5
0
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)
예제 #6
0
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)