Compare commits

..

No commits in common. "de91d075b4627ff754770b4f2b0d62883929a9b9" and "7e0c50a04e15a3c33b2051484f87d443d6acffe1" have entirely different histories.

4 changed files with 6 additions and 39 deletions

View File

@ -194,13 +194,7 @@ class Client:
async def _recv(self, one=False):
while self.__alive:
try:
header = b""
while len(header) < 4 and self.__alive:
h = await self.__reader.read(4)
if not h:
break
else:
header += h
header = await self.__reader.read(4)
int_header = int.from_bytes(header, byteorder='little', signed=True)
@ -225,14 +219,9 @@ class Client:
self.__packets_queue.append(None)
continue
data = b""
while len(data) < int_header and self.__alive:
buffer = await self.__reader.read(int_header - len(data))
if not buffer:
break
else:
data += buffer
data = await self.__reader.read(int_header)
# self.log.debug(f"int_header: {int_header}; data: `{data}`;")
abg = b"ABG:"
if len(data) > len(abg) and data.startswith(abg):
data = zlib.decompress(data[len(abg):])

View File

@ -217,22 +217,6 @@ class Core:
except Exception as e:
self.log.error(f"Error in heartbeat: {e}")
async def kick_cmd(self, args):
if not len(args) > 0:
return "\nUsage: kick <nick>|:<id> [reason]\nExamples:\n\tkick admin bad boy\n\tkick :0 bad boy"
reason = "kicked by console."
if len(args) > 1:
reason = " ".join(args[1:])
cl = args[0]
if cl.startswith(":") and cl[1:].isdigit():
client = self.get_client(cid=int(cl[1:]))
else:
client = self.get_client(nick=cl)
if client:
await client.kick(reason)
else:
return "Client not found."
async def main(self):
self.tcp = self.tcp(self, self.server_ip, self.server_port)
self.udp = self.udp(self, self.server_ip, self.server_port)
@ -240,7 +224,6 @@ class Core:
"list",
lambda x: f"Players list: {self.get_clients_list(True)}"
)
console.add_command("kick", self.kick_cmd)
pl_dir = "plugins"
self.log.debug("Initializing PluginsLoaders...")

View File

@ -100,8 +100,8 @@ class UDPServer(asyncio.DatagramTransport):
await asyncio.sleep(0.2)
except OSError as e:
# self.run = False
# self.Core.run = False
self.run = False
self.Core.run = False
self.log.error(f"Cannot bind port or other error: {e}")
except Exception as e:
self.log.error(f"Error: {e}")

View File

@ -7,7 +7,6 @@
# Licence: FPA
# (c) kuitoi.su 2023
import builtins
import inspect
import logging
from typing import AnyStr
@ -243,11 +242,7 @@ class Console:
self.log(text)
command_object = self.__func.get(cmd)
if command_object:
func = command_object['f']
if inspect.iscoroutinefunction(func):
out = await func(cmd_s[1:])
else:
out = func(cmd_s[1:])
out = command_object['f'](cmd_s[1:])
if out:
self.log(out)
else: