Skip to content

Commit

Permalink
Refactor middleware for private chat handling only.
Browse files Browse the repository at this point in the history
  • Loading branch information
nessshon committed May 19, 2024
1 parent abf7f8a commit 25fc555
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions aiogram_tonconnect/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from aiogram import BaseMiddleware
from aiogram.fsm.context import FSMContext
from aiogram.types import TelegramObject, User
from aiogram.types import TelegramObject, User, Chat

from .manager import ATCManager
from .tonconnect import AiogramTonConnect
Expand Down Expand Up @@ -71,8 +71,9 @@ async def __call__(
:return: :class:`Any`
"""
user: User = data.get("event_from_user")
chat: Chat = data.get("event_chat")

if user and not user.is_bot:
if chat and chat.type == "private" and user and not user.is_bot:
state: FSMContext = data.get("state")
state_data = await state.get_data()

Expand Down

0 comments on commit 25fc555

Please sign in to comment.