diff options
| author | Arslaan Pathan <[email protected]> | 2026-07-08 22:29:51 +1200 |
|---|---|---|
| committer | Arslaan Pathan <[email protected]> | 2026-07-08 22:29:51 +1200 |
| commit | d9d6d7ee74781da95be8b319f84fe7f0a2ea7ee0 (patch) | |
| tree | d69deffcda892a6e02e52b69c53e0ffd133f6551 | |
| parent | dfdd3d01fb361a3dc9269f209a166a781e314f34 (diff) | |
| download | slack-botnet-d9d6d7ee74781da95be8b319f84fe7f0a2ea7ee0.tar.xz slack-botnet-d9d6d7ee74781da95be8b319f84fe7f0a2ea7ee0.zip | |
Do a bit more work and fill in basic command parser
| -rw-r--r-- | example.env | 1 | ||||
| -rw-r--r-- | requirements.txt | 3 | ||||
| -rw-r--r-- | src/main.py | 41 |
3 files changed, 33 insertions, 12 deletions
diff --git a/example.env b/example.env index 248c27c..cfb00b0 100644 --- a/example.env +++ b/example.env @@ -1,3 +1,4 @@ SLACK_SELFBOT_OAUTH_XOXP=xoxp-xxx-your-token-here SLACK_APP_TOKEN=xapp-xxx-your-token-here SELFBOT_USER_ID=UXXXXXXXXXX +HACKCLUB_AI_KEY=sk-hc-v1-xxxxx-your-key-here diff --git a/requirements.txt b/requirements.txt index d7d00be..94e1553 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,4 +5,5 @@ slack-sdk aiosqlite python-dotenv httpx -openai +openrouter +aiohttp 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()) |
