Last active
June 23, 2021 07:41
-
-
Save stupoid/3bf23058468a7987919c6603cd0a4ef4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
from typing import Any, Dict | |
from slack_bolt.adapter.socket_mode.async_handler import AsyncSocketModeHandler | |
from slack_bolt.app.async_app import AsyncApp | |
from slack_bolt.context.ack.async_ack import AsyncAck | |
from slack_bolt.context.say.async_say import AsyncSay | |
app = AsyncApp() | |
@app.command("/hello-socket-mode") # type: ignore | |
async def hello_command(ack: AsyncAck, body: Dict[str, str]) -> None: | |
user_id = body["user_id"] | |
await ack(f"Hi <@{user_id}>!") | |
@app.command("/echo") # type: ignore | |
async def repeat_text(ack: AsyncAck, say: AsyncSay, body: Dict[str, str]) -> None: | |
await ack() | |
await say(f"{body['text']}") | |
@app.event("app_mention") # type: ignore | |
async def event_test(event: Dict[str, Any], say: AsyncSay) -> None: | |
await say(f"Hi there, <@{event['user']}>!") | |
async def main(): | |
handler = AsyncSocketModeHandler(app) | |
await handler.start_async() | |
if __name__ == "__main__": | |
asyncio.run(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment