예제 #1
0
    def create(id: str, force_create: bool = False):
        ValueChecker.validate_id(id)

        notification = None if force_create else ConfigBuilder.get_notification(id)
        if None is notification:
            notification = TelegramNotification(id)
            ConfigBuilder.add_notification(id, notification)

        return notification
예제 #2
0
    def remove_notification(self: T, notification: Union[Notification, str]) -> T:

        if isinstance(notification, Notification):
            if notification in self.__notifications:
                self.__notifications.remove(notification)

        elif isinstance(notification, str):
            notification = ConfigBuilder.get_notification(notification)
            if notification in self.__notifications:
                self.__notifications.remove(notification)

        return self
예제 #3
0
 def add_notification(self: T, notification: Union[Notification, str]) -> T:
     if isinstance(notification, Notification):
         if notification not in self.__notifications:
             self.__notifications.append(notification)
     elif isinstance(notification, str):
         notification = ConfigBuilder.get_notification(notification)
         if None is notification:
             raise Exception('Notification does not exist yet!')
         if notification not in self.__notifications:
             self.__notifications.append(notification)
     else:
         raise Exception('Can only add Notification or id of Notification!')
     return self