Don't spam the discord side with join messages while the tab list is

being backfilled
Fix player list bug
feature/embed-uploads
Tristan Gosselin-Hane 7 years ago
parent 1f4ae6e31a
commit 05baa28a8c
  1. 7
      webhook-bridge.py

@ -36,6 +36,7 @@ NEXT_MESSAGE_TIME = datetime.now(timezone.utc)
PREVIOUS_MESSAGE = ""
PLAYER_LIST = bidict()
MOTD = "Not yet implemented"
LAST_CONNECTION_TIME = datetime.now(timezone.utc)
def mc_uuid_to_username(uuid):
@ -144,6 +145,7 @@ def main():
def handle_disconnect():
logging.info('Disconnected.')
global PLAYER_LIST
PLAYER_LIST = bidict()
connection.disconnect(immediate=True)
time.sleep(15)
@ -227,6 +229,8 @@ def main():
"Processing AddPlayerAction tab list packet, name: {}, uuid: {}".format(action.name, action.uuid))
username = action.name
player_uuid = action.uuid
# Initial tablist backfill
if LAST_CONNECTION_TIME + timedelta(seconds=2.5) < datetime.now(timezone.utc):
webhook_payload = {
'username': username,
'avatar_url': "https://visage.surgeplay.com/face/160/{}".format(player_uuid),
@ -255,7 +259,8 @@ def main():
del PLAYER_LIST[action.uuid]
def handle_join_game(join_game_packet):
global PLAYER_LIST
global PLAYER_LIST, LAST_CONNECTION_TIME
LAST_CONNECTION_TIME = datetime.now(timezone.utc)
logging.info('Connected.')
PLAYER_LIST = bidict()

Loading…
Cancel
Save