app = Slackle()
@slackle.formatter.register(UserData)
class GreetingFormatter(BaseFormatter):
data_type = UserData
@classmethod
def default_params(cls):
return GreetingFormatterParams()
def to_slack_markdown(self) -> SlackMarkdown:
return SlackMarkdown(
f"Hi {self.data.name} :wave:"
)
@slackle.on_event("app_mention")
async def on_mention(user_id):
formatter = app.formatter.get(UserData)(user_id, parameter)
message = formatter.to_slack_markdown()
return await slack.send_message(message, channel_id)