now showing unavailable in queue
authorGeorgios Atheridis <atheridis@tutamail.com>
Mon, 19 Sep 2022 17:11:21 +0000 (17:11 +0000)
committerGeorgios Atheridis <atheridis@tutamail.com>
Mon, 19 Sep 2022 17:11:21 +0000 (17:11 +0000)
skgyorugo/commands/Q.py

index 89e8ee6d8a561f47a45607fd96af06af691b590f..282e530e50bb170f9e4ddc94f945b508d4642776 100644 (file)
@@ -52,6 +52,7 @@ def main(bot: Bot, message: Message):
     fetched = c.fetchall()
     queue = [x[0] for x in fetched]
     twitch = ttv_api.users.get_users(user_ids=queue)
+
     if not twitch:
         bot.send_privmsg(
             message.channel,
@@ -87,6 +88,28 @@ def main(bot: Bot, message: Message):
             reply=message.tags["id"],
         )
 
+    c.execute(
+        """
+        SELECT twitch_id FROM lol_queue WHERE available = 0 ORDER BY position ASC;
+        """
+    )
+    fetched_unavailable = c.fetchall()
+    unavailable = [x[0] for x in fetched_unavailable]
+    twitch_unavailable = ttv_api.users.get_users(user_ids=unavailable)
+
+    unavailable_users = []
+    for twitch_id in unavailable:
+        for twitch_user in twitch_unavailable:
+            if int(twitch_user.user_id) == int(twitch_id):
+                unavailable_users.append(twitch_user.display_name)
+                break
+        else:
+            bot.send_privmsg(
+                message.channel,
+                f"There was an issue fetching data from the user with id {twitch_id}. They won't be in the list. This is a very weird problem to have occured. Sadge",
+                reply=message.tags["id"],
+            )
+
     play_list = [user.display_name for user in queue_users[1:queue_size]]
     prio_queue = []
     wait_list = []
@@ -101,6 +124,10 @@ def main(bot: Bot, message: Message):
         msg = f"These people are playing with {message.channel}: {play_list} | These people are in Priority Queue: {prio_queue} | These people are in the Wait List: {wait_list}."
     else:
         msg = f"These people are playing with {message.channel}: {play_list} | These people are in the Wait List: {wait_list}."
+
+    if unavailable_users:
+        msg += f" | These people are also not here: {unavailable_users}."
+
     tools.smart_privmsg.send(
         bot,
         message,