Fixed cooldown
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
from functools import wraps
|
from functools import wraps
|
||||||
import datetime
|
import datetime
|
||||||
from bot.common import bot
|
|
||||||
from bot.db import db, DBTables
|
from bot.db import db, DBTables
|
||||||
import asyncio
|
import asyncio
|
||||||
from aiogram import types
|
from aiogram import types
|
||||||
@@ -33,10 +32,13 @@ def throttle(cooldown: int = 5, by_id: bool = True, admin_ids: list = None):
|
|||||||
|
|
||||||
if last_time <= delta:
|
if last_time <= delta:
|
||||||
try:
|
try:
|
||||||
db[DBTables.cooldown][func.__name__][user_id] = now
|
f_name_dict = db[DBTables.cooldown][func.__name__]
|
||||||
|
f_name_dict[user_id] = now
|
||||||
|
db[DBTables.cooldown][func.__name__] = f_name_dict
|
||||||
except KeyError:
|
except KeyError:
|
||||||
db[DBTables.cooldown][func.__name__] = dict()
|
f_name_dict = dict()
|
||||||
db[DBTables.cooldown][func.__name__][user_id] = now
|
f_name_dict[user_id] = now
|
||||||
|
db[DBTables.cooldown][func.__name__] = f_name_dict
|
||||||
try:
|
try:
|
||||||
return asyncio.create_task(func(*args, **kwargs))
|
return asyncio.create_task(func(*args, **kwargs))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
Reference in New Issue
Block a user