Created
July 29, 2019 18:54
-
-
Save Birdi7/4b061f64e62205f63c61472d9171bf1d to your computer and use it in GitHub Desktop.
A listing to show the bug in aiogram with wrapped functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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