From c7f99bcfcbe96d6cdc69eda3b72db6c8f8ec232e Mon Sep 17 00:00:00 2001 From: Jan Speller Date: Sat, 22 Feb 2020 19:11:21 +0100 Subject: [PATCH] changes to telegram --- plugin/telegram.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/plugin/telegram.py b/plugin/telegram.py index f32a0cf..3050afc 100644 --- a/plugin/telegram.py +++ b/plugin/telegram.py @@ -15,12 +15,11 @@ @description: Telegram Plugin """ import logging - from plugin.pluginBase import PluginBase # ###################### # # Custom plugin includes # -from telegram.error import (TelegramError, Unauthorized, BadRequest, TimedOut, ChatMigrated, NetworkError) +from telegram.error import (TelegramError, Unauthorized, BadRequest, TimedOut, NetworkError) import telegram # ###################### # @@ -44,15 +43,15 @@ class BoswatchPlugin(PluginBase): @param bwPacket: bwPacket instance""" msg = bwPacket.get("ric") + " (" + bwPacket.get("subric") + ")\n" + bwPacket.get("message") - if bwPacket.get("lat") is not None and bwPacket.get("lng") is not None: (lat, lng) = (bwPacket.get("lat"), bwPacket.get("lng")) + for chatId in self.config.get("chatIds", default=[]): try: # Send Message via Telegram - self.bot.send_message(chat_id=chatId, default=""), text=msg) - - # Send Location via Telegram if lat and lng exist in Package + self.bot.send_message(chat_id=chatId, text=msg) + + # Send Location via Telegram if lat and lng are defined if lat is not None and lng is not None: self.bot.sendLocation(chat_id=chatId, latitude=lat, longitude=lng) except Unauthorized: