mirror of
https://github.com/BOSWatch/BW3-Core.git
synced 2025-12-06 07:12:04 +01:00
add source for telegram.py
This commit is contained in:
parent
c2aab648c8
commit
ca81d86a1e
BIN
plugin/.telegram.py.swp
Normal file
BIN
plugin/.telegram.py.swp
Normal file
Binary file not shown.
|
|
@ -1,3 +1,4 @@
|
|||
??? from here until ???END lines may have been inserted/deleted
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""!
|
||||
|
|
@ -64,3 +65,21 @@ class BoswatchPlugin(PluginBase):
|
|||
logging.exception("Error while sending Telegram Message")
|
||||
except Exception as e:
|
||||
logging.exception("Unknown Error while sending Telegram Message: " + str(type(e).__name__) + ": " + str(e))
|
||||
|
||||
def zvei(self, bwPacket):
|
||||
"""!Called on ZVEI alarm
|
||||
@param bwPacket: bwPacket instance"""
|
||||
msg = self.parseWildcards(self.config.get("message"))
|
||||
for chatId in self.config.get("chatIds", default=[]):
|
||||
try:
|
||||
# Send Message via Telegram
|
||||
logging.info("Sending message to " + chatId)
|
||||
self.bot.send_message(chat_id=chatId, text=msg)
|
||||
except Unauthorized:
|
||||
logging.exception("Error while sending Telegram Message, please Check your api-key")
|
||||
except (TimedOut, NetworkError):
|
||||
logging.exception("Error while sending Telegram Message, please Check your connectivity")
|
||||
except (BadRequest, TelegramError):
|
||||
logging.exception("Error while sending Telegram Message")
|
||||
except Exception as e:
|
||||
logging.exception("Unknown Error while sending Telegram Message: " + str(type(e).__name__) + ": " + str(e))
|
||||
|
|
|
|||
Loading…
Reference in a new issue