From 93a9929576e38b49a67ad7000f5f7ddba4b8a958 Mon Sep 17 00:00:00 2001 From: Georgios Atheridis Date: Mon, 19 Sep 2022 17:11:21 +0000 Subject: [PATCH] now showing unavailable in queue --- skgyorugo/commands/Q.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/skgyorugo/commands/Q.py b/skgyorugo/commands/Q.py index 89e8ee6..282e530 100644 --- a/skgyorugo/commands/Q.py +++ b/skgyorugo/commands/Q.py @@ -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, -- 2.30.2