Exemple #1
0
    def _notify_failed_load(self, subreddit: Subreddit, error: Text,
                            revision_id: Text) -> bool:
        if self.notification_svc:
            self.notification_svc.send_notification(
                f'Failed to load config for r/{subreddit.display_name}\n{error}',
                subject=f'Subreddit Config Load Failed')
        body = f'I\'m unable to load your new config for r/{subreddit.display_name}. Your recent changes are invalid. \n\n' \
                f'Error: {error} \n\n' \
                'Please validate your changes and try again'

        try:
            subreddit.message('Repost Sleuth Failed To Load Config', body)
            return True
        except Exception as e:
            log.exception('Failed to send PM to %s', subreddit.display_name)
            return False
Exemple #2
0
 def _notify_successful_load(self, subreddit: Subreddit) -> bool:
     log.info('Sending notification for successful config update to %s',
              subreddit.display_name)
     if self.notification_svc:
         self.notification_svc.send_notification(
             f'New config loaded for r/{subreddit.display_name}',
             subject=f'Subreddit Config Load Success')
     try:
         subreddit.message(
             'Repost Sleuth Has Loaded Your New Config!',
             'I saw your config changes and have loaded them! \n\n I\'ll start using them now.'
         )
         return True
     except Exception as e:
         log.exception('Failed to send PM to %s', subreddit.display_name)
         return False
Exemple #3
0
 def _notify_config_created(self, subreddit: Subreddit) -> bool:
     """
     Send a private message to a sub's mod mail letting them know their config has been created
     :rtype: bool
     :param subreddit: Subreddit to notify
     :return: bool for successful or failed message
     """
     log.info('Sending config created notification to %s',
              subreddit.display_name)
     try:
         subreddit.message(
             'Repost Sleuth Has Loaded Your New Config!',
             'I saw your config changes and have loaded them! \n\n I\'ll start using them now.'
         )
         return True
     except Exception as e:
         log.exception('Failed to send config created notification')
         return False
Exemple #4
0
 def _notify_new_options(self, subreddit: Subreddit,
                         config_keys: List[Text]) -> bool:
     log.info(
         'Sending notification for new config keys being added to %s.  %s',
         config_keys, subreddit.display_name)
     if self.notification_svc:
         self.notification_svc.send_notification(
             f'Added now config keys to r/{subreddit.display_name}\n{config_keys}',
             subject='New Config Options Notification Sent')
     try:
         subreddit.message(
             'New Repost Sleuth Options Available!',
             'Your Repost Sleuth config was missing some newly available options.\n\n '
             f'I\'ve added the following options to your config: {config_keys}\n\n'
             'You can read more about them here: https://www.reddit.com/r/RepostSleuthBot/wiki/add-you-sub/configure-repost-sleuth#wiki_config_value_explanation'
         )
         return True
     except Exception as e:
         log.exception('Failed to send PM to %s', subreddit.display_name)
         return False