mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Optional
This commit is contained in:
parent
b30e4e77ad
commit
ce7b5f70e0
2 changed files with 4 additions and 2 deletions
|
|
@ -9,6 +9,7 @@ class BaseHandlerMixin:
|
|||
"""
|
||||
Typed mixin. Do nothing.
|
||||
"""
|
||||
|
||||
event: TelegramObject
|
||||
data: Dict[str, Any]
|
||||
|
||||
|
|
@ -17,6 +18,7 @@ class _HandlerBotMixin(BaseHandlerMixin):
|
|||
"""
|
||||
Mixin adds bot attribute
|
||||
"""
|
||||
|
||||
@property
|
||||
def bot(self) -> Bot:
|
||||
if "bot" in self.data:
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
from abc import ABC
|
||||
from typing import Optional
|
||||
|
||||
from aiogram.api.types import Message, User, Chat
|
||||
from aiogram.api.types import Chat, Message, User
|
||||
from aiogram.dispatcher.filters import CommandObject
|
||||
from aiogram.dispatcher.handler.base import BaseHandler, BaseHandlerMixin
|
||||
|
||||
|
|
@ -10,7 +10,7 @@ class MessageHandler(BaseHandler, ABC):
|
|||
event: Message
|
||||
|
||||
@property
|
||||
def from_user(self) -> User:
|
||||
def from_user(self) -> Optional[User]:
|
||||
return self.event.from_user
|
||||
|
||||
@property
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue