Skip to content

Instantly share code, notes, and snippets.

@ncwhale
Last active October 19, 2020 10:44
Show Gist options
  • Save ncwhale/a08883b7992995556cd6cd66b69d76c9 to your computer and use it in GitHub Desktop.
Save ncwhale/a08883b7992995556cd6cd66b69d76c9 to your computer and use it in GitHub Desktop.
@dp.message_handler(chat_ctx_filter, commands={'count'})
async def count_handler(event: types.Message, chat_ctx: Chat):
'+1s for every call'
with db.transaction_manager as trans:
trans.note(u"Count")
chat_count = chat_ctx.addCount()
delay_task = asyncio.create_task(asyncio.sleep(5))
await event.chat.do('typing')
await event.delete()
await delay_task
if chat_count == chat_ctx.count:
await event.answer(f"Count: {chat_count}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment