mirror of
https://github.com/BOSWatch/BW3-Core.git
synced 2025-12-06 07:12:04 +01:00
changes to telegram
This commit is contained in:
parent
4aea7b5d78
commit
c7f99bcfcb
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Reference in a new issue