diff --git a/bot.py b/bot.py index 95dffa2..4d4ed26 100644 --- a/bot.py +++ b/bot.py @@ -27,7 +27,7 @@ class Bot: self.camera_ip = os.environ["CAMERA_IP"] self.camera_user = os.environ["CAMERA_USER"] self.camera_password = os.environ["CAMERA_PASSWORD"] - self.chat_id = int(os.environ["CHAT_ID"]) + self.chat_ids = list(map(int, os.environ["CHAT_ID"].split(","))) self.profile_name = os.environ.get("CAMERA_PROFILE_NAME", "board") self.openhab_url = os.environ["OPENHAB_URL"] self.openhab_token = os.environ["OPENHAB_TOKEN"] @@ -353,7 +353,11 @@ class Bot: try: return await asyncio.get_event_loop().run_in_executor( - self.executor, self._take_photo_blocking, adjust_perspective, timeout, chat_action_fn + self.executor, + self._take_photo_blocking, + adjust_perspective, + timeout, + chat_action_fn, ) finally: if item_state == "OFF": @@ -374,7 +378,7 @@ class Bot: try: upd = cast(Update, await queue.get()) print(upd) - if not upd.message or upd.message.chat_id != self.chat_id: + if not upd.message or upd.message.chat_id not in self.chat_ids: print("Ignoring message") continue # noinspection PyBroadException @@ -384,7 +388,7 @@ class Bot: traceback.print_exc() exc = traceback.format_exc() await self.bot.send_message( - chat_id=self.chat_id, + chat_id=upd.message.chat_id, text=f"Error: {exc}", ) except Exception: