Bot become a Community Guard & Post send manager

added: dictionary support for censore
message/user management with dict triggers
This commit is contained in:
2025-08-22 21:44:14 +09:00
parent efdafb0efa
commit c16ec54891
27 changed files with 1746 additions and 184 deletions

25
app/infra/redis_client.py Normal file
View File

@@ -0,0 +1,25 @@
import os
try:
from redis import asyncio as aioredis
except Exception:
aioredis = None
_redis = None
async def get_redis():
"""
Возвращает подключение к Redis (async) или None, если REDIS_URL не задан
или библиотека не установлена.
"""
global _redis
if _redis is not None:
return _redis
url = os.getenv("REDIS_URL", "").strip()
if not url or aioredis is None:
return None
_redis = aioredis.from_url(url, encoding="utf-8", decode_responses=True)
try:
await _redis.ping()
except Exception:
_redis = None
return _redis