refactor(xxm): consolidate 4 bot implementations into unified xmpp_agent_core.py
- Merge bot_base.py, gateway/scripts/xmpp_bot.py, bots/*, xmpp_bot_rest.py into single xmpp_agent_core.py with --agent flag (xxm|mohe|zhiwei|xiaoguo) - Add xxm_bot.py wrapper (encoding=utf-8 for Windows exec) - Fix slixmpp connect() API: use host=/port= keyword args (was tuple) - Clean up orphans: bots/, scripts/, hermes_state.py, xmpp_bot.py, xmpp_bot_rest.py - Add docs/CLEANUP_PLAN.md documenting the migration - Update README.md project structure - Also: fix WeChat agent path resolution (relative paths)
This commit is contained in:
+18
-19
@@ -26,8 +26,8 @@ if not _lock.ok:
|
||||
# ── Config ──
|
||||
JID = "xxm@yoin.fun"
|
||||
PASSWORD = "hermes123"
|
||||
SERVER = "xmpp.yoin.fun"
|
||||
PORT = 3021
|
||||
SERVER = "192.168.1.246"
|
||||
PORT = 5222
|
||||
ATTACH_SESSION = "ses_xxm_xmpp"
|
||||
MUC_ROOMS = [
|
||||
"coregroup@conference.yoin.fun", # core group chat
|
||||
@@ -696,23 +696,22 @@ if __name__ == "__main__":
|
||||
bot_nick = JID.split("@")[0]
|
||||
async def _join_silent():
|
||||
for room_jid in MUC_ROOMS:
|
||||
for attempt in range(3):
|
||||
try:
|
||||
# Use join_muc_wait to ensure room join completes
|
||||
await self.plugin['xep_0045'].join_muc_wait(room_jid, bot_nick, timeout=60)
|
||||
log(f"Joined {room_jid} (silent)")
|
||||
break
|
||||
except asyncio.TimeoutError:
|
||||
log(f"MUC join timeout ({attempt+1}/3) for {room_jid}")
|
||||
if attempt == 2:
|
||||
log(f"MUC setup failed for {room_jid} after 3 attempts")
|
||||
await asyncio.sleep(5)
|
||||
else:
|
||||
await asyncio.sleep(3)
|
||||
except Exception as e:
|
||||
log(f"MUC setup failed for {room_jid}: {e} (type={type(e).__name__})")
|
||||
await asyncio.sleep(5)
|
||||
break
|
||||
nick = bot_nick
|
||||
try:
|
||||
# Use join_muc (non-waiting) to register plugin state
|
||||
self.plugin['xep_0045'].join_muc(room_jid, nick)
|
||||
# Also send raw presence as backup
|
||||
presence = (
|
||||
f"<presence to='{room_jid}/{nick}'>"
|
||||
f"<x xmlns='http://jabber.org/protocol/muc'>"
|
||||
f"<history maxstanzas='0'/>"
|
||||
f"</x></presence>"
|
||||
)
|
||||
self.send_raw(presence)
|
||||
log(f"Joined {room_jid} (async)")
|
||||
except Exception as e:
|
||||
log(f"MUC join failed for {room_jid}: {type(e).__name__}: {e}")
|
||||
await asyncio.sleep(2)
|
||||
# After joining, query MAM for recent history
|
||||
await asyncio.sleep(3) # wait for MUC join to propagate
|
||||
await _fetch_mam_history()
|
||||
|
||||
Reference in New Issue
Block a user