mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Added changelog and partial docs
This commit is contained in:
parent
47bd869bbd
commit
262c0e8a6e
6 changed files with 30 additions and 12 deletions
1
CHANGES/1392.feature.rst
Normal file
1
CHANGES/1392.feature.rst
Normal file
|
|
@ -0,0 +1 @@
|
|||
Reworked bot-wide globals like :code:`parse_mode`, :code:`disable_web_page_preview`, and others to be more flexible.
|
||||
|
|
@ -20,9 +20,7 @@ from typing import (
|
|||
import aiofiles
|
||||
|
||||
from aiogram.utils.token import extract_bot_id, validate_token
|
||||
from .default import Default, DefaultBotProperties
|
||||
from .session.aiohttp import AiohttpSession
|
||||
from .session.base import BaseSession
|
||||
|
||||
from ..methods import (
|
||||
AddStickerToSet,
|
||||
AnswerCallbackQuery,
|
||||
|
|
@ -235,6 +233,9 @@ from ..types import (
|
|||
UserProfilePhotos,
|
||||
WebhookInfo,
|
||||
)
|
||||
from .default import Default, DefaultBotProperties
|
||||
from .session.aiohttp import AiohttpSession
|
||||
from .session.base import BaseSession
|
||||
|
||||
T = TypeVar("T")
|
||||
|
||||
|
|
@ -278,9 +279,6 @@ class Bot:
|
|||
)
|
||||
|
||||
self.session = session
|
||||
self.parse_mode = parse_mode
|
||||
self.disable_web_page_preview = disable_web_page_preview
|
||||
self.protect_content = protect_content
|
||||
if (
|
||||
parse_mode is not None
|
||||
or disable_web_page_preview is not None
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ from __future__ import annotations
|
|||
|
||||
import sys
|
||||
from dataclasses import dataclass
|
||||
from typing import Any, Optional, TYPE_CHECKING, Dict
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from aiogram.types import LinkPreviewOptions
|
||||
|
|
@ -41,25 +41,36 @@ class DefaultBotProperties:
|
|||
"""
|
||||
|
||||
parse_mode: Optional[str] = None
|
||||
"""Default parse mode for messages."""
|
||||
disable_notification: Optional[bool] = None
|
||||
"""Sends the message silently. Users will receive a notification with no sound."""
|
||||
protect_content: Optional[bool] = None
|
||||
"""Protects content from copying."""
|
||||
allow_sending_without_reply: Optional[bool] = None
|
||||
"""Allows to send messages without reply."""
|
||||
|
||||
link_preview: Optional[LinkPreviewOptions] = None
|
||||
"""Link preview settings."""
|
||||
link_preview_is_disabled: Optional[bool] = None
|
||||
"""Disables link preview."""
|
||||
link_preview_prefer_small_media: Optional[bool] = None
|
||||
"""Prefer small media in link preview."""
|
||||
link_preview_prefer_large_media: Optional[bool] = None
|
||||
"""Prefer large media in link preview."""
|
||||
link_preview_show_above_text: Optional[bool] = None
|
||||
"""Show link preview above text."""
|
||||
|
||||
def __post_init__(self) -> None:
|
||||
if any(
|
||||
has_any_link_preview_option = any(
|
||||
(
|
||||
self.link_preview_is_disabled,
|
||||
self.link_preview_prefer_small_media,
|
||||
self.link_preview_prefer_large_media,
|
||||
self.link_preview_show_above_text,
|
||||
)
|
||||
):
|
||||
)
|
||||
|
||||
if has_any_link_preview_option and self.link_preview is None:
|
||||
from ..types import LinkPreviewOptions
|
||||
|
||||
self.link_preview = LinkPreviewOptions(
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ from typing import TYPE_CHECKING, Any, List, Optional, Union
|
|||
|
||||
from pydantic import Field
|
||||
|
||||
from .base import TelegramMethod
|
||||
from ..client.default import Default
|
||||
from ..types import (
|
||||
ForceReply,
|
||||
|
|
@ -16,6 +15,7 @@ from ..types import (
|
|||
ReplyKeyboardRemove,
|
||||
ReplyParameters,
|
||||
)
|
||||
from .base import TelegramMethod
|
||||
|
||||
|
||||
class SendMessage(TelegramMethod[Message]):
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
from typing import TYPE_CHECKING, Any, Optional, Union
|
||||
|
||||
from .base import TelegramObject
|
||||
from ..client.default import Default
|
||||
from .base import TelegramObject
|
||||
|
||||
|
||||
class LinkPreviewOptions(TelegramObject):
|
||||
|
|
|
|||
|
|
@ -1,5 +1,13 @@
|
|||
import asyncio
|
||||
from typing import Any, AsyncContextManager, AsyncGenerator, AsyncIterable, Dict, List, Union
|
||||
from typing import (
|
||||
Any,
|
||||
AsyncContextManager,
|
||||
AsyncGenerator,
|
||||
AsyncIterable,
|
||||
Dict,
|
||||
List,
|
||||
Union,
|
||||
)
|
||||
from unittest.mock import AsyncMock, patch
|
||||
|
||||
import aiohttp_socks
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue