MCPcopy Create free account
hub / github.com/Roy3838/Observer / check_usage

Function check_usage

api/quota_manager.py:150–171  ·  view source on GitHub ↗
(
    user_id: str, service: str,
    is_pro: bool = False, is_max: bool = False, is_plus: bool = False
)

Source from the content-addressed store, hash-verified

148 return int(val) >= RATE_LIMIT_PER_MINUTE if val else False
149
150async def check_usage(
151 user_id: str, service: str,
152 is_pro: bool = False, is_max: bool = False, is_plus: bool = False
153) -> bool:
154 if await is_rate_limited(user_id):
155 asyncio.create_task(_send_abuse_alert_async(user_id, service))
156 return True
157
158 r = await get_redis()
159 val = await r.get(f"quota:{user_id}:{service}")
160 current_usage = int(val) if val else 0
161
162 if is_max:
163 limit = MAX_QUOTA_LIMITS[service]
164 elif is_pro:
165 limit = PRO_QUOTA_LIMITS[service]
166 elif is_plus:
167 limit = PLUS_QUOTA_LIMITS[service]
168 else:
169 limit = QUOTA_LIMITS[service]
170
171 return current_usage >= limit
172
173async def get_all_usage_data() -> dict:
174 r = await get_redis()

Callers 7

send_smsFunction · 0.90
send_whatsappFunction · 0.90
make_voice_callFunction · 0.90
send_emailFunction · 0.90
send_pushoverFunction · 0.90
send_telegramFunction · 0.90

Calls 3

is_rate_limitedFunction · 0.85
_send_abuse_alert_asyncFunction · 0.85
get_redisFunction · 0.85

Tested by

no test coverage detected