Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Patch Notes
- """
- The bot will check its inbox for people who
- say "bad bot" or "shut up bot" to it.
- If someone says something that sounds like a death
- announcement then the bot will accuse the user
- of being the killer.
- More trigger phrases.
- Shut Up Exe Bot is now being hosted on Python Anywhere
- for better reliability.
- Subpatch: Module "os" is no longer imported as I have realised
- it is never used. To increase efficiency the amount of
- inbox messages that the bot checks will be tied to one
- tenth of coNumber, minus two. That means that if the bot
- is set to check 50 comments as the coNumber, then the bot
- will check 3 messages.
- """
- #Version number, as a string
- version = "7.30"
- print ("Starting Shut_Up_Exe_Bot version " + version)
- #Import the required modules
- print ("Importing modules...", end='')
- import praw
- import config
- import time
- print ('done')
- print ("Loading features...", end='')
- #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. Must be a multiple of 10!
- # For the fastest, set this to 30, which is the minimum. I recommend 50 if
- # your hardware allows.
- coNumber = 50
- #Define function LOGIN
- def login() :
- print ("Connecting to Reddit")
- print ("Authenticating...", end='')
- 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 ('done')
- return r
- #___________________________________________
- #Define function RUN_BOT
- def run_bot(r, comments_replied_to, execount, jestcount, vigcount, coNumber, printCRT, version) :
- 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() :
- if "execute" not 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 " + "^" + version)
- 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 "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 " + "^" + version)
- 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 " + "^" + version)
- 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 :
- vigcount += 1
- comment.reply ("You were shot by a Vigilante! Mayors shot: " + str(vigcount) + ". \n \n" +
- "Beep Boop. I am a bot. Please contact NateNate60 for any suggestions, questions, ~~and complaints~~" +
- "\n \n ^ShutUpExeBot ^Version " + "^" + version)
- print ("The current vigcount is: ", str(vigcount) + ". Reply successful.")
- comments_replied_to.append (comment.id)
- with open ('comments.txt', 'a') as f :
- f.write (comment.id + "\n")
- open ('vigcount.txt', 'w').close()
- with open ('vigcount.txt', 'a') as vig :
- vig.write (str(jestcount))
- 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 " + "^" + version)
- 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 comment.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 " + "^" + version)
- 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 "died last night" in comment.body.lower() and "he was" in comment.body.lower() or "dead in their home last night" in comment.body.lower() and "he was" in comment.body.lower() :
- print ("Found valid string for DEATH at " + comment.id)
- if reply == True :
- comment.reply ("I bet you were the one that killed them." + "\n \n" +
- "Beep Boop. I am a bot. Please contact NateNate60 for any suggestions, questions, ~~and complaints~~" +
- "\n \n ^ShutUpExeBot ^Version " + "^" + version)
- 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 "incognito" in comment.body.lower() and "mode" in comment.body.lower() :
- print ("Found valid string for INCOGNITO at " + comment.id)
- if reply == True :
- comment.reply ("Incognito mode? Remember to close your malarky before making screenshots." + "\n \n" +
- "Beep Boop. I am a bot. Please contact NateNate60 for any suggestions, questions, ~~and complaints~~" +
- "\n \n ^ShutUpExeBot ^Version " + "^" + version)
- 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 ("Fetching inbox")
- for message in r.inbox.unread(limit = coNumber/10) :
- if message.id not in comments_replied_to :
- if "bad" in message.body.lower() and "bot" in message.body.lower() :
- if reply == True :
- message.reply ("Bah, tarnation you anyways. If I got something wrong, please contact NateNate60." + "\n \n" +
- "^ShutUpExeBot ^Version " + "^" + version)
- print ("Found valid string for BADBOT at " + message.id)
- comments_replied_to.append (message.id)
- with open ('comments.txt', 'a') as f :
- f.write (message.id + "\n")
- elif "shut up" in message.body.lower() and "bot" in message.body.lower() or "begone" in message.body.lower() and "bot" in message.body.lower :
- print ("Found valid string for SHUTUPBOT at " + message.id)
- if reply == True :
- message.reply ("Begone, executioner." + "\n \n" +
- "^ShutUpExeBot ^Version " + "^" + version)
- comments_replied_to.append (message.id)
- with open ('comments.txt', 'a') as f :
- f.write (message.id + "\n")
- elif "silence" in message.body.lower() and "bot" in message.body.lower() :
- if reply == True :
- message.reply ("Begone, executioner." + "\n \n" +
- "^ShutUpExeBot ^Version " + "^" + version)
- comments_replied_to.append (message.id)
- with open ('comments.txt', 'a') as f :
- f.write (message.id + "\n")
- elif "good" in message.body.lower() and "bot" in message.body.lower() :
- if reply == True :
- message.reply ("Thank you for the praise, human." + "\n \n" +
- "^ShutUpExeBot ^Version " + "^" + version)
- comments_replied_to.append (message.id)
- with open ('comments.txt', 'a') as f :
- f.write (message.id + "\n")
- elif "!blacklist" in message.body.lower() :
- print (str(message.author) + " requested to be blacklisted")
- if reply == True :
- message.reply ("You have been blacklisted. To be unblacklisted, please contact u/NateNate60." + "\n \n" +
- "^ShutUpExeBot ^Version " + "^" + version)
- comments_replied_to.append (message.id)
- with open ('comments.txt', 'a') as f :
- f.write (message.id + "\n")
- config.banned.append (message.author)
- 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
- def get_vigcount() :
- with open ('vigcount.txt', 'r') as vig :
- vigcount = vig.read()
- vigcount = int(vigcount)
- return vigcount
- print ('done')
- #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()
- vigcount = get_vigcount()
- run_bot(r, comments_replied_to, execount, jestcount, vigcount, coNumber, printCRT, version)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement