17c776faec
-> !wants -> !orgs info -> special cmd's -> !assist -> "afk" for players without active account -> !loot add <item_ref> <count> => nolonger breaks !account Changes: -> grouped !tara, !gaunt, .. into !wb -> Display the most recent news entry on logon (default: enabled) -> improved grouping of !items -> Added the option to authentificate WS connections (Datanet module). This is used in special cases, where the Websocket Server requires the clien tto authentificate itself. (Server sends "#auth", client responds with the auth string) -> Add main name to relaying (priv <-> org) [default: disabled] -> Added logon/logoff messages back -> restricted default access to "dangerous" commands to moderator -> Added optional logging (Private Channel, Org Channel, Tells, ... disabled by default) Rewrite of the Tower Module. -> More verbosity, if enabled in config. by default, GAS and Hot timer only. -> !hot displays currently hot (and in penalty) sites, and these which go hot in < 60 minutes -> !attacks filterable by PF and Site -> display current contract QL's grouped by org: !contracts (requires managed cache)
46 lines
1.3 KiB
Python
46 lines
1.3 KiB
Python
import json
|
|
|
|
from websocket import create_connection, WebSocketConnectionClosedException
|
|
|
|
from core.dict_object import DictObject
|
|
from core.logger import Logger
|
|
|
|
|
|
class WebsocketRelayWorker:
|
|
def __init__(self, inbound_queue, url, auth):
|
|
self.logger = Logger(__name__)
|
|
self.inbound_queue = inbound_queue
|
|
self.url = url
|
|
self.auth = auth
|
|
self.ws = None
|
|
|
|
def run(self):
|
|
try:
|
|
self.ws = create_connection(self.url)
|
|
self.logger.info(f"Connected to Datanet Relay!")
|
|
self.inbound_queue.append(DictObject({"type": "connected"}))
|
|
|
|
result = self.ws.recv()
|
|
while result:
|
|
if result == "#auth":
|
|
self.ws.send(self.auth)
|
|
else:
|
|
obj = DictObject(json.loads(result))
|
|
self.inbound_queue.append(obj)
|
|
result = self.ws.recv()
|
|
self.ws.close()
|
|
except ConnectionRefusedError:
|
|
pass
|
|
except ConnectionResetError:
|
|
pass
|
|
except WebSocketConnectionClosedException:
|
|
pass
|
|
|
|
def send_message(self, message):
|
|
if self.ws:
|
|
self.ws.send(message)
|
|
|
|
def close(self):
|
|
if self.ws:
|
|
self.ws.close()
|