Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import prawcore.exceptions as e
- while True :
- try :
- #Patch Notes
- """
- SUEB can now process some WPB commands.
- """
- #Version number, as a string
- version = "9.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
- import os.path
- 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
- #Signature
- signature = "^NateNate60's ^ShutUpExeBot ^Version ^" + version + " ^Reply ^!info ^for ^information"
- #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, signature) :
- if tick == 1 :
- coNumber = 1000
- #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" in comment.body.lower() and "exe" in comment.body.lower() or "u 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() and "bot" 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) + ". \n \n You have been awarded 1 Willard Point!" + "\n \n"
- + signature)
- 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) + ". \n \n You have been awarded 1 Willard Point!" + "\n \n"
- + signature)
- 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) + ".\n \n You have been awarded 1 Willard Point!" + "\n \n"
- + signature)
- 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" +
- signature)
- 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" +
- signature)
- 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. \n \n You have been awarded 1 Willard Point!" + "\n \n" +
- signature)
- 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" +
- signature)
- 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" +
- signature)
- 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' +
- signature)
- 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 ("no u! If I got something wrong, please contact NateNate60." + "\n \n" +
- signature)
- 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" +
- signature)
- 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" +
- signature)
- 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 makes you happy, here's a Willard Point!" + "\n \n" +
- signature)
- 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" +
- signature)
- comments_replied_to.append (message.id)
- with open ('comments.txt', 'a') as f :
- f.write (message.id + "\n")
- config.banned.append (message.author)
- elif "!info" in message.body.lower() :
- print (time + ":", 'Found valid string for INFO at ' + message.id)
- if reply == True :
- message.reply ("HELLO and welcome to the info page of the NUMBER ONE DANKEST BOT IN ALL OF SALEM!!" + "\n \n" +
- 'What I do is I count the number of executioners that people have SILENCED MERCILESSLY with "shut up exe"! I also count the number of jesters in Salem!' +
- "DARE TO FIND ALL MY TRIGGER PHRASES! Or cheat and look on NateNate60's Pastebin." +
- " \n \n You may have also noticed that I occasionally award Willard Points to good humans. These don't stick around" +
- " unless you have a Willard Points account. To create an account to save up WP, message Willard_Points_Bot with `!newaccount`." +
- signature + " ^Tarnation ^a ^John ^Willard ^for ^a ^free ^Willard ^Point")
- comments_replied_to.append (message.id)
- with open ('comments.txt', 'a') as f :
- f.write (message.id + "\n")
- elif "!isup" in message.body.lower() or '!stat' in message.body.lower() :
- message.reply ("Online." + signature)
- comments_replied_to.append (message.id)
- with open ('comments.txt', 'a') as f :
- f.write (message.id + "\n")
- elif "!newacc" in message.body.lower() or "!createac" in message.body.lower() :
- if reply == True :
- if not os.path.isfile(str(message.author) + ".txt") :
- message.reply ("An account has been created. However, the 10 WP signing bonus has been forfeited because people do this so much on the wrong bot that the code has had to have been updated" +
- " resulting in dozens of lines of new code being written by NateNate60, and code-writing takes time, so the signing bonus has been consumed as a fee. Sorry. Maybe if you ask him nicely " +
- "you'll get it back." + signature)
- print (time, str(message.author), "created a WPB account at " + message.id)
- with open ('log.txt', 'a') as log :
- log.write ("\n" + time + ": " + str(message.author) + " opened an account through SUEB.")
- with open (str(message.author) + ".txt", 'w') as n :
- n.write ("0")
- else :
- with open (str(message.author) + ".txt", "r") as n :
- bal = n.read()
- message.reply ("You already have an account. You have " + bal + " Willard Points." + signature)
- comments_replied_to.append (message.id)
- with open ('comments.txt', 'a') as f :
- f.write (message.id + '\n')
- elif "!bal" in message.body :
- payload = message.body.split(" ")
- if len(payload) != 2 :
- message.reply ('Invalid syntax for balance checking. Try `!balance [username]`.' + signature)
- else :
- if os.path.isfile(payload[1] + ".txt") :
- with open (payload[1] + ".txt") as acc :
- bal = acc.read()
- message.reply("That account currently has " + bal + " Willard Points." + signature)
- print (time, str(message.author), "checked their WPB balance at " + message.id)
- else :
- message.reply ("That account does not exist. Use !newaccount" + signature)
- comments_replied_to.append (message.id)
- with open ('comments.txt', 'a') as f :
- f.write (message.id + "\n")
- 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 ("\n" + str(user) + "+" + str(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 PST" , 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, signature)
- 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.")
- except e.RequestException :
- print ("The bot crashed with RequestExcpetion. Restarting...")
- continue
- except PermissionError :
- print ("The bot crashed with PermissionError. Restarting...")
- continue
- except e.ServerError :
- print ('The bot crashed because it recieved a 503 HTTP error. Restarting...')
- continue
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement