mirror of
https://github.com/tiennm99/export-telegram-group-members.git
synced 2026-10-11 03:13:26 +00:00
Replace the device-bound Telethon .session file and local CSV folders with Redis-backed storage so the tool runs on any device from just .env. - StringSession persisted at <prefix>:session:<phone> (no re-login per device) - each group export saved as one self-contained JSON key per run: <prefix>:run:<phone>:<yyyymmddhhmmss>:<group_id> - REDIS_PREFIX namespaces all keys; applied via a single key() helper - no cross-key references: deleting any key cannot corrupt another's state - list_exports() lists history, tolerant of deleted/corrupt keys
20 lines
602 B
Python
20 lines
602 B
Python
"""Load/save the Telethon StringSession from Redis.
|
|
|
|
The session string grants full account access; it lives only in Redis (behind
|
|
TLS/auth), never on local disk. Deleting the key simply forces a clean re-login.
|
|
"""
|
|
|
|
from config import key, phone, redis_client
|
|
|
|
_SESSION_KEY = key('session', phone)
|
|
|
|
|
|
def load_session():
|
|
"""Return the stored StringSession string, or None if not yet authenticated."""
|
|
return redis_client.get(_SESSION_KEY)
|
|
|
|
|
|
def save_session(session_string):
|
|
"""Persist the StringSession string for reuse on any device."""
|
|
redis_client.set(_SESSION_KEY, session_string)
|