def cancel(bot, update): from bender import send_message if reset_message_handler(): send_message(bot, update, 'Doks. I aborted the mission.') else: send_message( bot, update, 'I wasn\'t about to do shit. Anyfuck, I\'ve cancelled it')
def ping(bot, update): from bender import send_message text = remove_first_word(update.message.text.strip()) if not text: send_message(bot, update, 'Missing host') else: p = __shell('ping -c 1 -w 1 {}'.format(text)) send_message(bot, update, p)
def ping(bot, update): from bender import send_message text = remove_first_word(update.message.text.strip()) if not text: send_message(bot, update, 'Missing host') else: p = __shell('ping -c 1 -w 1 {}'.format(text)) send_message(bot, update, p)
def message_handler_command(bot, update): from bender import send_message text = update.message.text if text: response = __shell(text) else: response = 'Whatever' bot_controller.reset_message_handler() send_message(bot, update, response)
def gimme(bot, update): from bender import send_message chat_id = update.message.chat_id text = remove_first_word(update.message.text) try: with open(text, 'rb') as f: return bot.sendDocument(chat_id=chat_id, document=f) except Exception as e: send_message(bot, update, '{} Shit hit the fan: {}'.format(emoji(Emoji.CROSS_MARK), e))
def message_handler_command(bot, update): from bender import send_message text = update.message.text if text: response = __shell(text) else: response = 'Whatever' bot_controller.reset_message_handler() send_message(bot, update, response)
def shell_exec(bot, update): from bender import send_message # Remove first word (shell or /shell) text = remove_first_word(update.message.text) if text: response = __shell(text) else: response = 'What command should I run?' bot_controller.set_message_handler(message_handler_command) send_message(bot, update, response)
def shell_exec(bot, update): from bender import send_message # Remove first word (shell or /shell) text = remove_first_word(update.message.text) if text: response = __shell(text) else: response = 'What command should I run?' bot_controller.set_message_handler(message_handler_command) send_message(bot, update, response)
def gimme(bot, update): from bender import send_message chat_id = update.message.chat_id text = remove_first_word(update.message.text) try: with open(text, 'rb') as f: return bot.sendDocument(chat_id=chat_id, document=f) except Exception as e: send_message( bot, update, '{} Shit hit the fan: {}'.format(emoji(Emoji.CROSS_MARK), e))
def check_auth(bot, update, *args, **kwargs): ''' Function to be applied on top of all decorated methods ''' if not is_authorized(update): logger = logging.getLogger() logger.debug('NOT AUTHORIZED: ' + update.message.from_user.username) import bender return bender.send_message(bot, update, 'nope, nope. NOPE.') return f(bot, update, *args, **kwargs)
def message_handler_light_selection(bot, update): from bender import send_message text = re.sub(r': (on|off)', '', update.message.text) try: state = __light_toggle(text) response = u'{} Toggled light {} (state: {})'.format(emoji(Emoji.WHITE_HEAVY_CHECK_MARK), text, 'on' if state else 'off') except LightNotFoundException: response = u'{} Could not find light named {}'.format(emoji(Emoji.CROSS_MARK), text) logger.error('RESET') bot_controller.reset_message_handler() return send_message(bot, update, response)
def message_handler_light_selection(bot, update): from bender import send_message text = re.sub(r': (on|off)', '', update.message.text) try: state = __light_toggle(text) response = u'{} Toggled light {} (state: {})'.format( emoji(Emoji.WHITE_HEAVY_CHECK_MARK), text, 'on' if state else 'off') except LightNotFoundException: response = u'{} Could not find light named {}'.format( emoji(Emoji.CROSS_MARK), text) logger.error('RESET') bot_controller.reset_message_handler() return send_message(bot, update, response)
def emojis(bot, update): from bender import send_message message = '' for e in [x for x in dir(Emoji) if x.isupper()]: message += '{}: {}\n'.format(emoji(getattr(Emoji, e)), e) send_message(bot, update, message)
def random_fact(bot, update): from bender import send_message send_message(bot, update, text=__random())
def clear(bot, update): from bender import send_message message = ''' . . ''' send_message(bot, update, message)
def clear(bot, update): from bender import send_message message = ''' . . ''' send_message(bot, update, message)
def __shell_exec(bot, update, command, text): from bender import send_message p = __shell('{} {}'.format(command, text)) send_message(bot, update, p)
def emojis(bot, update): from bender import send_message message = '' for e in [x for x in dir(Emoji) if x.isupper()]: message += '{}: {}\n'.format(emoji(getattr(Emoji, e)), e) send_message(bot, update, message)
def random_fact(bot, update): from bender import send_message send_message(bot, update, text=__random())
def insult(bot, update): from bender import send_message send_message(bot, update, text=__insult())
def insult(bot, update): from bender import send_message send_message(bot, update, text=__insult())
def quote(bot, update): from bender import send_message return send_message(bot, update, random.choice(QUOTES))
def cancel(bot, update): from bender import send_message if reset_message_handler(): send_message(bot, update, 'Doks. I aborted the mission.') else: send_message(bot, update, 'I wasn\'t about to do shit. Anyfuck, I\'ve cancelled it')
def quote(bot, update): from bender import send_message return send_message(bot, update, random.choice(QUOTES))
def __shell_exec(bot, update, command, text): from bender import send_message p = __shell('{} {}'.format(command, text)) send_message(bot, update, p)
def not_implemented(bot, update): message = 'Nah. This ain\'t implemented yet.' send_message(bot, update, message)