fixed bug for opgg command
authorGeorgios Atheridis <atheridis@tutamail.com>
Fri, 6 May 2022 13:25:25 +0000 (13:25 +0000)
committerGeorgios Atheridis <atheridis@tutamail.com>
Fri, 6 May 2022 13:25:25 +0000 (13:25 +0000)
skgyorugo/commands/opgg.py

index b488884b31259484f92d8b15cf6e57d725f12213..89b31305a8f35d3e1edeb180f1060c82ad023cd3 100644 (file)
@@ -36,26 +36,16 @@ def get_twitch_user_data(twitch_id: int):
     raise NotImplementedError()
 
 def main(bot: Bot, message: Message):
-    try:
-        replied_message = message.tags["reply-parent-msg-body"]
-    except KeyError:
-        replied_message = None
-    if replied_message:
-        msg = replied_message
-        replied_msg_id = message.tags["reply-parent-msg-id"]
-    else:
-        msg = ' '.join(message.value.split(' ')[1:])
-        replied_msg_id = None
-
     try:
         twitch_user = message.value.split(' ')[1]
     except IndexError:
+        twitch_user = message.tags.get("reply-parent-display-name", message.channel)
         twitch_id = message.tags.get("reply-parent-user-id", ttv_api.users.get_users(user_logins=[message.channel]))
     else:
         twitch_id = ttv_api.users.get_users(user_logins=[twitch_user])
 
     if not twitch_id:
-        logger.warning(f"There was an issue getting twitch data for user {twitch_id}; message was: {message.value}")
+        logger.warning(f"There was an issue getting twitch data for user {twitch_id}; message id was: {message.tags['id']}")
         smart_privmsg.send(bot, message, "Couldn't retrieve data", reply=message.tags["id"])
         return
 
@@ -76,7 +66,7 @@ def main(bot: Bot, message: Message):
     fetched = c.fetchall()
 
     if not fetched:
-        smart_privmsg.send(bot, message, f"No summoners added for that twitch user", reply=message.tags["id"])
+        smart_privmsg.send(bot, message, f"No summoners added for {twitch_user}", reply=message.tags["id"])
         return
     
     summoner_names = []
@@ -88,7 +78,7 @@ def main(bot: Bot, message: Message):
         if info:
             break
     else:
-        smart_privmsg.send(bot, message, f"{{channel}} is currently not in game. These are all of his summoners: {summoner_names}", reply=message.tags["id"])
+        smart_privmsg.send(bot, message, f"{twitch_user} is currently not in game. These are all of their summoners: {summoner_names}", reply=message.tags["id"])
         return
 
-    smart_privmsg.send(bot, message, f"{{channel}} is currently playing a game on: {summoner_names[-1]}", reply=message.tags["id"])
+    smart_privmsg.send(bot, message, f"{twitch_user} is currently playing a game on: {summoner_names[-1]}", reply=message.tags["id"])