Skip to content

Commit

Permalink
clearing detailes; delete unused imports
Browse files Browse the repository at this point in the history
  • Loading branch information
RoLO0u committed Oct 30, 2022
1 parent 4e31a3c commit ccfd4dd
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion bot/handlers/commands.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from aiogram import Router
from aiogram.types import Message, FSInputFile
from aiogram.types import Message
from aiogram.filters import Command


Expand Down
3 changes: 1 addition & 2 deletions bot/handlers/inline.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from typing import Dict, Any
from typing import Any
from time import monotonic

from aiogram import Router, F

from aiogram.types import CallbackQuery
from aiogram.filters.callback_data import CallbackData
from aiogram.fsm.storage.memory import MemoryStorage

router = Router()
Expand Down
3 changes: 0 additions & 3 deletions bot/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,11 @@ async def __call__(self, handler: Callable[[Message, Dict[str, Any]], Awaitable[

if not user_id in my_storage:
my_storage[user_id] = [time, False]
# print(1)
elif my_storage[user_id][1]:
# print(2)
return
elif my_storage[user_id][0] + .5 > time: # new message sent less than in 0.5 sec
my_storage[user_id] = [time, True]
await event.answer("You Sooooo Fast!!! Now You Should Make Captcha Below To Continue", reply_markup=captcha_inline())
# print(3)
return
else:
my_storage[user_id][0] = time
Expand Down
10 changes: 5 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import logging
import os

from aiogram import Dispatcher, types, Bot, F
from aiogram import Dispatcher, Bot, F
from aiogram.fsm.storage.memory import MemoryStorage

from bot import middleware
Expand Down Expand Up @@ -32,10 +32,10 @@ async def run():
# Middleware here
dp.message.middleware(middleware.AntiFloodMiddleware())

# try:
await dp.start_polling(bot, allowed_updates=dp.resolve_used_update_types())
# finally:
# await bot.session.close()
try:
await dp.start_polling(bot, allowed_updates=dp.resolve_used_update_types())
finally:
await bot.session.close()

if __name__ == "__main__":
asyncio.run(run())

0 comments on commit ccfd4dd

Please sign in to comment.