From efd18fc3a7d924c9feadd88e9d0553326583f96c Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Tue, 19 Mar 2019 14:01:00 +0100 Subject: [PATCH] Implement net_requests handler on Telegram bot --- royalnet/bots/telegram.py | 7 +++---- royalnet/network/royalnetlink.py | 4 ++-- royalnet/network/royalnetserver.py | 3 --- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/royalnet/bots/telegram.py b/royalnet/bots/telegram.py index 866d9eb1..d3c46c33 100644 --- a/royalnet/bots/telegram.py +++ b/royalnet/bots/telegram.py @@ -6,10 +6,6 @@ from ..utils import asyncify, Call, Command from ..network import RoyalnetLink, Message -async def null(message: Message): - pass - - class TelegramBot: def __init__(self, api_key: str, @@ -77,3 +73,6 @@ class TelegramBot: command = self.missing_command # Call the command return await self.Call(message.chat, command, *parameters).run() + + async def handle_net_request(self, message: Message): + pass diff --git a/royalnet/network/royalnetlink.py b/royalnet/network/royalnetlink.py index 65aa68ab..6f6f679b 100644 --- a/royalnet/network/royalnetlink.py +++ b/royalnet/network/royalnetlink.py @@ -138,9 +138,9 @@ class RoyalnetLink: continue # Package is a request 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) if response is not None: response_package: Package = package.reply(response) 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}") diff --git a/royalnet/network/royalnetserver.py b/royalnet/network/royalnetserver.py index 54500c4f..208d805e 100644 --- a/royalnet/network/royalnetserver.py +++ b/royalnet/network/royalnetserver.py @@ -88,9 +88,6 @@ class RoyalnetServer: # Is it nothing? if package.destination == "NULL": return [] - # Is it the wildcard? - if package.destination == "*": - return self.identified_clients # Is it a valid nid? try: destination = str(uuid.UUID(package.destination))