示例#1
0
def get_action(action, target, text=None, menu=None):
    "Return action class."

    if menu is not None:

        return Action(name=action,
                      target=target,
                      text=menu.text,
                      markup="menu",
                      payload=menu.options)

    elif text is not None:
        return Action(name=action, target=target, text=text)

    return
示例#2
0
def __fireteams_handler(message):
    """Method to handle fireteams"""

    cmd = __parse_message(message)

    if not isinstance(cmd, FireteamsCmd):
        return Action(
            name='new_message',
            target=message.chat.chat_id,
            text=cmd,
            markup='markdown'
        )

    else:
        return Action(
            name='new_message',
            target=message.chat.chat_id,
            text=__fireteams_do(cmd),
            markup='markdown'
        )
示例#3
0
def psnids(message):
    "Implements hear to receive the messages and execute the plugin logic"

    psnid_list = __list_psnids(message.chat.chat_id)

    if psnid_list:
        return Action(name='new_message',
                      target=message.chat.chat_id,
                      text=__escape_markdown(psnid_list),
                      markup='markdown')

    return
示例#4
0
def user_leaving(message):
    "Response to user leaving a group events."

    custom_message = __get_message(
        'user_leaving',
        message
    )

    if custom_message:
        return Action(
            name='new_message',
            target=message.chat.chat_id,
            text=custom_message,
            markup='markdown'
        )

    return "👋👋"
示例#5
0
def ___message_handler(message):
    """Parses the user message call the psnprofiles method if valid"""

    words = message.text.split()

    if not words:
        return None

    handler = words[0]

    if len(words) < 2:
        response = __usage(handler)
    else:
        response = __psntrophies(words[1])

    return Action(name='new_message',
                  target=message.chat.chat_id,
                  text=response,
                  markup='markdown')
示例#6
0
def help(message):
    "Implements hear to receive the messages and execute the plugin logic"
    return Action(name='new_message',
                  target=message.chat.chat_id,
                  text=command_help(message.text),
                  markup='markdown')