def send_reply(self, submission, refs): # TODO: Re-enable transcripts when the json has been fixed builder = ReferenceBuilder(include_transcript=False) reply_msg = builder.build_all(submission, refs, self.xkcd_fetcher, self.datastore, None) # Do not send if there's no body if builder.get_body_length() == 0: return True # Do not send if we are doing a dry run if self.dry_run: return True # Reply to the user reply_obj = utils.send_reply(submission, reply_msg) if reply_obj is None: return False # Edit and fix [delete] signature link builder.build_signature(reply_obj) reply_msg = builder.cat() if not utils.edit_reply(reply_obj, reply_msg): return False return True
def process_comment_reply(self, mail): body_lower = mail.body.lower() # Check for joke replies if body_lower.find('thank you') != -1 or body_lower.find('thanks') != -1: reply_msg = "[](/sbstalkthread)My pleasure" elif body_lower.find('i love you') != -1: reply_msg = "[](/sbstalkthread)Love ya too~" elif body_lower == 'k': reply_msg = "[](/o_o)K" elif body_lower == ")": reply_msg = "(" else: return True # Do not reply if the user is ignored if mail.author and mail.author.name.lower() in self.datastore.get_ignores(): logger.info('Skipping mail {id}. Reason: Author on ignore list.'.format(id=mail.id)) return True # Check it was originally a reply to a transcript if not self._is_transcript_reply(self.r, mail, self.auth['username']): logger.info('Skipping to post joke reply to {id}. Reason: Not a reply to a transcript'.format(id=mail.id)) return True # Do not send if we are doing a dry run if self.dry_run: return True # Reply to the user if utils.send_reply(mail, reply_msg): return True return False
def send_reply(self, comment, refs): builder = ReferenceBuilder() reply_msg = builder.build_all(comment, refs, self.xkcd_fetcher, self.datastore, None) # Do not send if there's no body if builder.get_body_length() == 0: return True # Do not send if we are doing a dry run if self.dry_run: return True # Reply to the user reply_obj = utils.send_reply(comment, reply_msg) if reply_obj is None: return False # Edit and fix [delete] signature link builder.build_signature(reply_obj) reply_msg = builder.cat() if not utils.edit_reply(reply_obj, reply_msg): return False return True
def _do(self, mail): reply_msg = '[](/sbstalkthread)This bot has been decommissioned.\n\n' \ 'It has migrated over to [lunarmist.net](http://lunarmist.net/emotes/), ' \ 'and has been enhanced with graphs and better comment coverage. Check it out!' # Reply to the user and mark it as read if utils.send_reply(mail, reply_msg): mail.mark_as_read() return True else: return False
def process_ignore(self, mail): # Add to ignore list if not self.dry_run: self.datastore.add_ignore(mail.author.name.lower()) # Reply to the user reply_msg = "You have been added to the ignore list. If this bot continues to respond, PM /u/LunarMist2." # Do not send if we are doing a dry run if self.dry_run: return True if utils.send_reply(mail, reply_msg): return True return False
def process_comment_reply(self, mail): body_lower = mail.body.lower() # Check for joke replies if body_lower.find('thank you') != -1 or body_lower.find( 'thanks') != -1: reply_msg = random.choice(SB_SECRETS) + "My pleasure" elif body_lower.find('i love you') != -1: reply_msg = random.choice(SB_SECRETS) + "Love ya too~" elif body_lower == 'k': reply_msg = "[](/o_o)K" elif body_lower == ")": reply_msg = "(" else: return True # Do not reply if the user is ignored if mail.author and mail.author.name.lower( ) in self.datastore.get_ignores(): logger.info( 'Skipping mail {id}. Reason: Author on ignore list.'.format( id=mail.id)) return True # Check it was originally a reply to a transcript if not self._is_transcript_reply(self.r, mail, self.auth['username']): logger.info( 'Skipping to post joke reply to {id}. Reason: Not a reply to a transcript' .format(id=mail.id)) return True # Do not send if we are doing a dry run if self.dry_run: return True # Reply to the user if utils.send_reply(mail, reply_msg): return True return False