Allow multiple chat IDs
This commit is contained in:
parent
9165cb9551
commit
d8c93fbc49
1 changed files with 8 additions and 4 deletions
12
bot.py
12
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:
|
||||
|
|
Loading…
Reference in a new issue