新增小红书、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
44 lines
1.4 KiB
Python
44 lines
1.4 KiB
Python
import logging
|
|
|
|
logger = logging.getLogger("yuxi.channel.xmpp.commands")
|
|
|
|
|
|
def register_xmpp_commands(bot, account):
|
|
if "xep_0050" not in bot.plugin:
|
|
return
|
|
|
|
commands = bot.plugin["xep_0050"]
|
|
|
|
async def handle_help(iq, session):
|
|
form = bot.plugin["xep_0004"].make_form(ftype="result")
|
|
form.add_field(
|
|
var="info",
|
|
ftype="text-single",
|
|
label="Bot Info",
|
|
value=f"ForcePilot XMPP Bot ({account.bare_jid})",
|
|
)
|
|
form.add_field(
|
|
var="rooms",
|
|
ftype="text-multi",
|
|
label="Active Rooms",
|
|
value="\n".join(account.rooms) or "(none)",
|
|
)
|
|
session["notes"] = [("info", "ForcePilot Bot — /help /status 可用")]
|
|
return session
|
|
|
|
async def handle_status(iq, session):
|
|
form = bot.plugin["xep_0004"].make_form(ftype="result")
|
|
form.add_field(var="connected", ftype="boolean", label="Connected", value=True)
|
|
form.add_field(
|
|
var="jid",
|
|
ftype="text-single",
|
|
label="JID",
|
|
value=str(bot.boundjid),
|
|
)
|
|
session["notes"] = [("info", "Bot 运行正常")]
|
|
return session
|
|
|
|
commands.add_command(node="help", name="Help", handler=handle_help)
|
|
commands.add_command(node="status", name="Status", handler=handle_status)
|
|
logger.info("XMPP Ad-Hoc commands registered: help, status")
|