aboutsummaryrefslogtreecommitdiff
path: root/src/botnet.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/botnet.py')
-rw-r--r--src/botnet.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/botnet.py b/src/botnet.py
index 377c0c2..225f7e9 100644
--- a/src/botnet.py
+++ b/src/botnet.py
@@ -1,5 +1,5 @@
from .db import create_deployment, get_daily_user_deployment_count, get_deployment, update_deployment_status, get_active_users, get_user, add_deployment_message, get_deployment_messages
-from .utils import generate_voting_blocks
+from .utils import generate_voting_blocks, get_random_channel
from slack_sdk.web.async_client import AsyncWebClient
import os
from dotenv import load_dotenv
@@ -122,8 +122,14 @@ async def execute_deployment(deployment_id: int):
for user in users:
try:
client = AsyncWebClient(token=user["oauth_token"])
+ channel = await get_random_channel(user["oauth_token"])
+ if not channel:
+ print(f"No channels found for {user['slack_id']}, using #botnet")
+ channel_id = "C0BGMV1CAQG"
+ else:
+ channel_id = channel["id"]
response = await client.chat_postMessage(
- channel="C0BGMV1CAQG", # put it in #botnet for now, make it detect recent thread with CM approval yada yada later
+ channel=channel_id, # put it in #botnet for now, make it detect recent thread with CM approval yada yada later
text=message,
as_user=True
)