Пример #1
0
async def member_greeted(action: Action, app: SirBot):
    """
    Called when a community member clicks the button saying they greeted the new member
    """
    response = base_response(action)
    user_id = action["user"]["id"]
    response["attachments"] = greeted_attachment(user_id)

    await app.plugins["slack"].api.query(methods.CHAT_UPDATE, response)
Пример #2
0
async def reset_message(action: Action, app: SirBot):
    """
    Resets the claim messaged button back to its initial state and appends the user that hit reset and the time
    """
    response = base_response(action)
    response["attachments"] = not_direct_messaged_attachment()
    response["attachments"][0]["text"] = reset_greet_message(action["user"]["id"])

    await app.plugins["slack"].api.query(methods.CHAT_UPDATE, response)
Пример #3
0
async def resource_buttons(action: Action, app: SirBot):
    """
    Edits the resource message with the clicked on resource
    """
    name = action["actions"][0]["name"]

    response = base_response(action)
    response["text"] = HELP_MENU_RESPONSES[name]

    await app.plugins["slack"].api.query(methods.CHAT_UPDATE, response)
async def reset_claim(action: Action, app: SirBot):
    """
    Provides basic "unclaim" functionality for use-cases that don't have any other effects.

    Updates the button back to its initial state
    """
    response = base_response(action)

    attachments = action["original_message"]["attachments"]
    for index, attachment in enumerate(attachments):
        if "callback_id" in attachment and attachment[
                "callback_id"] == "claimed":
            attachments[index] = not_claimed_attachment()

    response["attachments"] = attachments
    await app.plugins["slack"].api.query(methods.CHAT_UPDATE, response)
async def claimed(action: Action, app: SirBot):
    """
    Provides basic "claim" functionality for use-cases that don't have any other effects.

    Simply updates the button to allow resets and displays the user and time it was clicked.
    """
    response = base_response(action)
    user_id = action["user"]["id"]

    attachments = action["original_message"]["attachments"]

    for index, attachment in enumerate(attachments):
        if "callback_id" in attachment and attachment[
                "callback_id"] == "claimed":
            attachments[index] = claimed_attachment(user_id)
    response["attachments"] = attachments

    await app.plugins["slack"].api.query(methods.CHAT_UPDATE, response)