aboutsummaryrefslogtreecommitdiff
path: root/src/main.py
blob: 6f5e2d6a53acde367f8a1b085f0f020e23a48d72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import os
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()

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("")
async def handle_messages(message, say):
    if message.get("channel_type") != "im":
        return
    
    if message.get("user") == selfbot_user_id:
        return
    
    text = message.get("text", "").lower().strip()
    
    if not text.startswith("botnet"):
        return
    
    parts = text.split(" ")
    if len(parts) == 1:
        # 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:]
    
    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")
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=app_token)
    # handler.start()
    asyncio.run(main())