Merge branch 'feature/better-player-count-on-reconnect' into temp-develop

feature/embed-uploads
Tristan Gosselin-Hane 7 years ago
commit 2254879d56
No known key found for this signature in database
GPG Key ID: 86886FC44C72EAA1
  1. 15
      webhook-bridge.py

@ -274,6 +274,9 @@ def main():
player_uuid = action.uuid player_uuid = action.uuid
if action.name not in PLAYER_LIST.inv: if action.name not in PLAYER_LIST.inv:
PLAYER_LIST.inv[action.name] = action.uuid PLAYER_LIST.inv[action.name] = action.uuid
else:
# Sometimes we get a duplicate add packet on join idk why
return
if action.name not in UUID_CACHE.inv: if action.name not in UUID_CACHE.inv:
UUID_CACHE.inv[action.name] = action.uuid UUID_CACHE.inv[action.name] = action.uuid
# Initial tablist backfill # Initial tablist backfill
@ -295,8 +298,12 @@ def main():
ACCEPT_JOIN_EVENTS = True ACCEPT_JOIN_EVENTS = True
if config.es_enabled: if config.es_enabled:
diff = set(PREVIOUS_PLAYER_LIST.keys()) - set(PLAYER_LIST.keys()) diff = set(PREVIOUS_PLAYER_LIST.keys()) - set(PLAYER_LIST.keys())
for uuid in diff: for idx, uuid in enumerate(diff):
es_connection(uuid=uuid, reason=ConnectionReason.DISCONNECTED, count=len(PLAYER_LIST)) es_connection(uuid=uuid, reason=ConnectionReason.DISCONNECTED,
count=len(PREVIOUS_PLAYER_LIST) - (idx + 1))
# Don't bother announcing the bot's own join message (who cares) but log it for analytics still
if config.es_enabled:
es_connection(uuid=action.uuid, reason=ConnectionReason.CONNECTED, count=len(PLAYER_LIST))
if config.es_enabled: if config.es_enabled:
es_connection(uuid=action.uuid, reason=ConnectionReason.SEEN) es_connection(uuid=action.uuid, reason=ConnectionReason.SEEN)
@ -312,10 +319,10 @@ def main():
} }
for webhook in WEBHOOKS: for webhook in WEBHOOKS:
post = requests.post(webhook,json=webhook_payload) post = requests.post(webhook,json=webhook_payload)
if config.es_enabled:
es_connection(uuid=action.uuid, reason=ConnectionReason.DISCONNECTED, count=len(PLAYER_LIST))
del UUID_CACHE[action.uuid] del UUID_CACHE[action.uuid]
del PLAYER_LIST[action.uuid] del PLAYER_LIST[action.uuid]
if config.es_enabled:
es_connection(uuid=action.uuid, reason=ConnectionReason.DISCONNECTED, count=len(PLAYER_LIST))
def handle_join_game(join_game_packet): def handle_join_game(join_game_packet):
global PLAYER_LIST global PLAYER_LIST

Loading…
Cancel
Save