ForcePilot/backend/package/yuxi/channel/extensions/zulip/pairing.py
Kris d5e36d33b7 feat(channel): 添加 Zalo OA、Zoom Chat 和 Zulip 渠道扩展
新增 Zalo OA、Zoom Chat、Zulip 三个渠道扩展。

Zalo OA 渠道扩展主要模块:sidecar_client, config, gateway, outbound, streaming, pairing, security, auth, dedupe, directory, monitor, status, session, reactions, tools

Zoom Chat 渠道扩展主要模块:config, gateway, webhook, outbound, streaming, pairing, security, crypto, dedupe, actions, media, mentions, monitor, status, session, reactions, threading

Zulip 渠道扩展主要模块:client, config, gateway, outbound, streaming, pairing, security, monitor, status
2026-05-21 12:06:26 +08:00

39 lines
961 B
Python

from __future__ import annotations
import logging
import random
logger = logging.getLogger(__name__)
class ZulipPairing:
def __init__(self):
self._codes: dict[str, tuple[str, float]] = {}
async def generate_code(self, peer_id: str) -> str:
import time as _time
code = f"{random.randint(100000, 999999)}"
self._codes[peer_id] = (code, _time.time())
return code
async def verify_code(self, peer_id: str, code: str) -> bool:
import time as _time
if peer_id not in self._codes:
return False
stored_code, timestamp = self._codes[peer_id]
if _time.time() - timestamp > 600:
self._codes.pop(peer_id, None)
return False
if stored_code != code.strip():
return False
self._codes.pop(peer_id, None)
return True
def normalize_allow_entry(self, entry: str) -> str:
return entry.strip().lower()