Last active
December 19, 2019 03:50
-
-
Save diVineProportion/83e29dc16178cb1e5226382671965bff to your computer and use it in GitHub Desktop.
gamechat, damage, killfeed, event messages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import sys | |
import time | |
import requests | |
def gamechat(id_msg=0): | |
url_gamechat = "http://localhost:8111/gamechat?lastId={}" | |
url_gamechat = url_gamechat.format(id_msg) | |
req_gamechat = requests.get(url_gamechat, timeout=0.02) | |
return req_gamechat.json() | |
def hudmsg(id_evt=0, id_dmg=0): | |
url_hudmsg = "http://localhost:8111/hudmsg?lastEvt={}&lastDmg={}" | |
url_hudmsg = url_hudmsg.format(id_evt, id_dmg) | |
req_hudmsg = requests.get(url_hudmsg, timeout=0.02) | |
return req_hudmsg.json() | |
def run_once(statement, check): | |
if not checks[check]: | |
print(statement) | |
checks[check] = True | |
last_id_msg = 0 | |
last_id_evt = 0 | |
last_id_dmg = 0 | |
keep_looping = True | |
while keep_looping: | |
try: | |
req_gamechat = gamechat(last_id_msg) | |
req_hudmsg = hudmsg(last_id_evt, last_id_dmg) | |
list_msglog = req_gamechat | |
list_evtlog = req_hudmsg['events'] | |
list_dmglog = req_hudmsg['damage'] | |
if list_msglog: | |
for items in list_msglog: | |
print("MSG:", items) | |
list_last_msglog = list_msglog | |
last_id_msg = list_last_msglog[-1]['id'] | |
if list_evtlog: | |
for items in list_evtlog: | |
print("EVT:", items) | |
list_last_evtlog = list_evtlog | |
last_id_evt = list_last_evtlog[-1]['id'] | |
if list_dmglog: | |
for items in list_dmglog: | |
print("DMG:", items) | |
list_last_dmglog = list_dmglog | |
last_id_dmg = list_last_dmglog[-1]['id'] | |
keep_looping = True | |
except requests.exceptions.ReadTimeout as e: | |
pass | |
# print(e) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment