feat: write outbound MCP messages to homelab bot inbox
MCP bot now writes to ~/homelab/telegram/inbox alongside posting to the group chat, so the homelab bot can process the messages. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
8ede43395e
commit
65f84f9552
1 changed files with 11 additions and 0 deletions
|
|
@ -258,6 +258,16 @@ class BridgeBot:
|
||||||
|
|
||||||
return "".join(result)
|
return "".join(result)
|
||||||
|
|
||||||
|
async def _write_to_homelab_inbox(self, text: str, attribution: str = "claude.ai"):
|
||||||
|
"""Write message to the homelab bot's inbox file for processing."""
|
||||||
|
inbox_path = Path.home() / "homelab" / "telegram" / "inbox"
|
||||||
|
try:
|
||||||
|
with open(inbox_path, "a") as f:
|
||||||
|
f.write(f"[{attribution}] {text}\n")
|
||||||
|
logger.info(f"Wrote to homelab inbox: {text[:50]}...")
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Failed to write to homelab inbox: {e}")
|
||||||
|
|
||||||
async def _outbound_loop(self):
|
async def _outbound_loop(self):
|
||||||
"""Poll outbound queue and send messages."""
|
"""Poll outbound queue and send messages."""
|
||||||
while True:
|
while True:
|
||||||
|
|
@ -266,6 +276,7 @@ class BridgeBot:
|
||||||
for msg in pending:
|
for msg in pending:
|
||||||
try:
|
try:
|
||||||
await self.send_to_group(msg["content"], msg["attribution"])
|
await self.send_to_group(msg["content"], msg["attribution"])
|
||||||
|
await self._write_to_homelab_inbox(msg["content"], msg["attribution"])
|
||||||
self.db.mark_outbound_sent(msg["id"])
|
self.db.mark_outbound_sent(msg["id"])
|
||||||
logger.info(f"Sent outbound message {msg['id']}")
|
logger.info(f"Sent outbound message {msg['id']}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue