Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for expandable_blockquote #36

Merged
merged 2 commits into from
Jun 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion aiogram_i18n/utils/context_instance.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
from __future__ import annotations

from contextlib import contextmanager
from contextvars import ContextVar, Token
from typing import Any, Generator, Generic, Literal, Optional, TypeVar, cast, overload
from typing import TYPE_CHECKING, Any, Generator, Generic, Optional, TypeVar, cast, overload

if TYPE_CHECKING:
from typing_extensions import Literal

ContextInstance = TypeVar("ContextInstance")

Expand Down
13 changes: 12 additions & 1 deletion aiogram_i18n/utils/text_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,13 @@ def spoiler(self, value: str) -> str:
def quote(self, value: str) -> str:
return value

def custom_emoji(self, value: str, custom_emoji_id: str) -> str:
return value

def blockquote(self, value: str) -> str:
return value

def custom_emoji(self, value: str, custom_emoji_id: str) -> str:
def expandable_blockquote(self, value: str) -> str:
return value


Expand All @@ -70,6 +73,8 @@ def functions(self) -> Dict[str, Callable[..., Any]]:
"SPOILER": self.spoiler,
"QUOTE": self.quote,
"CUSTOM_EMOJI": self.custom_emoji,
"BLOCKQUOTE": self.blockquote,
"EXPANDABLE_BLOCKQUOTE": self.expandable_blockquote,
}

@property
Expand Down Expand Up @@ -122,5 +127,11 @@ def custom_emoji(
) -> str:
return self.get_decoration(parse_mode=parse_mode).custom_emoji(value, custom_emoji_id)

def blockquote(self, value: str, parse_mode: Optional[str] = None) -> str:
return self.get_decoration(parse_mode=parse_mode).blockquote(value)

def expandable_blockquote(self, value: str, parse_mode: Optional[str] = None) -> str:
return self.get_decoration(parse_mode=parse_mode).expandable_blockquote(value)


td = TextDecoration()
Loading