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 spread_the_word(): try: for subreddit in configAxis.subreddits: for comment in r.subreddit(subreddit).comments( limit=configAxis.comment_limit): has_comment = db.has_comment(comment.id, subreddit) if check_word(comment.body.lower( )) and not has_comment and comment.author != r.user.me( ) and not db.has_faith(comment.author.name) and not any( x == subreddit for x in configAxis.manual_subreddits): db.record_comment(comment.id, subreddit) logger.info("Comment found: " + comment.id) #bot default invite bot_invite(comment) if any(x in comment.body.lower() for x in configAxis.bot_call_words ) and not has_comment and comment.author != r.user.me(): db.record_comment(comment.id, subreddit) parse_parameters(comment) except praw.exceptions.APIException as ex: print("praw.exceptions.APIException, sleeping for 60s") print(str(ex)) logger.error(str(ex)) time.sleep(60) pass
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 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 check_inbox(): for message in r.inbox.unread(): message.mark_read() #If it's a comment instance, find originating subreddit #If subreddit is in configAxis.subreddits, record id to that subreddit's DB #Else do nothing if isinstance(message, Comment): comment = r.comment(message.id) subreddit_name = comment.subreddit.display_name print("inbox:" + subreddit_name) if any(x == subreddit_name for x in configAxis.subreddits): print("recording") db.record_comment(comment.id, subreddit_name) if configAxisFlags.inbox_forwarding: forward_inbox(message) if "!join" in message.body.lower(): sign_them_up(message) continue if "!stats" in message.body.lower(): #Faith check if not db.has_faith(message.author.name): message.reply(configAxis.not_a_member) continue #members only function members.member_stats(message) continue if "!help" in message.body.lower(): message.reply(util.get_help()) continue if "/u/axis_order" in message.body.lower(): if any(x == message.subreddit.display_name for x in configAxis.blacklisted_subreddits): print("blacklisted subreddit: " + message.subreddit.display_name) r.redditor(message.author.name).message( "Subreddit is blacklisted!", "Sorry, you've attempted to summon me into /r/" + message.subreddit.display_name + ", which is blacklisted!") continue parse_parameters(message) continue #アクシズ教、教義! 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) if "!meme" in message.body.lower(): #Faith check if not db.has_faith(message.author.name): message.reply(configAxis.not_a_member) continue #members only function members.member_meme(message, r) continue #admin only function (all-member broadcasting) if "!broadcast" in message.body.lower( ) and message.author.name == configAxis.forward_username: bot_broadcast(message)