diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.py | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/src/main.py b/src/main.py index f16c198..6f5e2d6 100644 --- a/src/main.py +++ b/src/main.py @@ -1,18 +1,23 @@ import os -from slack_bolt import App -from slack_bolt.adapter.socket_mode import SocketModeHandler +from slack_bolt.app.async_app import AsyncApp +from slack_bolt.adapter.socket_mode.async_handler import AsyncSocketModeHandler from dotenv import load_dotenv +import asyncio load_dotenv() -app = App(token=os.environ.get("SLACK_SELFBOT_OAUTH_XOXP")) +selfbot_token = os.environ.get("SLACK_SELFBOT_OAUTH_XOXP") +app_token = os.environ.get("SLACK_APP_TOKEN") +selfbot_user_id = os.environ.get("SELFBOT_USER_ID") + +app = AsyncApp(token=selfbot_token) @app.message("") -def handle_messages(message, say): +async def handle_messages(message, say): if message.get("channel_type") != "im": return - if message.get("user") == 'U0BFUFPFDGE': + if message.get("user") == selfbot_user_id: return text = message.get("text", "").lower().strip() @@ -22,18 +27,32 @@ def handle_messages(message, say): parts = text.split(" ") if len(parts) == 1: - say("Usage:\n`botnet help`") - return + # scuffed as hell, just sets it to help arbitrarily so it gets caught later LMAO + # too bad, if it works dont touch it + parts = ['botnet', 'help'] command = parts[1] args = parts[2:] - say(f"Command: {command}, Args: {args}") + if command == "help": + await say("*Botnet Commands*:\n---\n*botnet help*: shows this message\n*botnet deploy <message>*: sends a message into the deploy queue for review/voting\n*botnet approve <channel>*: approve Botnet to function in a channel (must be CM)", mrkdwn=True) + elif command == "deploy": + await say("Not implemented yet") + elif command == "approve": + await say("Not implemented yet") + else: + await say("Unknown command: {command}") @app.event("message") -def shut_up_slack_bolt(): +async def shut_up_slack_bolt(): + # shut up that annoying debug warning that this event is unhandled pass +async def main(): + handler = AsyncSocketModeHandler(app, app_token=app_token) + await handler.start_async() + if __name__ == "__main__": - handler = SocketModeHandler(app, app_token=os.environ.get("SLACK_APP_TOKEN")) - handler.start() + # handler = SocketModeHandler(app, app_token=app_token) + # handler.start() + asyncio.run(main()) |
