mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
fix: rename argument to chat_type
fix: rename example file name fix: str is container also lol. example fixed also
This commit is contained in:
parent
006a5ef987
commit
768491d976
2 changed files with 21 additions and 5 deletions
|
|
@ -6,6 +6,7 @@ It filters incoming object based on type of its chat type
|
|||
import logging
|
||||
|
||||
from aiogram import Bot, Dispatcher, executor, types
|
||||
from aiogram.dispatcher.handler import SkipHandler
|
||||
from aiogram.types import ChatType
|
||||
|
||||
API_TOKEN = 'BOT TOKEN HERE'
|
||||
|
|
@ -18,13 +19,24 @@ bot = Bot(token=API_TOKEN)
|
|||
dp = Dispatcher(bot)
|
||||
|
||||
|
||||
@dp.message_handler(chat_types=[ChatType.PRIVATE, ChatType.CHANNEL])
|
||||
@dp.message_handler(chat_type=[ChatType.PRIVATE, ChatType.CHANNEL])
|
||||
async def send_welcome(message: types.Message):
|
||||
"""
|
||||
This handler will be called when user sends `/start` or `/help` command
|
||||
"""
|
||||
await message.reply("Hi!\nI'm hearing your messages in private chats and channels")
|
||||
|
||||
# propagate message to the next handler
|
||||
raise SkipHandler
|
||||
|
||||
|
||||
@dp.message_handler(chat_type=ChatType.PRIVATE)
|
||||
async def send_welcome(message: types.Message):
|
||||
"""
|
||||
This handler will be called when user sends `/start` or `/help` command
|
||||
"""
|
||||
await message.reply("Hi!\nI'm hearing your messages only in private chats")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
executor.start_polling(dp, skip_updates=True)
|
||||
Loading…
Add table
Add a link
Reference in a new issue