handler(message: types.Message)

This commit is contained in:
Alex Root Junior 2017-06-03 10:53:13 +03:00
parent 03c7e4a6d8
commit 2192d4b7ea
3 changed files with 9 additions and 9 deletions

View file

@ -5,7 +5,7 @@ Babel is required.
import asyncio
import logging
from aiogram import Bot
from aiogram import Bot, types
from aiogram.dispatcher import Dispatcher
from aiogram.types import ParseMode
from aiogram.utils.markdown import *
@ -20,7 +20,7 @@ dp = Dispatcher(bot)
@dp.message_handler()
async def check_language(message):
async def check_language(message: types.Message):
locale = message.from_user.locale
await message.reply(text(

View file

@ -1,7 +1,7 @@
import asyncio
import logging
from aiogram import Bot
from aiogram import Bot, types
from aiogram.dispatcher import Dispatcher
API_TOKEN = 'BOT TOKEN HERE'
@ -14,19 +14,19 @@ dp = Dispatcher(bot)
@dp.message_handler(commands=['start', 'help'])
async def send_welcome(message):
async def send_welcome(message: types.Message):
await message.reply("Hi!\nI'm EchoBot!\nPowered by aiogram.")
@dp.message_handler(regexp='(^cat[s]?$|puss)')
async def cats(message):
async def cats(message: types.Message):
with open('data/cats.jpg', 'rb') as photo:
await bot.send_photo(message.chat.id, photo, caption='Cats is here 😺',
reply_to_message_id=message)
@dp.message_handler()
async def echo(message):
async def echo(message: types.Message):
await bot.send_message(message.chat.id, message.text)

View file

@ -15,13 +15,13 @@ dp = Dispatcher(bot)
@dp.message_handler(commands=['start'])
async def send_welcome(message):
async def send_welcome(message: types.Message):
await message.reply("Hi!\nI'm EchoBot!\nPowered by aiogram.")
@dp.message_handler(commands=['sticker'])
async def save_sticker(message):
async def handle_bad_message(msg):
async def save_sticker(message: types.Message):
async def handle_bad_message(msg: types.Message):
"""
Handler for unknown messages
"""