Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

fix(im): refresh telegram config before inbound handling

cyh2d64dd68f78f
diff --git a/modules/im/telegram.py b/modules/im/telegram.py
index 5ce357757..0e456132e 100644
--- a/modules/im/telegram.py
+++ b/modules/im/telegram.py
@@ -318,6 +318,9 @@ class TelegramBot(BaseIMClient):
await self._handle_message(message)
async def _handle_message(self, message: dict[str, Any]) -> None:
+ if self._controller and hasattr(self._controller, "_refresh_config_from_disk"):
+ self._controller._refresh_config_from_disk()
+
context = self._build_message_context(message)
if context is None:
return
diff --git a/tests/test_telegram_bot.py b/tests/test_telegram_bot.py
index 44ce5934c..2af6ff9ed 100644
--- a/tests/test_telegram_bot.py
+++ b/tests/test_telegram_bot.py
@@ -82,6 +82,33 @@ def test_group_message_uses_channel_require_mention_override() -> None:
assert bot.on_message_callback.await_args.args[1] == "hello team"
+def test_inbound_message_refreshes_config_before_reading_options() -> None:
+ bot = TelegramBot(TelegramConfig(bot_token="123456:test-token", require_mention=True))
+ bot._bot_user = {"id": 1, "username": "vibe_remote_bot"}
+ refresh_calls: list[bool] = []
+
+ def _refresh_config_from_disk() -> None:
+ refresh_calls.append(True)
+ bot.config.require_mention = False
+
+ bot.set_controller(SimpleNamespace(_refresh_config_from_disk=_refresh_config_from_disk))
+ bot.on_message_callback = AsyncMock()
+
+ asyncio.run(
+ bot._handle_message(
+ {
+ "message_id": 77,
+ "chat": {"id": -100123, "type": "group", "title": "Core Group"},
+ "from": {"id": 42},
+ "text": "hello team",
+ }
+ )
+ )
+
+ assert refresh_calls == [True]
+ bot.on_message_callback.assert_awaited_once()
+
+
def test_group_mention_only_falls_through_as_empty_message() -> None:
bot = TelegramBot(TelegramConfig(bot_token="123456:test-token", require_mention=True))
bot._bot_user = {"id": 1, "username": "vibe_remote_bot"}