welcomecenterbot/store.py
2024-09-26 16:02:55 +03:00

23 lines
524 B
Python

from bot.config import REDIS_URL
import redis.asyncio as r
# Connect to Redis
redis = r.Redis.from_url(REDIS_URL)
async def get_all_removed(uid):
pattern = f"removed:{uid}:*"
# Create a dictionary to hold the keys and values
texts = []
# Use scan_iter to find all keys matching the pattern
scanned = await redis.scan_iter(pattern)
for key in scanned:
# Fetch the value for each key
value = await redis.get(key)
if value:
texts.append(value)
return texts