blob: 6dd5cad9cb3d8090c41af7e5bc9cb89c1d41b764 (
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
|
from slack_sdk.web.async_client import AsyncWebClient
import aiosqlite
DB_PATH = "botnet.db"
async def init_db():
async with aiosqlite.connect(DB_PATH) as db:
await db.execute("""
CREATE TABLE IF NOT EXISTS Users (
slack_id TEXT PRIMARY KEY,
oauth_token TEXT NOT NULL,
joined_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)
""")
await db.commit()
async def add_user(slack_id: str, oauth_token: str):
async with aiosqlite.connect(DB_PATH) as db:
await db.execute(
"INSERT OR REPLACE INTO Users (slack_id, oauth_token) VALUES (?, ?)",
(slack_id, oauth_token)
)
await db.commit()
client = AsyncWebClient(token=oauth_token)
try:
await client.chat_postMessage(
channel="C0BGMV1CAQG",
text="I've joined the botnet!",
as_user=True
)
except Exception as e:
print(f"Failed to send welcome message: {e}")
|