Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print ("Starting Shut_Up_Exe_Bot version 6")
- #Patch Notes
- """
- The bot now responds to "silence, executioner".
- The bot will agree with the user if the users says "tarnation
- John Willard".
- Made they code neater wherever possible.
- """
- #Import the required modules
- import praw
- import config
- import time
- import os
- #Testing mode. True for testing mode off and False for on
- reply = True
- #Choose whether the bot should print the list of comments replied to after every
- # reply. False for don't print, True for print.
- printCRT = False
- #Maximum number of comments to check in one cycle
- coNumber = 50
- #Define function LOGIN
- def login() :
- print ("Authenticating.")
- r = praw.Reddit(username = config.username,
- password = config.password,
- client_id = config.client_id,
- client_secret = config.client_secret,
- user_agent = config.user_agent)
- print ("Authentication successful")
- return r
- #___________________________________________
- #Define function RUN_BOT
- def run_bot(r, comments_replied_to, execount, jestcount, coNumber, printCRT) :
- print ("Obtaining comments")
- #Obtaining comments
- for comment in r.subreddit('townofsalemgame').comments(limit = coNumber) :
- if comment.author not in config.banned :
- if comment.id not in comments_replied_to and comment.author != r.user.me() :
- if "shut up exe" in comment.body.lower() or "u exe" in comment.body.lower() or "re exe" in comment.body.lower() or "silence exe" in comment.body.lower() :
- print ("Found valid string for EXE at " + comment.id)
- if reply == True :
- execount += 1
- comment.reply ("Executioners silenced: " + str(execount) + "." + "\n \n" +
- "Beep Boop. I am a bot. Please contact NateNate60 for any suggestions, questions,~~and complaints~~"
- + "\n \n ^ShutUpExeBot ^Version ^6")
- print ("The current execount is: ", str(execount) + ". Reply successful.")
- comments_replied_to.append (comment.id)
- with open ('comments.txt', 'a') as f :
- f.write (comment.id + "\n")
- open('execount.txt', 'w').close()
- with open ('execount.txt', 'a') as exe :
- exe.write (str(execount))
- if printCRT == True :
- print ("Comments that the bot has replied to: " + str(comments_replied_to))
- elif "silence" in comment.body.lower() and "execut" in comment.body.lower() :
- print ("Found valid string for EXE at " + comment.id)
- if reply == True :
- execount += 1
- comment.reply ("Executioners silenced: " + str(execount) + "." + "\n \n" +
- "Beep Boop. I am a bot. Please contact NateNate60 for any suggestions, questions,~~and complaints~~"
- "\n \n ^ShutUpExeBot ^Version ^6")
- print ("The current execount is: ", str(execount) + ". Reply successful.")
- comments_replied_to.append (comment.id)
- with open ('comments.txt', 'a') as f :
- f.write (comment.id + "\n")
- open('execount.txt', 'w').close()
- with open ('execount.txt', 'a') as exe :
- exe.write (str(execount))
- if printCRT == True :
- print ("Comments that the bot has replied to: " + str(comments_replied_to))
- elif "shut up jest" in comment.body.lower() or "u jest" in comment.body.lower() or "re jest" in comment.body.lower() :
- print ("Found valid string for JEST at " + comment.id)
- if reply == True :
- jestcount += 1
- comment.reply ("Jesters discovered: " + str(jestcount) + "." + "\n \n" +
- "Beep Boop. I am a bot. Please contact NateNate60 for any suggestions, questions, ~~and complaints.~~"
- + "\n \n ^ShutUpExeBot ^Version ^6")
- print ("The current jestcount is: ", str(jestcount) + ". Reply successful.")
- comments_replied_to.append (comment.id)
- with open ('comments.txt', 'a') as f :
- f.write (comment.id + "\n")
- open('jestcount.txt', 'w').close()
- with open ('jestcount.txt', 'a') as jest :
- jest.write (str(jestcount))
- if printCRT == True :
- print ("Comments that the bot has replied to: " + str(comments_replied_to))
- elif "has revealed themselves as the mayor" in comment.body.lower() or "has revealed himself as the mayor" in comment.body.lower() or "i'm mayor" in comment.body.lower() :
- print ("Found valid string for MAYOR at " + comment.id)
- if reply == True :
- comment.reply ("You were shot by a Vigilante!" + "\n \n" +
- "Beep Boop. I am a bot. Please contact NateNate60 for any suggestions, questions, ~~and complaints~~" +
- "\n \n ^ShutUpExeBot ^Version ^6")
- comments_replied_to.append (comment.id)
- with open ('comments.txt', 'a') as f :
- f.write (comment.id + "\n")
- if printCRT == True :
- print ("Comments that the bot has replied to: " + str(comments_replied_to))
- elif "is maf" in comment.body.lower() :
- if "m sheriff" in comment.body.lower() :
- print ("Found valid string for SHERIFF at " + comment.id)
- if reply == True :
- comment.reply ("Please kindly close thine talking-cavity, person who kills convicted invididuals on behalf of the Government." + "\n \n" +
- "Beep Boop. I am a bot. Please contact NateNate60 for any suggestions, questions, ~~and complaints~~" +
- "\n \n ^ShutUpExeBot ^Version ^6")
- comments_replied_to.append (comment.id)
- with open ('comments.txt', 'a') as f :
- f.write (comment.id + "\n")
- if printCRT == True :
- print ("Comments that the bot has replied to: " + str(comments_replied_to))
- elif "tarnation john wil" in comments.body.lower() :
- print ("Found valid string for WILLARD at " + comment.id)
- if reply == True :
- comment.reply ("Yes, tarnation John Willard indeed." + "\n \n"
- "Beep Boop. I am a bot. Please contact NateNate60 for any suggestions, questions, ~~and complaints~~" +
- "\n \n ^ShutUpExeBot ^Version ^6")
- comments_replied_to.append (comment.id)
- with open ('comments.txt', 'a') as f :
- f.write (comment.id + "\n")
- if printCRT == True :
- print ("Comments that the bot has replied to: " + str(comments_replied_to))
- print ("The bot is resting for 5 seconds")
- time.sleep (5)
- return execount, comments_replied_to
- #Define function GET_COMMENT_LIST
- def get_comment_list() :
- with open ("comments.txt", "r") as f :
- comments_replied_to = f.read()
- comments_replied_to = comments_replied_to.split("\n")
- return comments_replied_to
- def get_execount() :
- with open ("execount.txt", "r") as exe :
- execount = exe.read ()
- execount = int(execount)
- return execount
- def get_jestcount() :
- with open ("jestcount.txt", "r") as jest :
- jestcount = jest.read()
- jestcount = int(jestcount)
- return jestcount
- #Log in
- r = login()
- #Set empty list for comments_replied_to
- comments_replied_to = get_comment_list()
- print ("Blacklisted users: ", config.banned)
- print ("Loaded.")
- #Run forever
- while True :
- execount = get_execount()
- jestcount = get_jestcount()
- run_bot(r, comments_replied_to, execount, jestcount, coNumber, printCRT)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement