Exemplo n.º 1
0
def __shell(cmd):
    try:
        s = sh(cmd)
        errors = s.errors(raw=True)
        if errors:
            response = u'{} FAIL: {}'.format(emoji(Emoji.PILE_OF_POO), errors)
        else:
            response = s.output(raw=True)
    except OSError as e:
        response = '{} That did\'t go well: {}'.format(emoji(Emoji.CROSS_MARK), e)
    return response
Exemplo n.º 2
0
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)
Exemplo n.º 3
0
def __shell(cmd):
    try:
        s = sh(cmd)
        errors = s.errors(raw=True)
        if errors:
            response = u'{} FAIL: {}'.format(emoji(Emoji.PILE_OF_POO), errors)
        else:
            response = s.output(raw=True)
    except OSError as e:
        response = '{} That did\'t go well: {}'.format(emoji(Emoji.CROSS_MARK),
                                                       e)
    return response
Exemplo n.º 4
0
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)
Exemplo n.º 5
0
def msg_handler_content(bot, update):
    global RECIPIENT
    chat_id = update.message.chat_id
    bot_controller.reset_message_handler()
    bot.sendMessage(
        chat_id=chat_id,
        text='{} Message sent!'.format(emoji(Emoji.WHITE_HEAVY_CHECK_MARK))
    )
Exemplo n.º 6
0
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))
Exemplo n.º 7
0
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))
Exemplo n.º 8
0
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)
Exemplo n.º 9
0
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)