Добавлены типы событий: bot_stopped, dialog_cleared, dialog_muted, dialog_unmuted
This commit is contained in:
parent
1bfd93f2ea
commit
ec432fe8ce
32
maxapi/types/updates/bot_stopped.py
Normal file
32
maxapi/types/updates/bot_stopped.py
Normal file
@ -0,0 +1,32 @@
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
from .update import Update
|
||||
|
||||
from ...types.users import User
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ...bot import Bot
|
||||
|
||||
|
||||
class BotStopped(Update):
|
||||
|
||||
"""
|
||||
Обновление, сигнализирующее об остановке бота.
|
||||
|
||||
Attributes:
|
||||
chat_id (int): Идентификатор чата.
|
||||
user (User): Пользователь (бот).
|
||||
user_locale (Optional[str]): Локаль пользователя.
|
||||
payload (Optional[str]): Дополнительные данные.
|
||||
"""
|
||||
|
||||
chat_id: int
|
||||
user: User
|
||||
user_locale: Optional[str] = None
|
||||
payload: Optional[str] = None
|
||||
|
||||
if TYPE_CHECKING:
|
||||
bot: Optional[Bot]
|
||||
|
||||
def get_ids(self):
|
||||
return (self.chat_id, self.user.user_id)
|
30
maxapi/types/updates/dialog_cleared.py
Normal file
30
maxapi/types/updates/dialog_cleared.py
Normal file
@ -0,0 +1,30 @@
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
from .update import Update
|
||||
|
||||
from ...types.users import User
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ...bot import Bot
|
||||
|
||||
|
||||
class DialogCleared(Update):
|
||||
|
||||
"""
|
||||
Обновление, сигнализирующее об очистке диалога с ботом.
|
||||
|
||||
Attributes:
|
||||
chat_id (int): Идентификатор чата.
|
||||
user (User): Пользователь (бот).
|
||||
user_locale (Optional[str]): Локаль пользователя.
|
||||
"""
|
||||
|
||||
chat_id: int
|
||||
user: User
|
||||
user_locale: Optional[str] = None
|
||||
|
||||
if TYPE_CHECKING:
|
||||
bot: Optional[Bot]
|
||||
|
||||
def get_ids(self):
|
||||
return (self.chat_id, self.user.user_id)
|
40
maxapi/types/updates/dialog_muted.py
Normal file
40
maxapi/types/updates/dialog_muted.py
Normal file
@ -0,0 +1,40 @@
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
from datetime import datetime
|
||||
|
||||
from .update import Update
|
||||
|
||||
from ...types.users import User
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ...bot import Bot
|
||||
|
||||
|
||||
class DialogMuted(Update):
|
||||
|
||||
"""
|
||||
Обновление, сигнализирующее об отключении оповещений от бота.
|
||||
|
||||
Attributes:
|
||||
chat_id (int): Идентификатор чата.
|
||||
muted_until (int): Время до включения оповещений от бота.
|
||||
user (User): Пользователь (бот).
|
||||
user_locale (Optional[str]): Локаль пользователя.
|
||||
"""
|
||||
|
||||
chat_id: int
|
||||
muted_until: int
|
||||
user: User
|
||||
user_locale: Optional[str] = None
|
||||
|
||||
if TYPE_CHECKING:
|
||||
bot: Optional[Bot]
|
||||
|
||||
@property
|
||||
def muted_until_datetime(self):
|
||||
try:
|
||||
return datetime.fromtimestamp(self.muted_until // 1000)
|
||||
except (OverflowError, OSError):
|
||||
return datetime.max
|
||||
|
||||
def get_ids(self):
|
||||
return (self.chat_id, self.user.user_id)
|
30
maxapi/types/updates/dialog_unmuted.py
Normal file
30
maxapi/types/updates/dialog_unmuted.py
Normal file
@ -0,0 +1,30 @@
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
from .update import Update
|
||||
|
||||
from ...types.users import User
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ...bot import Bot
|
||||
|
||||
|
||||
class DialogUnmuted(Update):
|
||||
|
||||
"""
|
||||
Обновление, сигнализирующее о включении оповещений от бота.
|
||||
|
||||
Attributes:
|
||||
chat_id (int): Идентификатор чата.
|
||||
user (User): Пользователь (бот).
|
||||
user_locale (Optional[str]): Локаль пользователя.
|
||||
"""
|
||||
|
||||
chat_id: int
|
||||
user: User
|
||||
user_locale: Optional[str] = None
|
||||
|
||||
if TYPE_CHECKING:
|
||||
bot: Optional[Bot]
|
||||
|
||||
def get_ids(self):
|
||||
return (self.chat_id, self.user.user_id)
|
Loading…
x
Reference in New Issue
Block a user