Skip to content

Commit

Permalink
Merge pull request from dev
Browse files Browse the repository at this point in the history
0.5.0
  • Loading branch information
loRes228 authored Jun 1, 2024
2 parents 9eded43 + 02cf2b7 commit e8ae6d6
Show file tree
Hide file tree
Showing 33 changed files with 118 additions and 73 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
cache-dependency-path: pyproject.toml

- name: Install dependencies
run: python -m pip install --upgrade .[dev,test,redis,mongo,sqlalchemy] build pip
run: python -m pip install --upgrade .[dev,test,redis,mongo,sqlalchemy] build pip aiogram

- name: Lint code
run: make lint
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,5 @@
.cache/
.codegen/
dist/
reports/
__pycache__/
.python-version
.coverage
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
* #### From PyPI

```commandline
pip install -U aiogram-broadcaster
pip install --upgrade aiogram-broadcaster
```

* #### From GitHub (_Development build_)

```commandline
pip install https://github.com/loRes228/aiogram_broadcaster/archive/refs/heads/dev.zip
pip install https://github.com/loRes228/aiogram_broadcaster/archive/refs/heads/dev.zip --fore-reinstall
```

## Creating a mailer and running broadcasting
Expand Down Expand Up @@ -410,9 +410,9 @@ async def mailer_completed(my_data: 1) -> None:

* #### [BaseMailerStorage](https://github.com/loRes228/aiogram_broadcaster/blob/main/aiogram_broadcaster/storages/base.py) Abstract class of storage.
* #### [FileMailerStorage](https://github.com/loRes228/aiogram_broadcaster/blob/main/aiogram_broadcaster/storages/file.py) Saves the mailers to a file.
* #### [MongoDBMailerStorage](https://github.com/loRes228/aiogram_broadcaster/blob/main/aiogram_broadcaster/storages/mongodb.py) Saves the mailers to a MongoDB.
* #### [RedisMailerStorage](https://github.com/loRes228/aiogram_broadcaster/blob/main/aiogram_broadcaster/storages/redis.py) Saves the mailers to a Redis.
* #### [SQLAlchemyMailerStorage](https://github.com/loRes228/aiogram_broadcaster/blob/main/aiogram_broadcaster/storages/sqlalchemy.py) Saves the mailers using SQLAlchemy.
* #### [MongoDBMailerStorage](https://github.com/loRes228/aiogram_broadcaster/blob/main/aiogram_broadcaster/storages/mongodb.py) Saves the mailers to a MongoDB. (Extra: mongo)
* #### [RedisMailerStorage](https://github.com/loRes228/aiogram_broadcaster/blob/main/aiogram_broadcaster/storages/redis.py) Saves the mailers to a Redis. (Extra: redis)
* #### [SQLAlchemyMailerStorage](https://github.com/loRes228/aiogram_broadcaster/blob/main/aiogram_broadcaster/storages/sqlalchemy.py) Saves the mailers using SQLAlchemy. (Extra: sqlalchemy)

#### Usage:

Expand Down
2 changes: 1 addition & 1 deletion aiogram_broadcaster/__meta__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.4.7"
__version__ = "0.5.0"
4 changes: 2 additions & 2 deletions aiogram_broadcaster/broadcaster.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def __init__(
def as_group(self) -> MailerGroup:
if not self._mailers:
raise RuntimeError("No mailers for grouping.")
return MailerGroup(*self._mailers.values())
return MailerGroup(*self)

async def create_mailers(
self,
Expand Down Expand Up @@ -189,7 +189,7 @@ async def restore_mailers(self) -> None:
return
bots = {bot.id: bot for bot in self.bots}
for mailer_id in mailer_ids:
if mailer_id in self._mailers:
if mailer_id in self:
continue
try:
record = await self.storage.get(mailer_id=mailer_id)
Expand Down
6 changes: 6 additions & 0 deletions aiogram_broadcaster/contents/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ class AnimationContent(BaseContent):
caption: Optional[str] = None
parse_mode: Optional[Union[str, Default]] = Default("parse_mode")
caption_entities: Optional[List[MessageEntity]] = None
show_caption_above_media: Optional[Union[bool, Default]] = Default("show_caption_above_media")
has_spoiler: Optional[bool] = None
disable_notification: Optional[bool] = None
protect_content: Optional[Union[bool, Default]] = Default("protect_content")
message_effect_id: Optional[str] = None
reply_markup: Optional[
Union[
InlineKeyboardMarkup,
Expand All @@ -48,9 +50,11 @@ async def __call__(self, chat_id: int) -> SendAnimation:
caption=self.caption,
parse_mode=self.parse_mode,
caption_entities=self.caption_entities,
show_caption_above_media=self.show_caption_above_media,
has_spoiler=self.has_spoiler,
disable_notification=self.disable_notification,
protect_content=self.protect_content,
message_effect_id=self.message_effect_id,
reply_markup=self.reply_markup,
**(self.model_extra or {}),
)
Expand All @@ -69,9 +73,11 @@ def __init__(
caption: Optional[str] = ...,
parse_mode: Optional[Union[str, Default]] = ...,
caption_entities: Optional[List[MessageEntity]] = ...,
show_caption_above_media: Optional[Union[bool, Default]] = ...,
has_spoiler: Optional[bool] = ...,
disable_notification: Optional[bool] = ...,
protect_content: Optional[Union[bool, Default]] = ...,
message_effect_id: Optional[str] = ...,
reply_markup: Optional[
Union[
InlineKeyboardMarkup,
Expand Down
3 changes: 3 additions & 0 deletions aiogram_broadcaster/contents/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class AudioContent(BaseContent):
thumbnail: Optional[InputFile] = None
disable_notification: Optional[bool] = None
protect_content: Optional[Union[bool, Default]] = Default("protect_content")
message_effect_id: Optional[str] = None
reply_markup: Optional[
Union[
InlineKeyboardMarkup,
Expand All @@ -49,6 +50,7 @@ async def __call__(self, chat_id: int) -> SendAudio:
thumbnail=self.thumbnail,
disable_notification=self.disable_notification,
protect_content=self.protect_content,
message_effect_id=self.message_effect_id,
reply_markup=self.reply_markup,
**(self.model_extra or {}),
)
Expand All @@ -69,6 +71,7 @@ def __init__(
thumbnail: Optional[InputFile] = ...,
disable_notification: Optional[bool] = ...,
protect_content: Optional[Union[bool, Default]] = ...,
message_effect_id: Optional[str] = ...,
reply_markup: Optional[
Union[
InlineKeyboardMarkup,
Expand Down
3 changes: 3 additions & 0 deletions aiogram_broadcaster/contents/contact.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class ContactContent(BaseContent):
vcard: Optional[str] = None
disable_notification: Optional[bool] = None
protect_content: Optional[Union[bool, Default]] = Default("protect_content")
message_effect_id: Optional[str] = None
reply_markup: Optional[
Union[
InlineKeyboardMarkup,
Expand All @@ -39,6 +40,7 @@ async def __call__(self, chat_id: int) -> SendContact:
vcard=self.vcard,
disable_notification=self.disable_notification,
protect_content=self.protect_content,
message_effect_id=self.message_effect_id,
reply_markup=self.reply_markup,
**(self.model_extra or {}),
)
Expand All @@ -55,6 +57,7 @@ def __init__(
vcard: Optional[str] = ...,
disable_notification: Optional[bool] = ...,
protect_content: Optional[Union[bool, Default]] = ...,
message_effect_id: Optional[str] = ...,
reply_markup: Optional[
Union[
InlineKeyboardMarkup,
Expand Down
3 changes: 3 additions & 0 deletions aiogram_broadcaster/contents/dice.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class DiceContent(BaseContent):
emoji: Optional[str] = None
disable_notification: Optional[bool] = None
protect_content: Optional[Union[bool, Default]] = Default("protect_content")
message_effect_id: Optional[str] = None
reply_markup: Optional[
Union[
InlineKeyboardMarkup,
Expand All @@ -33,6 +34,7 @@ async def __call__(self, chat_id: int) -> SendDice:
emoji=self.emoji,
disable_notification=self.disable_notification,
protect_content=self.protect_content,
message_effect_id=self.message_effect_id,
reply_markup=self.reply_markup,
**(self.model_extra or {}),
)
Expand All @@ -46,6 +48,7 @@ def __init__(
emoji: Optional[str] = ...,
disable_notification: Optional[bool] = ...,
protect_content: Optional[Union[bool, Default]] = ...,
message_effect_id: Optional[str] = ...,
reply_markup: Optional[
Union[
InlineKeyboardMarkup,
Expand Down
3 changes: 3 additions & 0 deletions aiogram_broadcaster/contents/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class DocumentContent(BaseContent):
disable_content_type_detection: Optional[bool] = None
disable_notification: Optional[bool] = None
protect_content: Optional[Union[bool, Default]] = Default("protect_content")
message_effect_id: Optional[str] = None
reply_markup: Optional[
Union[
InlineKeyboardMarkup,
Expand All @@ -45,6 +46,7 @@ async def __call__(self, chat_id: int) -> SendDocument:
disable_content_type_detection=self.disable_content_type_detection,
disable_notification=self.disable_notification,
protect_content=self.protect_content,
message_effect_id=self.message_effect_id,
reply_markup=self.reply_markup,
**(self.model_extra or {}),
)
Expand All @@ -63,6 +65,7 @@ def __init__(
disable_content_type_detection: Optional[bool] = ...,
disable_notification: Optional[bool] = ...,
protect_content: Optional[Union[bool, Default]] = ...,
message_effect_id: Optional[str] = ...,
reply_markup: Optional[
Union[
InlineKeyboardMarkup,
Expand Down
3 changes: 3 additions & 0 deletions aiogram_broadcaster/contents/from_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class FromChatCopyContent(BaseContent):
caption: Optional[str] = None
parse_mode: Optional[Union[str, Default]] = Default("parse_mode")
caption_entities: Optional[List[MessageEntity]] = None
show_caption_above_media: Optional[Union[bool, Default]] = Default("show_caption_above_media")
disable_notification: Optional[bool] = None
protect_content: Optional[Union[bool, Default]] = Default("protect_content")
reply_markup: Optional[
Expand All @@ -38,6 +39,7 @@ async def __call__(self, chat_id: int) -> CopyMessage:
caption=self.caption,
parse_mode=self.parse_mode,
caption_entities=self.caption_entities,
show_caption_above_media=self.show_caption_above_media,
disable_notification=self.disable_notification,
protect_content=self.protect_content,
reply_markup=self.reply_markup,
Expand All @@ -54,6 +56,7 @@ def __init__(
caption: Optional[str] = ...,
parse_mode: Optional[Union[str, Default]] = ...,
caption_entities: Optional[List[MessageEntity]] = ...,
show_caption_above_media: Optional[Union[bool, Default]] = ...,
disable_notification: Optional[bool] = ...,
protect_content: Optional[Union[bool, Default]] = ...,
reply_markup: Optional[
Expand Down
3 changes: 3 additions & 0 deletions aiogram_broadcaster/contents/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class GameContent(BaseContent):
business_connection_id: Optional[str] = None
disable_notification: Optional[bool] = None
protect_content: Optional[Union[bool, Default]] = Default("protect_content")
message_effect_id: Optional[str] = None
reply_markup: Optional[InlineKeyboardMarkup] = None

async def __call__(self, chat_id: int) -> SendGame:
Expand All @@ -21,6 +22,7 @@ async def __call__(self, chat_id: int) -> SendGame:
business_connection_id=self.business_connection_id,
disable_notification=self.disable_notification,
protect_content=self.protect_content,
message_effect_id=self.message_effect_id,
reply_markup=self.reply_markup,
**(self.model_extra or {}),
)
Expand All @@ -34,6 +36,7 @@ def __init__(
business_connection_id: Optional[str] = ...,
disable_notification: Optional[bool] = ...,
protect_content: Optional[Union[bool, Default]] = ...,
message_effect_id: Optional[str] = ...,
reply_markup: Optional[InlineKeyboardMarkup] = ...,
**kwargs: Any,
) -> None: ...
9 changes: 6 additions & 3 deletions aiogram_broadcaster/contents/invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ class InvoiceContent(BaseContent):
title: str
description: str
payload: str
provider_token: str
currency: str
prices: List[LabeledPrice]
provider_token: Optional[str] = None
max_tip_amount: Optional[int] = None
suggested_tip_amounts: Optional[List[int]] = None
start_parameter: Optional[str] = None
Expand All @@ -31,6 +31,7 @@ class InvoiceContent(BaseContent):
is_flexible: Optional[bool] = None
disable_notification: Optional[bool] = None
protect_content: Optional[Union[bool, Default]] = Default("protect_content")
message_effect_id: Optional[str] = None
reply_markup: Optional[InlineKeyboardMarkup] = None

async def __call__(self, chat_id: int) -> SendInvoice:
Expand All @@ -39,9 +40,9 @@ async def __call__(self, chat_id: int) -> SendInvoice:
title=self.title,
description=self.description,
payload=self.payload,
provider_token=self.provider_token,
currency=self.currency,
prices=self.prices,
provider_token=self.provider_token,
max_tip_amount=self.max_tip_amount,
suggested_tip_amounts=self.suggested_tip_amounts,
start_parameter=self.start_parameter,
Expand All @@ -59,6 +60,7 @@ async def __call__(self, chat_id: int) -> SendInvoice:
is_flexible=self.is_flexible,
disable_notification=self.disable_notification,
protect_content=self.protect_content,
message_effect_id=self.message_effect_id,
reply_markup=self.reply_markup,
**(self.model_extra or {}),
)
Expand All @@ -71,9 +73,9 @@ def __init__(
title: str,
description: str,
payload: str,
provider_token: str,
currency: str,
prices: List[LabeledPrice],
provider_token: Optional[str] = ...,
max_tip_amount: Optional[int] = ...,
suggested_tip_amounts: Optional[List[int]] = ...,
start_parameter: Optional[str] = ...,
Expand All @@ -91,6 +93,7 @@ def __init__(
is_flexible: Optional[bool] = ...,
disable_notification: Optional[bool] = ...,
protect_content: Optional[Union[bool, Default]] = ...,
message_effect_id: Optional[str] = ...,
reply_markup: Optional[InlineKeyboardMarkup] = ...,
**kwargs: Any,
) -> None: ...
4 changes: 1 addition & 3 deletions aiogram_broadcaster/contents/key_based.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
from typing import TYPE_CHECKING, Any, Dict, Optional

from aiogram.methods import TelegramMethod
from pydantic import ConfigDict, SerializeAsAny
from pydantic import SerializeAsAny

from .base import BaseContent


class KeyBasedContent(BaseContent, register=False):
model_config = ConfigDict(extra="allow")

default: Optional[SerializeAsAny[BaseContent]] = None
__pydantic_extra__: Dict[str, SerializeAsAny[BaseContent]]

Expand Down
3 changes: 3 additions & 0 deletions aiogram_broadcaster/contents/location.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class LocationContent(BaseContent):
proximity_alert_radius: Optional[int] = None
disable_notification: Optional[bool] = None
protect_content: Optional[Union[bool, Default]] = Default("protect_content")
message_effect_id: Optional[str] = None
reply_markup: Optional[
Union[
InlineKeyboardMarkup,
Expand All @@ -43,6 +44,7 @@ async def __call__(self, chat_id: int) -> SendLocation:
proximity_alert_radius=self.proximity_alert_radius,
disable_notification=self.disable_notification,
protect_content=self.protect_content,
message_effect_id=self.message_effect_id,
reply_markup=self.reply_markup,
**(self.model_extra or {}),
)
Expand All @@ -61,6 +63,7 @@ def __init__(
proximity_alert_radius: Optional[int] = ...,
disable_notification: Optional[bool] = ...,
protect_content: Optional[Union[bool, Default]] = ...,
message_effect_id: Optional[str] = ...,
reply_markup: Optional[
Union[
InlineKeyboardMarkup,
Expand Down
3 changes: 3 additions & 0 deletions aiogram_broadcaster/contents/media_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class MediaGroupContent(BaseContent):
business_connection_id: Optional[str] = None
disable_notification: Optional[bool] = None
protect_content: Optional[Union[bool, Default]] = Default("protect_content")
message_effect_id: Optional[str] = None

async def __call__(self, chat_id: int) -> SendMediaGroup:
return SendMediaGroup(
Expand All @@ -27,6 +28,7 @@ async def __call__(self, chat_id: int) -> SendMediaGroup:
business_connection_id=self.business_connection_id,
disable_notification=self.disable_notification,
protect_content=self.protect_content,
message_effect_id=self.message_effect_id,
**(self.model_extra or {}),
)

Expand All @@ -46,5 +48,6 @@ def __init__(
business_connection_id: Optional[str] = ...,
disable_notification: Optional[bool] = ...,
protect_content: Optional[Union[bool, Default]] = ...,
message_effect_id: Optional[str] = ...,
**kwargs: Any,
) -> None: ...
Loading

0 comments on commit e8ae6d6

Please sign in to comment.