Beispiel #1
0
 def __init__(self, config: Config):
     self.updater = None
     self.config = config
     self.enabled = config.telegram["enabled"]
     self.token = config.telegram["token"]
     self.body = config.telegram["body"]
     self.chat_ids = config.telegram["chat_ids"]
     self.mute = None
     if self.enabled and not self.token:
         raise TelegramConfigurationError("Missing Telegram token")
     if self.enabled:
         Item.check_mask(self.body)
         try:
             self.updater = Updater(token=self.token)
             self.updater.bot.get_me(timeout=60)
         except Exception as err:
             raise TelegramConfigurationError()
         if not self.chat_ids:
             self._get_chat_id()
         self.updater.dispatcher.add_handler(CommandHandler("help", self._help))
         self.updater.dispatcher.add_handler(CommandHandler("mute", self._mute))
         self.updater.dispatcher.add_handler(CommandHandler("unmute", self._unmute))
         self.updater.dispatcher.add_error_handler(self._error)
         self.updater.bot.set_my_commands([
             BotCommand('help', 'Displays available Commands'),
             BotCommand('mute', 'Deaktivates Telegram Notifications for x days'),
             BotCommand('unmute', 'Reactivates Telegram Notifications')
         ])
         self.updater.start_polling()
Beispiel #2
0
 def __init__(self, config: Config):
     self.server = None
     self.debug = 1 if config.debug else 0
     self.host = config.smtp["host"]
     self.port = config.smtp["port"]
     self.tls = config.smtp["tls"]
     self.username = config.smtp["username"]
     self.password = config.smtp["password"]
     self.sender = config.smtp["sender"]
     self.recipient = config.smtp["recipient"]
     self.enabled = config.smtp["enabled"]
     self.subject = config.smtp["subject"]
     self.body = config.smtp["body"]
     if self.enabled and (not self.host or not self.port):
         raise SMTPConfigurationError()
     if self.enabled:
         try:
             Item.check_mask(self.subject)
             Item.check_mask(self.body)
         except MaskConfigurationError as exc:
             raise SMTPConfigurationError(exc.message) from exc
         try:
             self._connect()
         except Exception as exc:
             raise SMTPConfigurationError() from exc
Beispiel #3
0
 def __init__(self, config: Config):
     self.enabled = config.webhook["enabled"]
     self.method = config.webhook["method"]
     self.url = config.webhook["url"]
     self.body = config.webhook["body"]
     self.type = config.webhook["type"]
     self.timeout = config.webhook["timeout"]
     if self.enabled and (not self.method or not self.url):
         raise WebHookConfigurationError()
     if self.enabled:
         try:
             Item.check_mask(self.body)
             Item.check_mask(self.url)
         except MaskConfigurationError as exc:
             raise WebHookConfigurationError(exc.message) from exc