def reply_to_nonexistent_target_subreddit_comment(source_comment, target_subreddit): source_subreddit = source_comment.subreddit.display_name NEW_SUBREDDIT_NAME_MINIMUM_LENGTH = 3 NEW_SUBREDDIT_NAME_MAXIMUM_LENGTH = 24 target_subreddit_length_valid = NEW_SUBREDDIT_NAME_MINIMUM_LENGTH <= len( target_subreddit) <= NEW_SUBREDDIT_NAME_MAXIMUM_LENGTH text = i18n.get_translated_string( 'NONEXISTENT_SUBREDDIT', source_subreddit, add_suffix=not target_subreddit_length_valid) text = text.format(target_subreddit=target_subreddit, ) if target_subreddit_length_valid: text2 = i18n.get_translated_string( 'PROMPT_NONEXISTENT_SUBREDDIT_CREATION', source_subreddit, add_suffix=True) text2 = text2.format(target_subreddit=target_subreddit, ) text = text + text2 comment2 = get_comment_with_different_praw_instance( source_comment, reddit_instantiator.SUB_DOESNT_EXIST_BOT_NAME) comment2.reply(text) return
def reply_to_source_equals_target_comment(source_comment): source_subreddit = source_comment.subreddit.display_name text = i18n.get_translated_string('THATS_WHERE_WE_ARE', source_subreddit) comment2 = get_comment_with_different_praw_instance( source_comment, reddit_instantiator.SAME_SUBREDDIT_BOT_NAME) comment2.reply(text) return
def reply_to_crosspost(source_comment, cross_post, target_subreddit): source_subreddit = source_comment.subreddit.display_name text = i18n.get_translated_string('REPLY_TO_CROSSPOST', source_subreddit) PHASE3_WAITING_PERIOD = os.environ.get('PHASE3_WAITING_PERIOD') timedelta_string = PHASE3_WAITING_PERIOD if source_comment.author: source_comment_author_name = source_comment.author.name else: source_comment_author_name = i18n.get_translated_string('THE_USER_WHO_COMMENTED', source_subreddit, add_suffix=False) text = text.format(source_subreddit=source_subreddit, target_subreddit=target_subreddit, source_comment_permalink=source_comment.permalink, source_comment_score=source_comment.score, source_submission_id=source_comment.submission.id, timedelta_string=timedelta_string, source_comment_author_name=source_comment_author_name,) return cross_post.reply(text)
def reply_to_same_content_post_comment(source_comment, target_subreddit, post_with_same_content): text = i18n.get_translated_string('FOUND_POST_WITH_SAME_CONTENT', target_subreddit) text = text.format( same_content_post_url=post_with_same_content.permalink, target_subreddit=target_subreddit, ) comment2 = get_comment_with_different_praw_instance( source_comment, reddit_instantiator.SAME_POST_BOT_NAME) comment2.reply(text) return
def respond_to_negative_sentiment(comment): text = i18n.get_translated_string( 'RESPOND_TO_NEGATIVE_SENTIMENT', target_subreddit=comment.subreddit.display_name) return comment.reply(text)