diff --git a/Makefile b/Makefile index e01e336..6fd9b31 100644 --- a/Makefile +++ b/Makefile @@ -10,5 +10,5 @@ lint: .PHONY: format format: - ruff check --fix ${CODE_DIRS} ruff format ${CODE_DIRS} + ruff check --fix ${CODE_DIRS} diff --git a/aiogram_broadcaster/__meta__.py b/aiogram_broadcaster/__meta__.py index df12433..f6b7e26 100644 --- a/aiogram_broadcaster/__meta__.py +++ b/aiogram_broadcaster/__meta__.py @@ -1 +1 @@ -__version__ = "0.4.2" +__version__ = "0.4.3" diff --git a/aiogram_broadcaster/contents/animation.py b/aiogram_broadcaster/contents/animation.py index f512335..4c15ddd 100644 --- a/aiogram_broadcaster/contents/animation.py +++ b/aiogram_broadcaster/contents/animation.py @@ -66,11 +66,11 @@ def __init__( height: Optional[int] = ..., thumbnail: Optional[InputFile] = ..., caption: Optional[str] = ..., - parse_mode: Optional[str] = ..., + parse_mode: Optional[Union[str, Default]] = ..., caption_entities: Optional[List[MessageEntity]] = ..., has_spoiler: Optional[bool] = ..., disable_notification: Optional[bool] = ..., - protect_content: Optional[bool] = ..., + protect_content: Optional[Union[bool, Default]] = ..., reply_markup: Optional[ Union[ InlineKeyboardMarkup, diff --git a/aiogram_broadcaster/contents/audio.py b/aiogram_broadcaster/contents/audio.py index a275992..810a54f 100644 --- a/aiogram_broadcaster/contents/audio.py +++ b/aiogram_broadcaster/contents/audio.py @@ -60,14 +60,14 @@ def __init__( audio: Union[InputFile, str], business_connection_id: Optional[str] = ..., caption: Optional[str] = ..., - parse_mode: Optional[str] = ..., + parse_mode: Optional[Union[str, Default]] = ..., caption_entities: Optional[List[MessageEntity]] = ..., duration: Optional[int] = ..., performer: Optional[str] = ..., title: Optional[str] = ..., thumbnail: Optional[InputFile] = ..., disable_notification: Optional[bool] = ..., - protect_content: Optional[bool] = ..., + protect_content: Optional[Union[bool, Default]] = ..., reply_markup: Optional[ Union[ InlineKeyboardMarkup, diff --git a/aiogram_broadcaster/contents/contact.py b/aiogram_broadcaster/contents/contact.py index d9553d1..c83c998 100644 --- a/aiogram_broadcaster/contents/contact.py +++ b/aiogram_broadcaster/contents/contact.py @@ -51,9 +51,9 @@ def __init__( first_name: str, business_connection_id: Optional[str] = ..., last_name: Optional[str] = ..., - vcard: Optional[str] = None, + vcard: Optional[str] = ..., disable_notification: Optional[bool] = ..., - protect_content: Optional[bool] = ..., + protect_content: Optional[Union[bool, Default]] = ..., reply_markup: Optional[ Union[ InlineKeyboardMarkup, diff --git a/aiogram_broadcaster/contents/dice.py b/aiogram_broadcaster/contents/dice.py index 4225dff..1a01645 100644 --- a/aiogram_broadcaster/contents/dice.py +++ b/aiogram_broadcaster/contents/dice.py @@ -44,7 +44,7 @@ def __init__( business_connection_id: Optional[str] = ..., emoji: Optional[str] = ..., disable_notification: Optional[bool] = ..., - protect_content: Optional[bool] = ..., + protect_content: Optional[Union[bool, Default]] = ..., reply_markup: Optional[ Union[ InlineKeyboardMarkup, diff --git a/aiogram_broadcaster/contents/document.py b/aiogram_broadcaster/contents/document.py index a203c69..def4da6 100644 --- a/aiogram_broadcaster/contents/document.py +++ b/aiogram_broadcaster/contents/document.py @@ -57,11 +57,11 @@ def __init__( business_connection_id: Optional[str] = ..., thumbnail: Optional[InputFile] = ..., caption: Optional[str] = ..., - parse_mode: Optional[str] = ..., + parse_mode: Optional[Union[str, Default]] = ..., caption_entities: Optional[List[MessageEntity]] = ..., disable_content_type_detection: Optional[bool] = ..., disable_notification: Optional[bool] = ..., - protect_content: Optional[bool] = ..., + protect_content: Optional[Union[bool, Default]] = ..., reply_markup: Optional[ Union[ InlineKeyboardMarkup, diff --git a/aiogram_broadcaster/contents/from_chat.py b/aiogram_broadcaster/contents/from_chat.py index cad2947..c29293a 100644 --- a/aiogram_broadcaster/contents/from_chat.py +++ b/aiogram_broadcaster/contents/from_chat.py @@ -89,5 +89,5 @@ def __init__( from_chat_id: Union[int, str], message_id: int, disable_notification: Optional[bool] = ..., - protect_content: Optional[bool] = ..., + protect_content: Optional[Union[bool, Default]] = ..., ) -> None: ... diff --git a/aiogram_broadcaster/contents/game.py b/aiogram_broadcaster/contents/game.py index b35ccab..db7b844 100644 --- a/aiogram_broadcaster/contents/game.py +++ b/aiogram_broadcaster/contents/game.py @@ -2,7 +2,9 @@ from aiogram.client.default import Default from aiogram.methods import SendGame -from aiogram.types import InlineKeyboardMarkup +from aiogram.types import ( + InlineKeyboardMarkup, +) from .base import BaseContent @@ -32,6 +34,6 @@ def __init__( game_short_name: str, business_connection_id: Optional[str] = ..., disable_notification: Optional[bool] = ..., - protect_content: Optional[bool] = ..., + protect_content: Optional[Union[bool, Default]] = ..., reply_markup: Optional[InlineKeyboardMarkup] = ..., ) -> None: ... diff --git a/aiogram_broadcaster/contents/invoice.py b/aiogram_broadcaster/contents/invoice.py index f2b66d8..cbffcce 100644 --- a/aiogram_broadcaster/contents/invoice.py +++ b/aiogram_broadcaster/contents/invoice.py @@ -2,7 +2,10 @@ from aiogram.client.default import Default from aiogram.methods import SendInvoice -from aiogram.types import InlineKeyboardMarkup, LabeledPrice +from aiogram.types import ( + InlineKeyboardMarkup, + LabeledPrice, +) from .base import BaseContent @@ -89,6 +92,6 @@ def __init__( send_email_to_provider: Optional[bool] = ..., is_flexible: Optional[bool] = ..., disable_notification: Optional[bool] = ..., - protect_content: Optional[bool] = ..., + protect_content: Optional[Union[bool, Default]] = ..., reply_markup: Optional[InlineKeyboardMarkup] = ..., ) -> None: ... diff --git a/aiogram_broadcaster/contents/location.py b/aiogram_broadcaster/contents/location.py index c1096f5..fcd7bf5 100644 --- a/aiogram_broadcaster/contents/location.py +++ b/aiogram_broadcaster/contents/location.py @@ -59,7 +59,7 @@ def __init__( heading: Optional[int] = ..., proximity_alert_radius: Optional[int] = ..., disable_notification: Optional[bool] = ..., - protect_content: Optional[bool] = ..., + protect_content: Optional[Union[bool, Default]] = ..., reply_markup: Optional[ Union[ InlineKeyboardMarkup, diff --git a/aiogram_broadcaster/contents/media_group.py b/aiogram_broadcaster/contents/media_group.py index 68dc6ef..46833b5 100644 --- a/aiogram_broadcaster/contents/media_group.py +++ b/aiogram_broadcaster/contents/media_group.py @@ -44,5 +44,5 @@ def __init__( ], business_connection_id: Optional[str] = ..., disable_notification: Optional[bool] = ..., - protect_content: Optional[bool] = ..., + protect_content: Optional[Union[bool, Default]] = ..., ) -> None: ... diff --git a/aiogram_broadcaster/contents/message.py b/aiogram_broadcaster/contents/message.py index ad29ba3..ddd049f 100644 --- a/aiogram_broadcaster/contents/message.py +++ b/aiogram_broadcaster/contents/message.py @@ -1,7 +1,24 @@ -from typing import TYPE_CHECKING, Any, List, Optional, Union +from typing import TYPE_CHECKING, List, Optional, Union from aiogram.client.default import Default -from aiogram.methods import CopyMessage, ForwardMessage, TelegramMethod +from aiogram.methods import ( + CopyMessage, + ForwardMessage, + SendAnimation, + SendAudio, + SendContact, + SendDice, + SendDocument, + SendLocation, + SendMessage, + SendPhoto, + SendPoll, + SendSticker, + SendVenue, + SendVideo, + SendVideoNote, + SendVoice, +) from aiogram.types import ( ForceReply, InlineKeyboardMarkup, @@ -48,10 +65,10 @@ def __init__( *, message: Message, caption: Optional[str] = ..., - parse_mode: Optional[str] = ..., + parse_mode: Optional[Union[str, Default]] = ..., caption_entities: Optional[List[MessageEntity]] = ..., disable_notification: Optional[bool] = ..., - protect_content: Optional[bool] = ..., + protect_content: Optional[Union[bool, Default]] = ..., reply_markup: Optional[ Union[ InlineKeyboardMarkup, @@ -82,7 +99,7 @@ def __init__( *, message: Message, disable_notification: Optional[bool] = ..., - protect_content: Optional[bool] = ..., + protect_content: Optional[Union[bool, Default]] = ..., ) -> None: ... @@ -93,7 +110,26 @@ class MessageSendContent(BaseContent): business_connection_id: Optional[str] = None parse_mode: Optional[str] = None - async def __call__(self, chat_id: int) -> TelegramMethod[Any]: + async def __call__( + self, + chat_id: int, + ) -> Union[ + ForwardMessage, + SendAnimation, + SendAudio, + SendContact, + SendDocument, + SendLocation, + SendMessage, + SendPhoto, + SendPoll, + SendDice, + SendSticker, + SendVenue, + SendVideo, + SendVideoNote, + SendVoice, + ]: return self.message.send_copy( chat_id=chat_id, disable_notification=self.disable_notification, diff --git a/aiogram_broadcaster/contents/photo.py b/aiogram_broadcaster/contents/photo.py index 8f76e22..71d0e38 100644 --- a/aiogram_broadcaster/contents/photo.py +++ b/aiogram_broadcaster/contents/photo.py @@ -54,11 +54,11 @@ def __init__( photo: Union[InputFile, str], business_connection_id: Optional[str] = ..., caption: Optional[str] = ..., - parse_mode: Optional[str] = ..., + parse_mode: Optional[Union[str, Default]] = ..., caption_entities: Optional[List[MessageEntity]] = ..., has_spoiler: Optional[bool] = ..., disable_notification: Optional[bool] = ..., - protect_content: Optional[bool] = ..., + protect_content: Optional[Union[bool, Default]] = ..., reply_markup: Optional[ Union[ InlineKeyboardMarkup, diff --git a/aiogram_broadcaster/contents/poll.py b/aiogram_broadcaster/contents/poll.py index 93e664b..d7fc505 100644 --- a/aiogram_broadcaster/contents/poll.py +++ b/aiogram_broadcaster/contents/poll.py @@ -6,6 +6,7 @@ from aiogram.types import ( ForceReply, InlineKeyboardMarkup, + InputPollOption, MessageEntity, ReplyKeyboardMarkup, ReplyKeyboardRemove, @@ -16,8 +17,10 @@ class PollContent(BaseContent): question: str - options: List[str] + options: List[Union[InputPollOption, str]] business_connection_id: Optional[str] = None + question_parse_mode: Optional[Union[str, Default]] = Default("parse_mode") + question_entities: Optional[List[MessageEntity]] = None is_anonymous: Optional[bool] = None type: Optional[str] = None allows_multiple_answers: Optional[bool] = None @@ -45,6 +48,8 @@ async def __call__(self, chat_id: int) -> SendPoll: question=self.question, options=self.options, business_connection_id=self.business_connection_id, + question_parse_mode=self.question_parse_mode, + question_entities=self.question_entities, is_anonymous=self.is_anonymous, type=self.type, allows_multiple_answers=self.allows_multiple_answers, @@ -66,20 +71,22 @@ def __init__( self, *, question: str, - options: List[str], + options: List[Union[InputPollOption, str]], business_connection_id: Optional[str] = ..., + question_parse_mode: Optional[Union[str, Default]] = ..., + question_entities: Optional[List[MessageEntity]] = ..., is_anonymous: Optional[bool] = ..., type: Optional[str] = ..., # noqa: A002 allows_multiple_answers: Optional[bool] = ..., correct_option_id: Optional[int] = ..., explanation: Optional[str] = ..., - explanation_parse_mode: Optional[str] = ..., + explanation_parse_mode: Optional[Union[str, Default]] = ..., explanation_entities: Optional[List[MessageEntity]] = ..., open_period: Optional[int] = ..., close_date: Optional[Union[datetime, timedelta, int]] = ..., is_closed: Optional[bool] = ..., disable_notification: Optional[bool] = ..., - protect_content: Optional[bool] = ..., + protect_content: Optional[Union[bool, Default]] = ..., reply_markup: Optional[ Union[ InlineKeyboardMarkup, diff --git a/aiogram_broadcaster/contents/sticker.py b/aiogram_broadcaster/contents/sticker.py index d68f98e..6a76410 100644 --- a/aiogram_broadcaster/contents/sticker.py +++ b/aiogram_broadcaster/contents/sticker.py @@ -48,7 +48,7 @@ def __init__( business_connection_id: Optional[str] = ..., emoji: Optional[str] = ..., disable_notification: Optional[bool] = ..., - protect_content: Optional[bool] = ..., + protect_content: Optional[Union[bool, Default]] = ..., reply_markup: Optional[ Union[ InlineKeyboardMarkup, diff --git a/aiogram_broadcaster/contents/text.py b/aiogram_broadcaster/contents/text.py index 753f6d9..f15567b 100644 --- a/aiogram_broadcaster/contents/text.py +++ b/aiogram_broadcaster/contents/text.py @@ -51,11 +51,11 @@ def __init__( *, text: str, business_connection_id: Optional[str] = ..., - parse_mode: Optional[str] = ..., + parse_mode: Optional[Union[str, Default]] = ..., entities: Optional[List[MessageEntity]] = ..., - link_preview_options: Optional[LinkPreviewOptions] = ..., + link_preview_options: Optional[Union[LinkPreviewOptions, Default]] = ..., disable_notification: Optional[bool] = ..., - protect_content: Optional[bool] = ..., + protect_content: Optional[Union[bool, Default]] = ..., reply_markup: Optional[ Union[ InlineKeyboardMarkup, diff --git a/aiogram_broadcaster/contents/venue.py b/aiogram_broadcaster/contents/venue.py index b9bfd6b..7cc3c7e 100644 --- a/aiogram_broadcaster/contents/venue.py +++ b/aiogram_broadcaster/contents/venue.py @@ -65,7 +65,7 @@ def __init__( google_place_id: Optional[str] = ..., google_place_type: Optional[str] = ..., disable_notification: Optional[bool] = ..., - protect_content: Optional[bool] = ..., + protect_content: Optional[Union[bool, Default]] = ..., reply_markup: Optional[ Union[ InlineKeyboardMarkup, diff --git a/aiogram_broadcaster/contents/video.py b/aiogram_broadcaster/contents/video.py index 979a115..a9735c4 100644 --- a/aiogram_broadcaster/contents/video.py +++ b/aiogram_broadcaster/contents/video.py @@ -68,12 +68,12 @@ def __init__( height: Optional[int] = ..., thumbnail: Optional[InputFile] = ..., caption: Optional[str] = ..., - parse_mode: Optional[str] = ..., + parse_mode: Optional[Union[str, Default]] = ..., caption_entities: Optional[List[MessageEntity]] = ..., has_spoiler: Optional[bool] = ..., supports_streaming: Optional[bool] = ..., disable_notification: Optional[bool] = ..., - protect_content: Optional[bool] = ..., + protect_content: Optional[Union[bool, Default]] = ..., reply_markup: Optional[ Union[ InlineKeyboardMarkup, diff --git a/aiogram_broadcaster/contents/video_note.py b/aiogram_broadcaster/contents/video_note.py index 3318146..a78bf84 100644 --- a/aiogram_broadcaster/contents/video_note.py +++ b/aiogram_broadcaster/contents/video_note.py @@ -54,7 +54,7 @@ def __init__( length: Optional[int] = ..., thumbnail: Optional[InputFile] = ..., disable_notification: Optional[bool] = ..., - protect_content: Optional[bool] = ..., + protect_content: Optional[Union[bool, Default]] = ..., reply_markup: Optional[ Union[ InlineKeyboardMarkup, diff --git a/aiogram_broadcaster/contents/voice.py b/aiogram_broadcaster/contents/voice.py index 1c2730e..004bd85 100644 --- a/aiogram_broadcaster/contents/voice.py +++ b/aiogram_broadcaster/contents/voice.py @@ -54,11 +54,11 @@ def __init__( voice: Union[InputFile, str], business_connection_id: Optional[str] = ..., caption: Optional[str] = ..., - parse_mode: Optional[str] = ..., + parse_mode: Optional[Union[str, Default]] = ..., caption_entities: Optional[List[MessageEntity]] = ..., duration: Optional[int] = ..., disable_notification: Optional[bool] = ..., - protect_content: Optional[bool] = ..., + protect_content: Optional[Union[bool, Default]] = ..., reply_markup: Optional[ Union[ InlineKeyboardMarkup, diff --git a/pyproject.toml b/pyproject.toml index 380cf75..c0a457e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,10 +10,10 @@ readme = "README.md" requires-python = ">=3.8" license = "MIT" authors = [ - { name = "LORES" }, + { name = "LORES" } ] dependencies = [ - "aiogram>=3.4.0" + "aiogram>=3.6.0" ] [project.urls] @@ -26,13 +26,13 @@ dev = [ "types-aiofiles>=23.2.0" ] redis = [ - "redis[hiredis]>=5.0.0", + "redis[hiredis]>=5.0.0" ] mongo = [ "motor>=3.0.0" ] sqlalchemy = [ - "SQLAlchemy>=2.0.0", + "SQLAlchemy>=2.0.0" ] [tool.hatch.version]