mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Merge branch 'dev-2.x' into dev-2.x-api-5.0
This commit is contained in:
commit
a7d759cdbe
3 changed files with 20 additions and 6 deletions
|
|
@ -11,7 +11,7 @@ from .chat_permissions import ChatPermissions
|
|||
from .chat_photo import ChatPhoto
|
||||
from .input_file import InputFile
|
||||
from ..utils import helper, markdown
|
||||
from ..utils.deprecated import deprecated
|
||||
from ..utils.deprecated import deprecated, DeprecatedReadOnlyClassVar
|
||||
|
||||
|
||||
class Chat(base.TelegramObject):
|
||||
|
|
@ -550,6 +550,7 @@ class ChatType(helper.Helper):
|
|||
:key: PRIVATE
|
||||
:key: GROUP
|
||||
:key: SUPER_GROUP
|
||||
:key: SUPERGROUP
|
||||
:key: CHANNEL
|
||||
"""
|
||||
|
||||
|
|
@ -557,9 +558,14 @@ class ChatType(helper.Helper):
|
|||
|
||||
PRIVATE = helper.Item() # private
|
||||
GROUP = helper.Item() # group
|
||||
SUPER_GROUP = helper.Item() # supergroup
|
||||
SUPERGROUP = helper.Item() # supergroup
|
||||
CHANNEL = helper.Item() # channel
|
||||
|
||||
SUPER_GROUP: DeprecatedReadOnlyClassVar[ChatType, helper.Item] \
|
||||
= DeprecatedReadOnlyClassVar(
|
||||
"SUPER_GROUP chat type is deprecated, use SUPERGROUP instead.",
|
||||
new_value_getter=lambda cls: cls.SUPERGROUP)
|
||||
|
||||
@staticmethod
|
||||
def _check(obj, chat_types) -> bool:
|
||||
if hasattr(obj, 'chat'):
|
||||
|
|
@ -599,7 +605,7 @@ class ChatType(helper.Helper):
|
|||
:param obj:
|
||||
:return:
|
||||
"""
|
||||
return cls._check(obj, [cls.SUPER_GROUP])
|
||||
return cls._check(obj, [cls.SUPER_GROUP, cls.SUPERGROUP])
|
||||
|
||||
@classmethod
|
||||
@deprecated("This filter was moved to ChatTypeFilter, and will be removed in aiogram v3.0")
|
||||
|
|
@ -610,7 +616,7 @@ class ChatType(helper.Helper):
|
|||
:param obj:
|
||||
:return:
|
||||
"""
|
||||
return cls._check(obj, [cls.GROUP, cls.SUPER_GROUP])
|
||||
return cls._check(obj, [cls.GROUP, cls.SUPER_GROUP, cls.SUPERGROUP])
|
||||
|
||||
@classmethod
|
||||
@deprecated("This filter was moved to ChatTypeFilter, and will be removed in aiogram v3.0")
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import io
|
|||
import logging
|
||||
import os
|
||||
import secrets
|
||||
from pathlib import Path
|
||||
from typing import Union
|
||||
|
||||
import aiohttp
|
||||
|
||||
|
|
@ -25,7 +27,7 @@ class InputFile(base.TelegramObject):
|
|||
https://core.telegram.org/bots/api#inputfile
|
||||
"""
|
||||
|
||||
def __init__(self, path_or_bytesio, filename=None, conf=None):
|
||||
def __init__(self, path_or_bytesio: Union[str, io.IOBase, Path], filename=None, conf=None):
|
||||
"""
|
||||
|
||||
:param path_or_bytesio:
|
||||
|
|
@ -45,6 +47,12 @@ class InputFile(base.TelegramObject):
|
|||
elif isinstance(path_or_bytesio, _WebPipe):
|
||||
self._path = None
|
||||
self._file = path_or_bytesio
|
||||
|
||||
elif isinstance(path_or_bytesio, Path):
|
||||
self._file = path_or_bytesio.open("rb")
|
||||
self._path = path_or_bytesio.resolve()
|
||||
if filename is None:
|
||||
filename = path_or_bytesio.name
|
||||
else:
|
||||
raise TypeError('Not supported file type.')
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ Next step: interaction with bots starts with one command. Register your first co
|
|||
:language: python
|
||||
:lines: 20-25
|
||||
|
||||
If you want to handle all messages in the chat simply add handler without filters:
|
||||
If you want to handle all text messages in the chat simply add handler without filters:
|
||||
|
||||
.. literalinclude:: ../../examples/echo_bot.py
|
||||
:language: python
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue