MCPcopy Create free account
hub / github.com/dedsec1121fk/DedSec / user_cards

Function user_cards

Scripts/ButSystem.py:1254–1286  ·  view source on GitHub ↗

Return users with profile info, sorted online-first, plus counts.

(scope: str, exclude: Optional[str]=None)

Source from the content-addressed store, hash-verified

1252
1253def load_or_create_session_key() -> str:
1254 """load_or_create_session_key.
1255
1256Internal helper function.
1257
1258This docstring was added automatically to improve maintainability.
1259
1260Returns:
1261 Varies.
1262"""
1263 if os.path.exists(SESSION_KEY_PATH):
1264 raw = open(SESSION_KEY_PATH, "rb").read().strip().decode("utf-8", errors="ignore")
1265 return raw or base64.urlsafe_b64encode(os.urandom(32)).decode()
1266 key = base64.urlsafe_b64encode(os.urandom(32)).decode()
1267 with open(SESSION_KEY_PATH, "wb") as f:
1268 f.write(key.encode("utf-8"))
1269 try:
1270 os.chmod(SESSION_KEY_PATH, 0o600)
1271 except Exception:
1272 pass
1273 return key
1274
1275# ---------------------------
1276# Presence (online/offline) — heartbeat
1277# ---------------------------
1278
1279PRESENCE = {} # scope -> {username: last_seen_ts}
1280PRESENCE_LOCK = threading.Lock()
1281ONLINE_WINDOW = 45 # seconds
1282
1283def current_scope() -> str:
1284 """Return a presence scope based on the host used to reach the app.
1285
1286 This keeps 'online' accurate per generated link (local vs cloudflared vs tor),
1287 so users are only shown online if they're actually active on the same link.
1288 """
1289 try:

Callers 5

online_sorted_usersFunction · 0.70
chatsFunction · 0.70
api_usersFunction · 0.70
_story_user_cardsFunction · 0.70

Calls 3

db_connectFunction · 0.70
aesgcm_decrypt_textFunction · 0.70
is_onlineFunction · 0.70

Tested by

no test coverage detected