Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Patch Notes
- """
- Work has begun on integrating Shut Up Exe Bot with WillardPoints Bot.
- The goal is to make it so that SUEB can issue Willard Points to redditors
- that trigger execount and jestcount.
- """
- #Version number, as a string
- version = "8.0"
- print ("Starting Shut_Up_Exe_Bot version " + version)
- #Import the required modules
- print ("Importing modules...", end='')
- import praw
- import config
- import time as t
- import datetime
- 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 5!
- # For the fastest, set this to 15, which is the minimum. I recommend 50 if
- # your hardware allows.
- coNumber = 30
- # Set the tick
- tick = 0
- #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, tick, time) :
- if tick == 1 :
- coNumber = coNumber * 20
- #Obtaining comments
- for comment in r.subreddit('townofsalemgame+over50kmp+townofcirclejerk').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() or "!trigger 1" in comment.body.lower() and comment.author == "NateNate60" :
- if "execute" not in comment.body.lower() and "jail" not in comment.body.lower() and "don" not in comment.body.lower():
- print (time + ":", "Found valid string for EXE at " + comment.id)
- if reply == True :
- execount += 1
- comment.reply ("Executioners silenced: " + str(execount) + ". You have been awarded 1 Willard Point!" + "\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))
- award (1, comment.author)
- elif "silence" in comment.body.lower() and "exe" in comment.body.lower() :
- print (time + ":", "Found valid string for EXE at " + comment.id)
- if reply == True :
- execount += 1
- comment.reply ("Executioners silenced: " + str(execount) + ". You have been awarded 1 Willard Point!" + "\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))
- award (1, comment.author)
- elif "shut up jest" in comment.body.lower() or "u jest" in comment.body.lower() or "re jest" in comment.body.lower() :
- print (time + ":", "Found valid string for JEST at " + comment.id)
- if reply == True :
- jestcount += 1
- comment.reply ("Jesters discovered: " + str(jestcount) + ". You have been awarded 1 Willard Point!" + "\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))
- award (1, comment.author)
- elif "has revealed themse" in comment.body.lower() and "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 (time + ":", "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))
- award (1, comment.author)
- elif "is maf" in comment.body.lower() or "yo" in comment.body.lower() and "maf" in comment.body.lower() or "sus" in comment.body.lower() :
- if "m sheriff" in comment.body.lower() :
- print (time + ":", "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 (time + ":", "Found valid string for WILLARD at " + comment.id)
- if reply == True :
- comment.reply ("Yes, tarnation John Willard indeed. You have been awarded 1 Willard Point!" + "\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))
- award (1, comment.author)
- 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 (time + ":", "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 (time + ":", "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))
- elif "more weight" in comment.body.lower() or 'more wieght' in comment.body.lower() :
- print (time + ":", "Found valid string for WEIGHT at " + comment.id)
- if reply == True :
- comment.reply (">more weight" + "\n \n" + "Those are some famous words, spoken by Giles Corey during the IRL witch trials, " +
- 'after he refused to plead. He was then promptly dispatched with the "Splat!" death animation. Have a Willard Point!' + '\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))
- award (1, comment.author)
- if tick%5 == 0 :
- for message in r.inbox.unread(limit = coNumber/5) :
- if message.id not in comments_replied_to :
- if "bad" in message.body.lower() and "bot" in message.body.lower() :
- print (time + ":", "Found valid string for BADBOT at " + message.id)
- if reply == True :
- message.reply ("Bah, tarnation you anyways. If I got something wrong, please contact NateNate60." + "\n \n" +
- "^ShutUpExeBot ^Version " + "^" + version)
- 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 (time + ":", "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() :
- print (time + ":", 'Found valid string for SILENCEBOT 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 "good" in message.body.lower() and "bot" in message.body.lower() :
- print (time + ":", "Found valid string for PRAISE at", message.id)
- if reply == True :
- message.reply ("Thank you for the praise, human. If it make you happy, here's a Willard Point!" + "\n \n" +
- "^ShutUpExeBot ^Version " + "^" + version)
- comments_replied_to.append (message.id)
- with open ('comments.txt', 'a') as f :
- f.write (message.id + "\n")
- award (1, message.author)
- elif "!blacklist" in message.body.lower() :
- print (time + ":", 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)
- elif "!sleep" in message.body.lower() :
- pass
- t.sleep (5)
- return comments_replied_to, execount, jestcount, vigcount
- #Define function AWARD, which awards Willard Points.
- def award (award, user) :
- with open ("transactions.txt", 'a') as trans :
- trans.write (user + "+" + award)
- #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')
- #Get time
- print ("Getting time...", end='')
- st = t.time()
- st = datetime.datetime.fromtimestamp(st).strftime('%Y-%m-%d %H:%M:%S')
- time = st
- print ('done.')
- print ("Right now, it's UTC" , time)
- #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 :
- st = t.time()
- st = datetime.datetime.fromtimestamp(st).strftime('%Y-%m-%d %H:%M:%S')
- time = st
- execount = get_execount()
- jestcount = get_jestcount()
- vigcount = get_vigcount()
- run_bot(r, comments_replied_to, execount, jestcount, vigcount, coNumber, printCRT, version, tick, time)
- tick += 1
- if tick == 1 :
- print (time + ":", "The bot has successfully completed one cycle.")
- elif tick == 5 :
- print (time + ":", 'The bot has successfully completed 5 cycles.')
- elif tick%10 == 0 and tick < 100 :
- print (time + ":", 'The bot has successfully completed', tick, "cycles.")
- elif tick%100 == 0 and tick < 500 :
- print (time + ":", 'The bot has successfully completed', tick, "cycles.")
- elif tick%500 == 0 and tick < 3000:
- print (time + ":", 'The bot has successfully completed', tick, "cycles.")
- elif tick%1000 == 0 :
- print (time + ":", 'The bot has successfully completed', tick, "cycles.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement