mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-27 16:04:21 +00:00
chore: 修改包名
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from . import algo
|
||||
from .algos import fixedwin
|
||||
from ...core import app
|
||||
|
||||
|
||||
class RateLimiter:
|
||||
"""限速器
|
||||
"""
|
||||
|
||||
ap: app.Application
|
||||
|
||||
algo: algo.ReteLimitAlgo
|
||||
|
||||
def __init__(self, ap: app.Application):
|
||||
self.ap = ap
|
||||
|
||||
async def initialize(self):
|
||||
self.algo = fixedwin.FixedWindowAlgo(self.ap)
|
||||
await self.algo.initialize()
|
||||
|
||||
async def require(self, launcher_type: str, launcher_id: int) -> bool:
|
||||
"""请求访问
|
||||
"""
|
||||
return await self.algo.require_access(launcher_type, launcher_id)
|
||||
|
||||
async def release(self, launcher_type: str, launcher_id: int):
|
||||
"""释放访问
|
||||
"""
|
||||
return await self.algo.release_access(launcher_type, launcher_id)
|
||||
Reference in New Issue
Block a user