新增小红书、XMPP、元宝、Zalo 四个渠道扩展。 小红书渠道扩展主要模块:config, gateway, webhook, outbound, streaming, pairing, security, dedupe, media, status, window XMPP 渠道扩展主要模块:plugin, config, gateway, outbound, streaming, pairing, security, dedupe, accounts, commands, muc, rate_limiter, stanza_utils, status, monitor 元宝渠道扩展主要模块:plugin, client, config_schema, gateway, outbound(chunk/queue/transport), inbound(dispatcher), streaming, pairing, security, accounts, actions, commands, codec(biz/conn), session, shared, utils Zalo 渠道扩展主要模块:api, config, gateway, webhook, outbound, pairing, security, session, polling, monitor, status
27 lines
942 B
Python
27 lines
942 B
Python
import logging
|
|
|
|
logger = logging.getLogger("yuxi.channel.xmpp.muc")
|
|
|
|
|
|
async def join_muc_with_fallback(bot, room: str, nicks: list[str], password: str | None = None) -> tuple[str, str]:
|
|
last_error = None
|
|
for nick in nicks:
|
|
try:
|
|
muc = bot.plugin["xep_0045"]
|
|
await muc.join_muc_wait(room, nick, password=password, maxstanzas=0)
|
|
return room, nick
|
|
except Exception as e:
|
|
last_error = e
|
|
logger.debug("MUC join failed with nick '%s' for %s: %s", nick, room, e)
|
|
continue
|
|
raise RuntimeError(f"无法加入 MUC 房间 {room}: {last_error}")
|
|
|
|
|
|
async def leave_muc(bot, room: str, nick: str) -> None:
|
|
try:
|
|
muc = bot.plugin["xep_0045"]
|
|
await muc.leave_muc_wait(room, nick, msg="Bot offline")
|
|
logger.info("Left MUC: %s (%s)", room, nick)
|
|
except Exception as e:
|
|
logger.warning("Failed to leave MUC %s: %s", room, e)
|