From 239957bb814d263443d5a95d2e526e0420ee570a Mon Sep 17 00:00:00 2001 From: hkc Date: Fri, 26 Aug 2022 14:32:55 +0300 Subject: [PATCH] Imports cleanup, also fixed #4 --- mastoposter/__main__.py | 6 ++---- mastoposter/integrations/__init__.py | 1 + mastoposter/integrations/discord/__init__.py | 10 ++++------ mastoposter/integrations/telegram.py | 3 ++- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/mastoposter/__main__.py b/mastoposter/__main__.py index fce4613..f657340 100644 --- a/mastoposter/__main__.py +++ b/mastoposter/__main__.py @@ -1,11 +1,9 @@ #!/usr/bin/env python3 from asyncio import run from configparser import ConfigParser -from mastoposter.integrations.discord import DiscordIntegration - -from mastoposter.integrations.telegram import TelegramIntegration +from mastoposter.integrations import DiscordIntegration, TelegramIntegration from mastoposter.sources import websocket_source -from typing import Any, AsyncGenerator, Callable, Dict, List +from typing import AsyncGenerator, Callable, List from mastoposter.integrations.base import BaseIntegration from mastoposter.types import Status diff --git a/mastoposter/integrations/__init__.py b/mastoposter/integrations/__init__.py index 1512e6f..0c5a5ea 100644 --- a/mastoposter/integrations/__init__.py +++ b/mastoposter/integrations/__init__.py @@ -1 +1,2 @@ from .telegram import TelegramIntegration +from .discord import DiscordIntegration diff --git a/mastoposter/integrations/discord/__init__.py b/mastoposter/integrations/discord/__init__.py index 0cc21ed..4aa535f 100644 --- a/mastoposter/integrations/discord/__init__.py +++ b/mastoposter/integrations/discord/__init__.py @@ -1,5 +1,4 @@ -from json import dumps -from typing import Dict, List, Optional +from typing import List, Optional from bs4 import BeautifulSoup, PageElement, Tag from httpx import AsyncClient from zlib import crc32 @@ -7,7 +6,6 @@ from mastoposter.integrations.base import BaseIntegration from mastoposter.integrations.discord.types import ( DiscordEmbed, DiscordEmbedAuthor, - DiscordEmbedField, DiscordEmbedImage, ) from mastoposter.types import Status @@ -74,12 +72,12 @@ class DiscordIntegration(BaseIntegration): text = self.node_to_text(BeautifulSoup(source.content, features="lxml")) if source.spoiler_text: - text = f"CW: {source.spoiler_text}\n||{text}||" + text = f"{source.spoiler_text}\n||{text}||" if status.reblog is not None: - title = f"{status.account.acct} boosted from {source.account.acct}" + title = f"@{status.account.acct} boosted from @{source.account.acct}" else: - title = f"{status.account.acct} posted" + title = f"@{status.account.acct} posted" embeds.append( DiscordEmbed( diff --git a/mastoposter/integrations/telegram.py b/mastoposter/integrations/telegram.py index daae0b6..adc2698 100644 --- a/mastoposter/integrations/telegram.py +++ b/mastoposter/integrations/telegram.py @@ -142,7 +142,8 @@ class TelegramIntegration(BaseIntegration): if status.reblog and self.show_boost_from: text = ( 'Boosted post from {}\n'.format( - source.account.url, source.account.display_name + source.account.url, + source.account.display_name or source.account.username, ) + text )