def _invite_comment(comment, referralname): if comment.author.name == configAxis.username: return print("Inviting comment") if referralname is None: comment.reply(util.get_invite_image()+util.get_footer()) else: comment.reply(util.get_invite_image()+util.get_footer()+" ^("+configAxis.invitation+util.escape_reddit_chars(referralname)+")") log_body = "Replied to user "+comment.author.name logger.info(log_body)
def sign_them_up(message): if not db.has_faith(message.author.name): print("Found a sucker!: " + message.author.name + " " + message.id) db.member_signup(message.author.name) message.reply( "WELCOME TO THE BLESSED AXIS ORDER! You are member #" + db.get_member_number(message.author.name) + "! Go forth and earn Axis Points by praying or inviting others to join (check the Help Wiki linked below)! May you receive the blessings of the Holy Water Goddess Aqua!" + util.get_footer()) logger.info(message.author.name + " has joined Axis Order!") print(message.author.name + " has joined Axis Order!") if isinstance(message, Comment) and not isinstance( message.parent(), Submission): comment = r.comment(message.id) if configAxis.invitation in comment.parent( ).body and comment.parent().author.name == r.user.me().name: wordlist = comment.parent().body.split() username = util.unescape_reddit_chars(wordlist[-1][:-1]) db.add_points(username, 5) logger.info(username + " has been credited +5 points for the referral") print(username + " has been credited +5 points for the referral") else: num_members_string = db.get_number_of_members() message.reply( "Hello fellow faithful, it seems like you already belong to the wonderful Axis Order! You are member #" + db.get_member_number(message.author.name) + " of " + db.get_number_of_members() + " " + util.add_s(int(num_members_string), "member") + "!")
def parse_parameters(comment): valid_input = False #助けてよ~!! if "!help" in comment.body.lower(): valid_input = True comment.reply(util.get_help()) #Someone wants to join via botcall LOL! GET SCAMMED BRUH if "!join" in comment.body.lower(): valid_input = True sign_them_up(comment) #=========MEMBERS ONLY FUNCTION START============ #invites the author of the parent comment to this current comment if that person has not yet joined the order if "!invite" in comment.body.lower(): valid_input = True #Faith check if not db.has_faith(comment.author.name): comment.reply(configAxis.not_a_member) return #members only function members.member_invite(comment) #アクシズ教、教義! if any(x in comment.body.lower() for x in configAxis.teaching_hit_words): valid_input = True #Faith check if not db.has_faith(comment.author.name): comment.reply(configAxis.not_a_member) return #members only function members.member_pray(comment) #replies stats of author of comment if "!stats" in comment.body.lower(): valid_input = True #Faith check if not db.has_faith(comment.author.name): comment.reply(configAxis.not_a_member) return #members only function members.member_stats(comment) if "!meme" in comment.body.lower(): valid_input = True #Faith check if not db.has_faith(comment.author.name): comment.reply(configAxis.not_a_member) return #members only function members.member_meme(comment, r) #=========MEMBERS ONLY FUNCTION END============ if not valid_input: comment.reply( "Hi, it looks like you've called me without providing a valid parameter! Have a look at the Help Wiki (linked below) for the latest available commands!" + util.get_footer())
def bot_invite(comment): if comment.author == r.user.me(): return print("Inviting comment") comment.reply(util.get_invite_image() + util.get_footer()) log_body = "Replied to user " + comment.author.name logger.info(log_body)
def member_pray(comment): print("submission id: "+comment.submission.fullname) points = 0 if comment.submission.fullname == configAxis.pray_submission_id: points += 1 if "all" in comment.body.lower() or "-a" in comment.body.lower(): all_message = "" if db.can_receive_points_from_prayer(comment.author.name): points += 2 db.add_points(comment.author.name, points) all_message += "You've gained "+str(points)+" Axis Points for reciting all the teachings maniacally in one breath!: \n\n" db.update_pray_time(comment.author.name) comment.reply(all_message+util.get_all_teachings()+util.get_footer()) else: single_message = "" if db.can_receive_points_from_prayer(comment.author.name): points += 1 db.add_points(comment.author.name, points) single_message += "You've gained "+str(points)+" Axis "+util.add_s(points, "Point")+" for reciting the following teachings!: \n\n" db.update_pray_time(comment.author.name) comment.reply(single_message+util.get_single_teaching(comment)+util.get_footer())
def member_meme(comment, r): current_points = int(db.get_referrals(comment.author.name)) if current_points < configAxis.points_to_meme: comment.reply("Sorry, but you must be of rank \""+ranker.get_rank(configAxis.points_to_meme)+"\" ("+str(configAxis.points_to_meme)+" Axis Points) or higher to request a Meme Strike!"+util.get_footer()) return text = comment.body.lower() if "!memestrike " in comment.body.lower(): #targetted memestriking on a specific post at the url the user provides if current_points < configAxis.points_to_memestrike: comment.reply("Sorry, but you must be of rank \""+ranker.get_rank(configAxis.points_to_memestrke)+"\" ("+str(configAxis.points_to_memestrike)+" Axis Points) or higher to request a Meme Strike!"+util.get_footer()) return #assumed parameter format: !axisbot !memestrike URL memetext #split with space, get index = 2 as url, process space_split_text = text.split() split_index = 1 min_arg_count = 2 if "!axis" in text: split_index += 1 min_arg_count = 3 if len(space_split_text) < min_arg_count: comment.reply("It seems that something went wrong! Please make sure you supply a proper full reddit URL when meme striking!"+util.get_footer()) return url = space_split_text[split_index] if "www.reddit" not in url: comment.reply("It seems that something went wrong! Please make sure you supply a proper full reddit URL when meme striking!"+util.get_footer()) return #hacky id extraction. comment_id = url[len(url)-8:len(url)-1] target_post = None try: target_post = r.comment(comment_id) target_post.parent() except: try: target_post = r.submission(url = url) except: comment.reply("It seems that something went wrong! Please make sure you supply a proper full reddit URL when meme striking!"+util.get_footer()) return index = text.find(url+" ") #blacklist check if any(x == target_post.subreddit.display_name for x in configAxis.blacklisted_subreddits): comment.reply("Sorry, you can not order a meme strike into a proactively blacklisted subreddit!") return try: if index == -1 or text[index+len(url+" "):] == "": target_post.reply(axisMeme.get_meme_hyperlink(" ")+util.get_footer_meme()+" ^(This is a Meme Strike ordered by member /u/"+comment.author.name+")") return target_post.reply(axisMeme.get_meme_hyperlink(text[index+len(url+" "):])+util.get_footer_meme()) #+" ^(This is a Meme Strike ordered by member /u/"+comment.author.name+")" except: comment.reply("It seems that something went wrong! This bot may have been banned from the subreddit you're trying to meme strike!"+util.get_footer()) else: #normal memeing that replies to user via botcalls or username mention index = text.find("!meme ") if index == -1 or text[index+6:] == "": comment.reply(axisMeme.get_meme_hyperlink(" ")+util.get_footer()) return comment.reply(axisMeme.get_meme_hyperlink(text[index+6:])+util.get_footer())
def member_invite(comment): target_comment = comment.parent() logger.info(comment.author.name + " initiated an invite on "+target_comment.author.name) print(comment.author.name + " initiated an invite on "+target_comment.author.name) if db.has_faith(target_comment.author.name): comment.reply("Great news! "+target_comment.author.name+" is already a member of the holy Axis Order!" +util.get_footer()) else: if type(target_comment) is praw.models.Submission: print("Submission invite") _invite_submission(target_comment, comment) else: print("Comment invite") _invite_comment(target_comment, comment.author.name)
def _invite_submission(submission, inviting_comment): print("Inviting submission") submission.reply(util.get_invite_image()+util.get_footer()+" ^("+configAxis.invitation+util.escape_reddit_chars(inviting_comment.author.name)+")") logger.info("Replied to submission at "+submission.shortlink) print("Replied to submission at "+submission.shortlink)