mirror of
https://github.com/SantaSpeen/Rcon-VK-Bot.git
synced 2026-08-30 05:40:44 +00:00
Code optimization
This commit is contained in:
@@ -28,6 +28,7 @@ def fix_rcon_text(_srt):
|
|||||||
_srt[i + 1] = ''
|
_srt[i + 1] = ''
|
||||||
_srt = ''.join(_srt)
|
_srt = ''.join(_srt)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
print(f"fix_rcon_text ERROR with: {_srt}")
|
||||||
_srt = f'CRITICAL ERROR: {e}'
|
_srt = f'CRITICAL ERROR: {e}'
|
||||||
return _srt
|
return _srt
|
||||||
|
|
||||||
@@ -37,7 +38,9 @@ def rcon(cmd):
|
|||||||
with MCRcon(host, password, port) as mcr:
|
with MCRcon(host, password, port) as mcr:
|
||||||
return fix_rcon_text(mcr.command(cmd))
|
return fix_rcon_text(mcr.command(cmd))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return f"Rcon error"
|
print(f"RCON ERROR with command: {cmd}")
|
||||||
|
print(traceback.format_exc())
|
||||||
|
return f"Rcon error: {e}"
|
||||||
|
|
||||||
|
|
||||||
def get_lp_server():
|
def get_lp_server():
|
||||||
@@ -59,8 +62,8 @@ def main():
|
|||||||
server, key, ts = get_lp_server()
|
server, key, ts = get_lp_server()
|
||||||
print("Listening..")
|
print("Listening..")
|
||||||
while True:
|
while True:
|
||||||
|
lp = requests.get(f'{server}?act=a_check&key={key}&ts={ts}&wait=25').json()
|
||||||
try:
|
try:
|
||||||
lp = requests.get(f'{server}?act=a_check&key={key}&ts={ts}&wait=25').json()
|
|
||||||
if lp.get('failed') is not None:
|
if lp.get('failed') is not None:
|
||||||
key = get_lp_server()[1]
|
key = get_lp_server()[1]
|
||||||
if ts != lp.get('ts') and lp.get('updates'):
|
if ts != lp.get('ts') and lp.get('updates'):
|
||||||
|
|||||||
Reference in New Issue
Block a user