From 3904e475a4c59f5884b29c0c21d9c777d2202d94 Mon Sep 17 00:00:00 2001 From: hkc Date: Wed, 2 Nov 2022 20:18:31 +0300 Subject: [PATCH] MORE. LOGS. --- mastoposter/integrations/discord/__init__.py | 9 ++++++++- mastoposter/integrations/telegram.py | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/mastoposter/integrations/discord/__init__.py b/mastoposter/integrations/discord/__init__.py index 04d4d00..dd88b66 100644 --- a/mastoposter/integrations/discord/__init__.py +++ b/mastoposter/integrations/discord/__init__.py @@ -41,12 +41,14 @@ class DiscordIntegration(BaseIntegration): logger.debug("Executing webhook with %r", json) - return ( + result = ( await c.post( self.webhook, json=json, ) ).json() + logger.debug("Result: %r", result) + return result async def __call__(self, status: Status) -> Optional[str]: source = status.reblog or status @@ -88,6 +90,11 @@ class DiscordIntegration(BaseIntegration): ), ) ) + else: + logger.warn( + "Unsupported attachment %r for Discord Embed", + attachment.type, + ) await self.execute_webhook( username=status.account.acct, diff --git a/mastoposter/integrations/telegram.py b/mastoposter/integrations/telegram.py index 9b9889c..50ac846 100644 --- a/mastoposter/integrations/telegram.py +++ b/mastoposter/integrations/telegram.py @@ -88,12 +88,15 @@ class TelegramIntegration(BaseIntegration): async def _tg_request(self, method: str, **kwargs) -> TGResponse: url = API_URL.format(self.token, method) async with AsyncClient() as client: + logger.debug("TG request: %s(%r)", method, kwargs) response = TGResponse.from_dict( (await client.post(url, json=kwargs)).json(), kwargs ) if not response.ok: logger.error("TG error: %r", response.error) logger.error("parameters: %r", kwargs) + else: + logger.debug("Result: %r", response.result) return response async def _post_plaintext(self, text: str) -> TGResponse: