diff --git a/.gitignore b/.gitignore index adae094..b71c8b0 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,4 @@ __pycache__/ cert/ data/ docker-compose.yml -x.py +utils/x.py diff --git a/main.py b/main.py index bcebd89..92e793e 100644 --- a/main.py +++ b/main.py @@ -10,7 +10,7 @@ from telegram.ext import (ApplicationBuilder, CallbackQueryHandler, CommandHandl InlineQueryHandler, MessageHandler, PicklePersistence, filters) import common -from tweet import Telegram +from utils.tweet import Telegram if TYPE_CHECKING: from telegram import Chat, Message, Update diff --git a/types.py b/types.py deleted file mode 100644 index 65428d6..0000000 --- a/types.py +++ /dev/null @@ -1,19 +0,0 @@ -from typing import Type, TypedDict - -from telegram import InlineQueryResultMpeg4Gif, InlineQueryResultPhoto, InlineQueryResultVideo, InputMediaPhoto, \ - InputMediaVideo - -TypeInlineQueryResult: Type[ - InlineQueryResultMpeg4Gif | InlineQueryResultPhoto | InlineQueryResultVideo] = InlineQueryResultMpeg4Gif | InlineQueryResultPhoto | InlineQueryResultVideo -InputMediaAnimation = tuple[str, bool] -TypeMessageMediaResult: Type[ - InputMediaPhoto | InputMediaVideo | InputMediaAnimation] = InputMediaPhoto | InputMediaVideo | InputMediaAnimation - - -class TweetInfo(TypedDict): - tweetID: str - user_name: str - user_screen_name: str - text: str - media_extended: list[dict] - possibly_sensitive: bool diff --git a/utils/__init__.py b/utils/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tweet.py b/utils/tweet.py similarity index 99% rename from tweet.py rename to utils/tweet.py index 69f5d07..ff05800 100644 --- a/tweet.py +++ b/utils/tweet.py @@ -12,7 +12,7 @@ from telegram import (InlineQueryResultMpeg4Gif, InlineQueryResultPhoto, InlineQ from common import get_logger, x_media_regex, x_tco_regex, x_url_regex if TYPE_CHECKING: - from types import TweetInfo, TypeInlineQueryResult, TypeMessageMediaResult + from .types import TweetInfo, TypeInlineQueryResult, TypeMessageMediaResult logger = get_logger(__name__) diff --git a/utils/types.py b/utils/types.py new file mode 100644 index 0000000..d100c7b --- /dev/null +++ b/utils/types.py @@ -0,0 +1,17 @@ +from typing import TypedDict + +from telegram import InlineQueryResultMpeg4Gif, InlineQueryResultPhoto, InlineQueryResultVideo, InputMediaPhoto, \ + InputMediaVideo + +TypeInlineQueryResult = InlineQueryResultMpeg4Gif | InlineQueryResultPhoto | InlineQueryResultVideo +InputMediaAnimation = tuple[str, bool] +TypeMessageMediaResult = InputMediaPhoto | InputMediaVideo | InputMediaAnimation + + +class TweetInfo(TypedDict): + tweetID: str + user_name: str + user_screen_name: str + text: str + media_extended: list[dict] + possibly_sensitive: bool