def validate_comment(comment): # Decides whether or not to reply to a given comment. # - Must contain command # - Must not have already replied # - Must not reply to self if command in comment.body.lower(): queue = pickle.load(open(file, "rb")) if not queue: queue = Queue() data = pickle.load(open('RSRData.p', 'rb')) if queue.contains(comment.id) or comment.id in [x[0] for x in data]: return False if comment.author.name is "RedditSilverRobot": _register_comment(comment, "Cannot respond to self.") return False if get_receiver(comment) == '[deleted]': _register_comment(comment, "Parent comment was deleted!") return False comment.refresh() for child_comment in comment.replies: if child_comment.author.name == "RedditSilverRobot": _register_comment(comment, "Already replied to this comment. Will not do it again.") return False return True return False
def validate_comment(comment): # Decides whether or not to reply to a given comment. # - Must contain command # - Must not have already replied # - Must not reply to self if command in comment.body.lower(): queue = pickle.load(open(file, "rb")) if not queue: queue = Queue() data = pickle.load(open('RSRData.p', 'rb')) # Already in the queue, don't add. if queue.contains(comment.id) or comment.id in [x[0] for x in data]: return False # We wrote the comment, don't loop. if comment.author.name is "garlicbot": _register_comment(comment, "Cannot respond to self.") return False # Parent comment was deleted, don't respond. if get_receiver(comment) == '[deleted]': _register_comment(comment, "Parent comment was deleted!") return False # We've blacklisted this sub, don't respond. if comment.subreddit.display_name.lower() in banned_subs: _register_comment(comment, "Subreddit is blacklisted!") return False comment.refresh() for child_comment in comment.replies: if child_comment.author.name == "garlicbot": _register_comment( comment, "Already replied to this comment. Will not do it again.") return False return True return False
def validate_comment(message): # print(message) if 'reactions' in message: if msg_reaction in message['reactions']: # poster = message['reactions'][msg_reaction]['usernames'] # msg_text = message['msg'] # print("Message ID %s had the emoji %s on the following message: %s" % (message['_id'], message['reactions'], message['msg'])) queue = pickle.load(open(file, "rb")) if not queue: queue = Queue() data = pickle.load(open('RSRData.p', 'rb')) # Already in the queue, don't add. if queue.contains(message['_id']) or message['_id'] in [x[0] for x in data]: return False if message['reactions'][msg_reaction]['usernames'][0] == get_receiver(message): _register_comment(message, "Cannot respond to self.") return False return True return False return False
def valid_comment(comment): if(command in comment.body.lower()): #unpack data queue = pickle.load(open(queueFile, 'rb')) #create if empty if not queueFile: queue = Queue() data = pickle.load(open('FridgeData.p', 'rb')) #comment already in queue, or already processed if(queue.contains(comment.id) or comment.id in [entry[0] for entry in data]): return False comment.refresh() for child in comment.replies: if child.author.name == 'summon-bot': #this comment has already been replied to, but it passed our #queue for some reason. need to store return True return False