Exemplo n.º 1
0
def process_received_message(message):
    global pending_hide_keyboard
    logger.info(message)
    message = DictObject.objectify(message)
    username = message['from'].username if hasattr(message['from'],
                                                   'username') else None

    processed_event = process_chat_event(message)  #text or location
    if not processed_event:
        is_text = hasattr(message, 'text')
        if not is_text:
            #if it's not text it will not be processed for commands or direct message
            process_no_text_message(message, username)
            return

        processed_command = process_command(message, username)
        if not processed_command:
            processed_reply = commands.process_expected_reply(message.chat.id,\
                                                                message['from']['id'],\
                                                                username,\
                                                                message.text)
            if processed_reply:
                # Processed as reply, won't continue
                pending_hide_keyboard = True
                return
            (direct_msg, clean_text) = direct_message(message)
            direct_conversation = is_direct_conversation(message)
            if direct_msg:
                process_chat_message(message, clean_text)
            if not direct_msg or direct_conversation:
                process_message_trigger(message, clean_text, username)
Exemplo n.º 2
0
def process_received_message(message):
    global pending_hide_keyboard
    logger.info(message)
    message = DictObject.objectify(message)
    username = message['from'].username if hasattr(message['from'], 'username') else None

    processed_event = process_chat_event(message)#text or location
    if not processed_event:
        is_text = hasattr(message, 'text')
        if not is_text:
            #if it's not text it will not be processed for commands or direct message
            process_no_text_message(message, username)
            return

        processed_command = process_command(message, username)
        if not processed_command:
            processed_reply = commands.process_expected_reply(message.chat.id,\
                                                                message['from']['id'],\
                                                                username,\
                                                                message.text)
            if processed_reply:
                # Processed as reply, won't continue
                pending_hide_keyboard = True
                return 
            (direct_msg, clean_text) = direct_message(message)
            direct_conversation = is_direct_conversation(message)
            if direct_msg:
                process_chat_message(message, clean_text)
            if not direct_msg or direct_conversation:
                process_message_trigger(message, clean_text, username)
Exemplo n.º 3
0
def process_no_text_message(message, username):
    global pending_hide_keyboard
    if hasattr(message, 'text'):
        return False
    processed = False
    if hasattr(message, 'location'):
        processed = commands.process_expected_reply(message.chat.id,\
                                        message['from']['id'],\
                                        username,\
                                        message.location)
        if processed:
            pending_hide_keyboard = True

    return processed
Exemplo n.º 4
0
def process_no_text_message(message, username):
    global pending_hide_keyboard
    if hasattr(message, 'text'):
        return False
    processed = False
    if hasattr(message, 'location'):
        processed = commands.process_expected_reply(message.chat.id,\
                                        message['from']['id'],\
                                        username,\
                                        message.location)
        if processed:
            pending_hide_keyboard = True
        
    return processed