Skip to content

Instantly share code, notes, and snippets.

@Birdi7
Created July 29, 2019 18:54
Show Gist options
  • Save Birdi7/4b061f64e62205f63c61472d9171bf1d to your computer and use it in GitHub Desktop.
Save Birdi7/4b061f64e62205f63c61472d9171bf1d to your computer and use it in GitHub Desktop.
A listing to show the bug in aiogram with wrapped functions
import functools
import logging
from typing import Coroutine
from aiogram import Bot, Dispatcher, executor, types
from aiogram.contrib.fsm_storage.memory import MemoryStorage
API_TOKEN = 'BOT_TOKEN_HERE'
# Configure logging
logging.basicConfig(level=logging.INFO)
# Initialize bot and dispatcher
bot = Bot(token=API_TOKEN)
dp = Dispatcher(bot, storage=MemoryStorage())
def my_decorator(func: Coroutine):
@functools.wraps(func)
async def wrapped(*args, **kwargs):
print(f"in wrapped")
return (await func(*args, **kwargs))
return wrapped
@dp.message_handler(commands=['start', 'help'])
@my_decorator
async def send_welcome(message: types.Message):
await message.reply("Hi!\nI'm EchoBot!\nPowered by aiogram.")
if __name__ == '__main__':
executor.start_polling(dp, skip_updates=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment