removed debug

This commit is contained in:
Amazed 2020-09-28 03:52:04 +02:00
parent 28389931df
commit d66160b27d

View File

@ -33,40 +33,32 @@ class SacrificeCog(commands.Cog):
@commands.Cog.listener() @commands.Cog.listener()
async def on_raw_reaction_add(self, payload): async def on_raw_reaction_add(self, payload):
tracked = await self.config.tracked_msgs() tracked = await self.config.tracked_msgs()
print(str(payload.message_id)) await self.log(str(payload.message_id))
print(tracked.keys()) await self.log(tracked.keys())
if str(payload.message_id) in tracked.keys(): if str(payload.message_id) in tracked.keys():
# fetch channel # fetch channel
channel = await self.bot.fetch_channel(620879085739966464) # channel channel = await self.bot.fetch_channel(620879085739966464) # channel
if not channel: if not channel:
print("not channel")
tracked.remove(payload.message_id) tracked.remove(payload.message_id)
await self.config.tracked_msgs.set(tracked) await self.config.tracked_msgs.set(tracked)
return return
# fetch msg # fetch msg
orig_msg = await channel.fetch_message(payload.message_id) orig_msg = await channel.fetch_message(payload.message_id)
if not orig_msg: if not orig_msg:
print("not msg")
tracked.remove(payload.message_id) tracked.remove(payload.message_id)
await self.config.tracked_msgs.set(tracked) await self.config.tracked_msgs.set(tracked)
return return
opponents = orig_msg.mentions opponents = orig_msg.mentions
if not opponents: if not opponents:
print("not opponent")
tracked.remove(payload.message_id) tracked.remove(payload.message_id)
await self.config.tracked_msgs.set(tracked) await self.config.tracked_msgs.set(tracked)
return return
opponent = opponents[0] opponent = opponents[0]
print("not yet")
print(str(payload.user_id))
print(str(opponent.id))
print(payload.emoji)
if str(payload.user_id) == str(opponent.id) and payload.emoji.name == "👍": if str(payload.user_id) == str(opponent.id) and payload.emoji.name == "👍":
print("true") await self.log("true")
outcome = orig_msg.content.split(" ")[2] outcome = orig_msg.content.split(" ")[2]
print(outcome) # DEBUG
if SacrificeCog.is_valid_winloss(outcome): if SacrificeCog.is_valid_winloss(outcome):
for c in outcome: for c in outcome:
if c.lower() == "w": if c.lower() == "w":
@ -86,10 +78,6 @@ class SacrificeCog(commands.Cog):
del tracked[str(payload.message_id)] del tracked[str(payload.message_id)]
await self.config.tracked_msgs.set(tracked) await self.config.tracked_msgs.set(tracked)
return return
else:
print("not valid winloss: %s" % outcome)
else:
print("not tracked")
async def track_msg(self, orig_message_id: str, bot_msg_id: str): async def track_msg(self, orig_message_id: str, bot_msg_id: str):
tracked = await self.config.tracked_msgs() tracked = await self.config.tracked_msgs()
@ -140,7 +128,6 @@ class SacrificeCog(commands.Cog):
k_winner = 40 # TODO: should be lowered after many games k_winner = 40 # TODO: should be lowered after many games
k_looser = 40 # TODO: should be lowered after many games k_looser = 40 # TODO: should be lowered after many games
new_elo_winner = elo_winner + k_winner * (1 - expection_winner) new_elo_winner = elo_winner + k_winner * (1 - expection_winner)
print("%s = %s + %s * (1 - %s)" % (new_elo_winner, elo_winner, k_winner, expection_winner))
new_elo_looser = elo_looser + k_looser * (0 - expection_looser) new_elo_looser = elo_looser + k_looser * (0 - expection_looser)
await self.save_elo({winner_id: new_elo_winner, looser_id: new_elo_looser}) await self.save_elo({winner_id: new_elo_winner, looser_id: new_elo_looser})