diff --git a/backend/bang/game.py b/backend/bang/game.py index ce0eeecb..80994f53 100644 --- a/backend/bang/game.py +++ b/backend/bang/game.py @@ -80,8 +80,10 @@ def replay(self, log): self.is_hidden = True self.is_replay = True self.replay_speed = 1 - for i in range(len(log)): - print('replay:', i, 'of', len(log)) + for i in range(len(log)-1): + print('replay:', i, 'of', len(log)-3, '->', log[i]) + if (log[i] == "@@@"): + break cmd = log[i].split(';') if cmd[1] == 'players': self.expansions = json.loads(cmd[4].replace("'",'"')) diff --git a/backend/server.py b/backend/server.py index a04a0c36..01b3dc43 100644 --- a/backend/server.py +++ b/backend/server.py @@ -57,6 +57,24 @@ def get_online_players(sid): global online_players sio.emit('players', room='lobby', data=online_players) +@sio.event +def report(sid, text): + ses: Player = sio.get_session(sid) + data='' + if hasattr(ses, 'game'): + data = "\n".join(ses.game.rpc_log[:-1]).strip() + data = data +"\n@@@\n" +text + #print(data) + response = requests.post("https://www.toptal.com/developers/hastebin/documents", data) + key = json.loads(response.text).get('key') + if "DISCORD_WEBHOOK" in os.environ and len(os.environ['DISCORD_WEBHOOK']) > 0: + webhook = DiscordWebhook(url=os.environ['DISCORD_WEBHOOK'], content=f'New bug report, replay at https://www.toptal.com/developers/hastebin/{key}') + response = webhook.execute() + sio.emit('chat_message', room=sid, data={'color': f'green','text':f'Report OK'}) + else: + print("WARNING: DISCORD_WEBHOOK not found") + print(f'New bug report, replay at https://www.toptal.com/developers/hastebin/{key}') + @sio.event def set_username(sid, username): ses = sio.get_session(sid) @@ -337,18 +355,6 @@ def chat_message(sid, msg, pl=None): ses.game.add_player(bot) bot.bot_spin() return - if '/report' in msg and not ses.game.is_replay: - data = "\n".join(ses.game.rpc_log[:-1]).strip() - response = requests.post("https://www.toptal.com/developers/hastebin/documents", data) - key = json.loads(response.text).get('key') - if "DISCORD_WEBHOOK" in os.environ and len(os.environ['DISCORD_WEBHOOK']) > 0: - webhook = DiscordWebhook(url=os.environ['DISCORD_WEBHOOK'], content=f'New bug report, replay at https://www.toptal.com/developers/hastebin/{key}') - response = webhook.execute() - sio.emit('chat_message', room=sid, data={'color': f'green','text':f'Report OK'}) - else: - print("WARNING: DISCORD_WEBHOOK not found") - print(f'New bug report, replay at https://www.toptal.com/developers/hastebin/{key}') - return if '/replay' in msg and not '/replayspeed' in msg: _cmd = msg.split() if len(_cmd) == 2: diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 56031a96..367c83fe 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -9,6 +9,7 @@
+