1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00

Implement net_requests handler on Telegram bot

This commit is contained in:
Steffo 2019-03-19 14:01:00 +01:00
parent 879c0ce953
commit efd18fc3a7
3 changed files with 5 additions and 9 deletions

View file

@ -6,10 +6,6 @@ from ..utils import asyncify, Call, Command
from ..network import RoyalnetLink, Message from ..network import RoyalnetLink, Message
async def null(message: Message):
pass
class TelegramBot: class TelegramBot:
def __init__(self, def __init__(self,
api_key: str, api_key: str,
@ -77,3 +73,6 @@ class TelegramBot:
command = self.missing_command command = self.missing_command
# Call the command # Call the command
return await self.Call(message.chat, command, *parameters).run() return await self.Call(message.chat, command, *parameters).run()
async def handle_net_request(self, message: Message):
pass

View file

@ -138,9 +138,9 @@ class RoyalnetLink:
continue continue
# Package is a request # Package is a request
assert isinstance(package, Package) assert isinstance(package, Package)
log.debug(f"Received request: {package.source} -> {package.data}") log.debug(f"Received request {package.conversation_id}: {package}")
response = await self.request_handler(package.data) response = await self.request_handler(package.data)
if response is not None: if response is not None:
response_package: Package = package.reply(response) response_package: Package = package.reply(response)
await self.send(response_package) await self.send(response_package)
log.debug(f"Replied to request: {response_package.data} -> {response_package.destination}") log.debug(f"Replied to request {response_package.conversation_id}: {response_package}")

View file

@ -88,9 +88,6 @@ class RoyalnetServer:
# Is it nothing? # Is it nothing?
if package.destination == "NULL": if package.destination == "NULL":
return [] return []
# Is it the wildcard?
if package.destination == "*":
return self.identified_clients
# Is it a valid nid? # Is it a valid nid?
try: try:
destination = str(uuid.UUID(package.destination)) destination = str(uuid.UUID(package.destination))