SHARE
TWEET

H2Bot for Snoonet

fire219 Jul 9th, 2015 174 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. """
  2.  /$$   /$$  /$$$$$$  /$$$$$$$              /$$    
  3. | $$  | $$ /$$__  $$| $$__  $$            | $$    
  4. | $$  | $$|__/  \ $$| $$  \ $$  /$$$$$$  /$$$$$$  
  5. | $$$$$$$$  /$$$$$$/| $$$$$$$  /$$__  $$|_  $$_/  
  6. | $$__  $$ /$$____/ | $$__  $$| $$  \ $$  | $$    
  7. | $$  | $$| $$      | $$  \ $$| $$  | $$  | $$ /$$
  8. | $$  | $$| $$$$$$$$| $$$$$$$/|  $$$$$$/  |  $$$$/
  9. |__/  |__/|________/|_______/  \______/    \___/
  10.  
  11. H2Bot -- Multipurpose IRC Bot
  12. Built for #starmade on EsperNet
  13. Designed and built by fire219 (Matthew Petry)
  14.  
  15. Thanks to:
  16. Megacrafter127 -- suggestions and testing
  17. Titansmasher -- Code optimization, testing, suggestions
  18. Whoever wrote the tutorial at SHellium Wiki (tiny bits of that code can still be found in H2!)
  19. Everyone else who has suggested a feature or even provided motivation for development to continue
  20. """
  21.  
  22. # librarieslibrarieslibraries.
  23. import socket
  24. import time
  25. import random
  26. import os
  27. import thread
  28. import smtplib
  29. from email.mime.text import MIMEText
  30. from email.parser import Parser
  31.  
  32. # variables you can touch      
  33. server = "irc.snoonet.org" # IRC network
  34. channel = "#lifeisstrange" # Channel
  35. botnick = "H2Bot" # Bot's nick
  36. curses = ['fuck', 'shit', 'damn', 'dammit', 'cunt', 'tits', 'bitch', ' cock ', 'dick', 'jizz', 'nigger', 'queer', 'slut', 'twat', 'whore', 'pussy', ' hell ', 'spick', 'wetback', 'dike', 'bastard', 'towelhead', 'clit', 'douche', 'bugger', ' fuk ', '$hit', 'godverdomme', 'miljaardeju', 'kut', 'klote', 'verdomme', 'godver', 'nondedju', 'mieljaar', 'tering', 'sodemieter', 'merde', 'conneries', 'branleur', 'connard', 'schwanz', 'arsch', 'hurensohn', 'verdammt', 'puta', 'foda', ] #Profanity list for swear filter (used on first run)
  37. cursesns = ['fuck', 'shit', 'damn', 'dammit', 'cunt', 'tits', 'bitch', 'cock', 'dick', 'jizz', 'nigger', 'queer', 'slut', 'twat', 'whore', 'pussy', 'hell', 'spick', 'wetback', 'dike', 'bastard', 'towelhead', 'clit', 'douche', 'bugger', 'fuk', '$hit', 'godverdomme', 'miljaardeju', 'kut', 'klote', 'verdomme', 'godver', 'nondedju', 'mieljaar', 'tering', 'sodemieter', 'merde', 'conneries', 'branleur', 'connard', 'schwanz', 'arsch', 'hurensohn', 'verdammt', 'puta', 'foda',] #No-spaces profanity list for swear filter stage 2 (used on first run)  
  38. selfref = ['h2bot', 'himself', 'hisself', 'itself', 'dick', 'cock', 'hydrobot', 'hydrogenbot', ' its ', 'thyself'] #Self (and bad thing) references for fun commands
  39. log = 1 #create log file?
  40. filelocation = "C:\\Users\\Matthew\\Documents\\hydrobot\\" #where to create bot files
  41. password = "hydrobotmasterrace"
  42.  
  43. #--------------DO NOT TOUCH----------------------------
  44. swearfilter = 0
  45. timelimit = 0
  46. funcommands = 1
  47. ircmsg = ""
  48. tbanned = dict()
  49. tbanned2 = []
  50. mods = []
  51. L1off = []
  52. L2off = []
  53. L3off = []
  54. alloff= dict()
  55. date = time.strftime("%m_%d_%Y")
  56. swearcount = 0
  57. chanready = 0
  58. threadsrunning = 0
  59. #------------END NO TOUCHIE AREA-----------------------
  60.  
  61.  
  62. #log initialization
  63. if log == 1:
  64.  if os.path.isfile('C:\Users\Matthew\Documents\hydrobot\log '+ date) == True:
  65.    logw = open('C:\Users\Matthew\Documents\hydrobot\log '+ date, 'a')
  66.    logw.write('---LOG CONTINUED---\n')
  67.  
  68.  else:
  69.    logw = open('C:\Users\Matthew\Documents\hydrobot\log '+ date, 'w')
  70.    logw.write('---LOG STARTED---\n')
  71.  
  72.  
  73. #swear filter offenders file initialization
  74.  
  75. if os.path.isfile(filelocation+'swfile') == True:
  76.         pass
  77. else:
  78.  swf = open(filelocation+'swfile', 'w')
  79.  swf.write("{}")
  80.  swf = open(filelocation+'swfile', 'w')
  81.    
  82. #tempban file initialization  
  83. if os.path.isfile(filelocation+'tbanned') == True:
  84.  tbf = open(filelocation+'tbanned', 'r+')
  85.  tbanned = tbf.read()
  86.  tbanned = tbanned.strip("[]")
  87.  tbanned = eval(tbanned)
  88.  tbf.close()
  89. else:
  90.  tbf = open(filelocation+'tbanned', 'w')
  91.  tbf.write("{}")
  92.  tbf = open(filelocation+'tbanned', 'r+')
  93.  
  94. if os.path.isfile(filelocation+'tbanned2') == True:
  95.  tbf2 = open(filelocation+'tbanned2', 'r+')
  96.  tbanned2 = tbf2.read()
  97.  tbanned2 = tbanned2.strip("[]")
  98.  tbanned2 = tbanned2.replace("'", " ")
  99.  tbanned2 = tbanned2.strip(",")
  100.  tbanned2 = tbanned2.split()
  101.  tbf.close()
  102. else:
  103.  tbf2 = open(filelocation+'tbanned2', 'w')
  104.  tbf.write("[]")
  105.  tbfw = open(filelocation+'tbanned2', 'r+')
  106.  
  107.  
  108.  
  109. #--------------ABSOLUTELY NO TOUCHIE UNLESS YOU KNOW WHAT YOU'RE DOING-------------------
  110. ircsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  111. ircsock.connect((server, 6667))
  112. ircsock.send("USER "+ botnick +" "+ botnick +" "+ botnick +" :H2Bot -- the lightest and most volatile IRC Bot.\n") # user authentication
  113. time.sleep(2)
  114. ircsock.send("NICK "+ botnick +"\n")
  115. #--------------END NO TOUCHIE ZONE-------------------------------------------------------
  116.  
  117. def stringdetect(string): #basic string detection
  118.   if ircmsg.find(string) != -1:
  119.     return True
  120.   else:
  121.     return False
  122.  
  123. def ping(): # IRC PING responder
  124.  
  125.   ircsock.send("PONG :" + ircmsg.strip("PING :") + "/n")
  126.   print("PONG :" + ircmsg.strip("PING :"))
  127.   joinchan(channel)
  128.  
  129.  
  130. def joinchan(chan): # This function is used to join channels.
  131.   ircsock.send("JOIN "+ chan +"\n")
  132.  
  133. def hello(): # This function responds to a user that inputs "Hello <botnick>"
  134.   ircsock.send("PRIVMSG "+ channel +" :Hello!\n")
  135.  
  136. def rand(number): #random number gen
  137.  try:
  138.   rand = random.randint(1, int(number))
  139.   print(number)
  140.   ircsock.send("PRIVMSG "+ channel +" :Random Selection: " + str(rand) + "\n")
  141.  except:
  142.   pass
  143.   ircsock.send("PRIVMSG "+ channel +" :Bad information given. \n")
  144.  
  145. def rand2(randstring): #random character chooser
  146.  try:
  147.   rand = random.choice(randstring)
  148.   ircsock.send("PRIVMSG "+ channel +" :Random Selection: " + rand + "\n")
  149.  except:
  150.   pass
  151.   ircsock.send("PRIVMSG "+ channel +" :Bad information given. \n")
  152.  
  153. def intro(): #introduction to H2
  154.   ircsock.send("PRIVMSG "+ channel +" :Hello! I am HydroBot, also known as H2Bot. I am built/maintained by fire219 for the #starmade Espernet channel. Credit also goes to Titansmasher for major code optimizations, and Megacrafter127 for help testing. :)\n")
  155.  
  156. def locateuser(username): #broken piece of crap
  157.  
  158.   ircsock.send("PRIVMSG "+ channel +" :/names "+ channel + "\n")
  159.   ircmsg = ircsock.recv(2048) # receive data from the server
  160.   ircmsg = ircmsg.strip('\n\r') # removing any unnecessary linebreaks.
  161.   print(ircmsg) # Here we print what's coming from the server
  162.  # exitlocateloop = 0
  163.  # while exitlocateloop == -1:
  164.   # ircsock.send("PRIVMSG "+ channel +" :/names "+ channel + "\n")
  165.   # ircmsg = ircsock.recv(2048) # receive data from the server
  166.  #  ircmsg = ircmsg.strip('\n\r') # removing any unnecessary linebreaks.
  167.   while stringdetect("HB respond"):
  168.      ircmsg = ircsock.recv(2048) # receive data from the server
  169.      ircmsg = ircmsg.strip('\n\r') # removing any unnecessary linebreaks.
  170.      print(ircmsg) # Here we print what's coming from the server
  171.   names = ircmsg
  172.  #  exitlocateloop = ircmsg.find("Users")
  173.  
  174.   if username in names:
  175.      ircsock.send("PRIVMSG "+ channel +" :Match for '" + username + "' found!\n")
  176.      ircsock.send("PRIVMSG "+ channel +" :/whois "+ username + "\n")
  177.      ircmsg = ircsock.recv(2048) # receive data from the server
  178.      ircmsg = ircmsg.strip('\n\r') # removing any unnecessary linebreaks.
  179.      print(ircmsg) # Here we print what's coming from the server
  180.      nameip = ircmsg[len(channel)+1:]
  181.      nameip = nameip.split(' ')[0]
  182.      ircsock.send("PRIVMSG "+ channel +" :IP: " + nameip + "\n")
  183.   if username not in names:
  184.      ircsock.send("PRIVMSG "+ channel +" :No match for '" + username + "' could be found!\n")
  185.  
  186.  
  187. def slapuser(user): #slap user
  188.      ircsock.send("PRIVMSG "+ channel +" :\x01ACTION slaps " + user + " with a large robotic trout!\x01\n")
  189.      
  190. def ewuser(user): # ew user
  191.      ircsock.send("PRIVMSG "+ channel +" :Ew, "+ user +"! \n")
  192.  
  193. def suckuser(user): #vacuum cleaner, hehe
  194.      ircsock.send("PRIVMSG "+ channel +" :\x01ACTION sucks "+ user +" up with a vacuum cleaner! \x01\n")
  195.          
  196.          
  197. def opfindrun(): #find channel ops
  198.     opfind = ircmsg
  199.     opfindr = opfind.index("353 "+botnick)
  200.     opfind = opfind[opfindr:]
  201.     opfindr = opfind.index(channel)
  202.     opfind = opfind[opfindr:]
  203.     opfind2 = len(channel) + 1
  204.     opfind = opfind[opfind2:]
  205.     opfind = opfind[1:]
  206.     opfindr = opfind.index(":")
  207.     opfind = opfind[:opfindr]
  208.     opfind = opfind[:-2]
  209.     opfind = opfind.split(' ')
  210.     print(opfind)
  211.     opparse = 0
  212.     try:
  213.      for x in range(0, len(opfind)):
  214.         if opfind[opparse].find("@") == -1:
  215.             opfind.pop(opparse)
  216.             x = x + 1
  217.             oparse = opparse + 1
  218.         else:
  219.             tempop = opfind[opparse]            
  220.             tempop = tempop.replace("@", "")
  221.             mods.append(tempop)
  222.             opfind.pop(opparse)            
  223.             x = x + 1
  224.             oparse = opparse + 1
  225.     except IndexError:
  226.         print()
  227.     print(mods)
  228.     chanready = 1
  229.  
  230. def help(ircmsg): #basic command help
  231.     ircmsg = ircmsg[1:]
  232.     ircmsgr = ircmsg.index("!")
  233.     ircmsg = ircmsg[:ircmsgr]  
  234.     ircsock.send("PRIVMSG "+ ircmsg +" :H2Bot Help\n")    
  235.     ircsock.send("PRIVMSG "+ ircmsg +" :-----------\n")
  236.     ircsock.send("PRIVMSG "+ ircmsg +" :'Hello H2Bot' - H2Bot says hello back \n")
  237.     ircsock.send("PRIVMSG "+ ircmsg +" :HB intro - Introduction \n")
  238.     ircsock.send("PRIVMSG "+ ircmsg +" :HB locate <user> - says whether <user> is in chat or not (must be followed by 'HB respond' due to Python hating fire219)\n")
  239.     ircsock.send("PRIVMSG "+ ircmsg +" :HB randomize <text> - selects a random character out of <text> \n")
  240.     ircsock.send("PRIVMSG "+ ircmsg +" :HB randomnum <end number> - Selects a random number from 1 to <end number> \n")
  241.     ircsock.send("PRIVMSG "+ ircmsg +" :HB slap <user> - slaps user with a fish \n")
  242.     ircsock.send("PRIVMSG "+ ircmsg +" :HB ew <user> - shows your disgust for a user \n")
  243.     ircsock.send("PRIVMSG "+ ircmsg +" :HB suck <user> - not quite what you think \n")
  244.     ircsock.send("PRIVMSG "+ ircmsg +" :HB curtime - shows the current time in the timezone H2 is running from (usually Central) \n")
  245.     ircsock.send("PRIVMSG "+ ircmsg +" :HB easy - Be a smartass and tell them how easy something was. \n")             
  246.  
  247. def adminhelp(ircmsg): #admin command help
  248.     ircmsg = ircmsg[1:]
  249.     ircmsgr = ircmsg.index("!")
  250.     ircmsg = ircmsg[:ircmsgr]  
  251.     ircsock.send("PRIVMSG "+ ircmsg +" :H2Bot Admin Help\n")    
  252.     ircsock.send("PRIVMSG "+ ircmsg +" :-----------\n")
  253.     ircsock.send("PRIVMSG "+ ircmsg +" :'HB sw on/off' - swearfilter toggle \n")
  254.     ircsock.send("PRIVMSG "+ ircmsg +" :'HB fun on/off' - FUNction toggle \n")
  255.     ircsock.send("PRIVMSG "+ ircmsg +" :'HB shutdown' - shutdown H2Bot \n")    
  256.     ircsock.send("PRIVMSG "+ ircmsg +" :'HB tban <user> M-D_h:m' - tempban \n")
  257.     ircsock.send("PRIVMSG "+ ircmsg +" :'HB tkban <user> M-D_h:m' - tempban + kick \n")        
  258.        
  259. def selfharmdetect(string, actionmsg1, actionmsg2, self=selfref): #detects if the user is trying to issue a command against the bot.
  260.     if any(word in string.lower() for word in self):
  261.         user = string[1:]
  262.         print(user)
  263.         ircmsgr = user.index("!")
  264.         print(user)
  265.         user = user[:ircmsgr]
  266.         print(user)
  267.         ircsock.send("PRIVMSG " + channel + actionmsg1 + user + actionmsg2)
  268.        
  269.         return False
  270.     else:
  271.         return True
  272.  
  273. def stringSplit(string, text, position): #gets the parameter the user passed and returns it
  274.     stringreq = string
  275.     stringreqr = stringreq.index(text)
  276.     print(stringreqr)
  277.     stringreq = stringreq[stringreqr:]
  278.     print(stringreq)
  279.     stringreq = stringreq[position:]
  280.     print(stringreq)
  281.     stringreq = stringreq.strip('\n\r')
  282.     print(stringreq)
  283.     return stringreq
  284.    
  285. def functionTimer(string, timelimit): #checks that the functions arent being used too often
  286.     if timelimit > 0:
  287.         string = string[1:]
  288.         print(string)
  289.         string = string.index("!")
  290.         print(string)
  291.         string = string[:ircmsgr]
  292.         print(string)
  293.         ircsock.send("NOTICE "+ string +" :A FUNction has been used recently. Please wait a while before trying again. " + str(timelimit) + " cycles left. \n")
  294.         return False
  295.     else:  
  296.         timelimit = 10
  297.         return True
  298.  
  299. def wrongarg(receive, expect): # wrong number of arguments handler
  300.     ircsock.send("PRIVMSG "+channel+" :Error: Expected "+expect+" arguments, received "+receive+".\n")
  301.  
  302. def unbanloop(): #tempban parse 'n unban MULTITHREAD EDITION :O
  303.   while True:
  304.    try:
  305.         tbanparse = 0
  306.         for x in xrange(0, len(tbanned2)):
  307.          #print("unban time "+tbanned[tbanned2[tbanparse]])
  308.          #print("current time "+time.strftime("%m-%d_%H:%M"))
  309.          curtime = time.strftime("%m-%d_%H:%M")
  310.          cmonth = time.strftime("%m")
  311.          if cmonth[0] == '0':
  312.           cmonth = cmonth[1:]
  313.          cday = time.strftime("%d")
  314.          if cday[0] == '0':
  315.           cday = cday[1:]        
  316.          chour = time.strftime("%H")
  317.          if chour[0] == '0':
  318.           chour = chour[1:]      
  319.          cmin = time.strftime("%M")
  320.          if cmin[0] == '0':
  321.           cmin = cmin[1:]      
  322.          curtime = str(cmonth+"-"+cday+"_"+chour+":"+cmin)
  323.          if tbanned[tbanned2[tbanparse]] == curtime:
  324.                         tbf2 = open('C:\Users\Matthew\Documents\hydrobot\\tbanned2', 'w')
  325.                         tbf = open('C:\Users\Matthew\Documents\hydrobot\\tbanned', 'w')
  326.                         ircsock.send("MODE "+ channel +" -b "+tbanned2[tbanparse]+"\n")
  327.                         temp=tbanned2[tbanparse]
  328.                         tbanned.pop(temp)
  329.                         ircsock.send("PRIVMSG "+ channel +" :User "+tbanned2[tbanparse]+" is unbanned.\n")
  330.                         tbanned2.pop(tbanparse)
  331.                         tbf.write(str(tbanned))
  332.                         tbf2.write(str(tbanned2))
  333.                         tbf.close()
  334.                         tbf2.close()           
  335.          tbanparse = tbanparse + 1     
  336.  
  337.    except KeyError:
  338.                 tbf2 = open('C:\Users\Matthew\Documents\hydrobot\\tbanned2', 'w')
  339.                 tbanned2.pop(tbanparse)
  340.                 tbf2.write(str(tbanned2))
  341.                 tbf2.close()
  342.                 tbanparse = tbanparse + 1
  343.                 print("We hit an error, but we're still purring along!")
  344.  
  345. def swtimeout(name): #swearfilter timeout
  346.         time.sleep(600)
  347.         alloff.pop(name)
  348.         swf = open(filelocation+'swfile', 'w')
  349.         swf.write(str(alloff))
  350.         swf.close()            
  351.  
  352.        
  353. while True: # Be careful with these! it might send you to an infinite loop
  354.   ircmsg = ircsock.recv(2048) # receive data from the server
  355.   ircmsg = ircmsg.strip('\n\r') # removing any unnecessary linebreaks.
  356.   print(ircmsg) # Here we print what's coming from the server
  357.   if log == 1:
  358.    logw = open('C:\\Users\\Matthew\\Documents\\hydrobot\\log '+ date, 'a')
  359.    logw.write(ircmsg+'\n')
  360.  
  361.  
  362.  
  363.   if stringdetect("353 "+botnick):
  364.     opfindrun()
  365.  
  366.   if stringdetect("This nickname is registered"):
  367.     ircsock.send("PRIVMSG NickServ :identify "+password+"\n")
  368.        
  369.   if stringdetect(":Hello "+ botnick): # If we can find "Hello Mybot" it will call the function hello()
  370.     hello()
  371.  
  372.   if stringdetect("PING :"): # if the server pings us then we've got to respond!
  373.     ping()
  374.  
  375.   if stringdetect(":HB intro"):
  376.     intro()  
  377.  
  378.   if stringdetect(":"+botnick+" MODE "+botnick+" :+i"):
  379.     joinchan(channel)
  380.        
  381.   if stringdetect(" MODE "+botnick+" +xi"):
  382.     joinchan(channel)  
  383.  
  384.  
  385.   if stringdetect(":HB locate"):
  386.     locateuser(stringSplit(ircmsg, "locate", 7))
  387.  
  388.   if funcommands == 1:    
  389.     if stringdetect("HB randomize"): #checks if this command was used
  390.       if functionTimer(ircmsg, timelimit): #checks if the time limit is up
  391.        rand2(stringSplit(ircmsg, "randomize", 10)) #runs the function rand2 with the players parameter
  392.     if stringdetect("HB randomnum"):
  393.       if functionTimer(ircmsg, timelimit):
  394.        rand(stringSplit(ircmsg, "randomnum", 10))
  395.     if stringdetect(":HB slap"):
  396.       if functionTimer(ircmsg, timelimit):
  397.         if selfharmdetect(ircmsg, " :\x01ACTION slaps ", " with a large robotic trout for thinking I am dumb! \x01 \n"):
  398.          slapuser(stringSplit(ircmsg, "slap", 5))
  399.  
  400.     if stringdetect(":HB ew"):
  401.       if functionTimer(ircmsg, timelimit):
  402.         if selfharmdetect(ircmsg, " :Ew, ", ". I'm not that stupid! :P \n"):
  403.          ewuser(stringSplit(ircmsg, "ew ", 3))
  404.     if stringdetect(":HB suck"):
  405.       if functionTimer(ircmsg, timelimit):
  406.         if selfharmdetect(ircmsg, " :Um no", ". I'm not that stupid! :P \n"):
  407.          suckuser(stringSplit(ircmsg, "suck", 5))
  408.  
  409.   if stringdetect(":is this the real life"):
  410.     ircsock.send("PRIVMSG "+ channel +" :Is this just fantasy?\n")
  411.        
  412.   if stringdetect(":HB easy"):
  413.         ircsock.send("PRIVMSG "+ channel +" :That was easy. http://goo.gl/bnUZS7 \n")
  414.        
  415.   if stringdetect(":HB help"):
  416.     help(ircmsg)
  417.  
  418.   if stringdetect(":HB curtime"):
  419.     ircsock.send("PRIVMSG "+ channel +" :"+time.strftime("%m-%d_%H:%M")+"\n")
  420.        
  421.   if swearfilter == 1:
  422.    
  423.    if any(word in ircmsg.lower() for word in curses):
  424.         swearmessage = ircmsg.lower()
  425.         swearmessage = swearmessage[1:]
  426.         swearmessager = swearmessage.index(":")
  427.         swearmessage = swearmessage[swearmessager:]
  428.         swearmessage = swearmessage[1:]
  429.        
  430.         ircmsg = ircmsg[1:]
  431.         print(ircmsg)
  432.         ircmsgr = ircmsg.index("!")
  433.         print(ircmsg)
  434.         ircmsg = ircmsg[:ircmsgr]
  435.         print(ircmsg)
  436.         try:
  437.                 sweartally = alloff[ircmsg]
  438.         except KeyError:
  439.                 sweartally = 0
  440.                 thread.start_new_thread(swtimeout, (ircmsg,))
  441.                 print("New Timeout thread started.")
  442.         swearmessage = swearmessage.split(" ")
  443.         print(swearmessage)
  444.         swearparse = 0
  445.  
  446.         for word in swearmessage:
  447.                 if any(word in swearmessage[swearparse] for word in curses):
  448.                         sweartally = sweartally + 1
  449.                         swearparse = swearparse + 1
  450.                 else:
  451.                         swearparse = swearparse + 1
  452.        
  453.  
  454.         alloff[ircmsg] = sweartally
  455.         swf = open(filelocation+'swfile', 'w')
  456.         swf.write(str(alloff))
  457.         swf.close()    
  458.         if sweartally > 6:
  459.                 opparse = 0
  460.                 for x in xrange(0, len(mods)):
  461.                         ircsock.send("NOTICE "+mods[opparse]+" :Hey "+mods[opparse]+", "+ircmsg+" has continued using profanity.\n")
  462.                         opparse = opparse + 1          
  463.                 ircsock.send("NOTICE "+ ircmsg +" :"+ircmsg+", the chat mods have been alerted again.\n")      
  464.         elif sweartally == 6:
  465.                 opparse = 0
  466.                 for x in xrange(0, len(mods)):
  467.                         ircsock.send("NOTICE "+mods[opparse]+" :Hey "+mods[opparse]+", "+ircmsg+" has reached the profanity limit.\n")
  468.                         opparse = opparse + 1  
  469.                 ircsock.send("NOTICE "+ ircmsg +" :"+ircmsg+", the chat mods have been alerted. Action will be taken as deemed necessary.\n")          
  470.         elif sweartally == 5:
  471.                 ircsock.send("NOTICE "+ ircmsg +" :"+ircmsg+", stop cursing immediately. You have cursed "+str(sweartally)+" times in the last hour. Further offenses will be immediately brought to the attention of a moderator.\n")
  472.         elif sweartally >= 3:  
  473.                 ircsock.send("NOTICE "+ ircmsg +" :"+ircmsg+", please do not curse. You have cursed "+str(sweartally)+" times in the last hour. \n")
  474.  
  475.    
  476.   if stringdetect(":HB sw on"):
  477.    secr = ircmsg.index("PRIVMSG")
  478.    ircmsg = ircmsg[:secr]
  479.    if any(word in ircmsg for word in mods):  
  480.     swearfilter = 1  
  481.     ircsock.send("PRIVMSG "+ channel +" :Swear warning on. Current setting: six strikes every 10 minutes.\n")
  482.  
  483.   if stringdetect(":HB sw off"):
  484.    secr = ircmsg.index("PRIVMSG")
  485.    ircmsg = ircmsg[:secr]
  486.    if any(word in ircmsg for word in mods):
  487.     swearfilter = 0  
  488.     ircsock.send("PRIVMSG "+ channel +" :Swear warning off. Someone complained enough to make fire219 turn it off. \n")
  489.    
  490.   if stringdetect(":HB fun on"):
  491.    secr = ircmsg.index("PRIVMSG")
  492.    ircmsg = ircmsg[:secr]
  493.    if any(word in ircmsg for word in mods):  
  494.     funcommands = 1  
  495.     ircsock.send("PRIVMSG "+ channel +" :FUNctions on.\n")
  496.  
  497.   if stringdetect(":HB nokris"):
  498.         ircsock.send("PRIVMSG "+ channel +" :Activating Protocol 'Remove Inferior Beings'.\n")
  499.         time.sleep(1)
  500.         ircsock.send("KICK "+ channel +" Kris|Mobile  :Is inferior being.\n")
  501.         time.sleep(2)
  502.         ircsock.send("PRIVMSG "+ channel +" :Protocol 'Remove Inferior Beings' completed.\n")
  503.        
  504.   if stringdetect(":ping"):
  505.         ircsock.send("PRIVMSG "+ channel +" :Shut the fuck up.\n")
  506.        
  507.   if stringdetect(":HB shutdown"):
  508.    secr = ircmsg.index("PRIVMSG")
  509.    ircmsg = ircmsg[:secr]
  510.    secret = ['Doctor']
  511.    if any(word in ircmsg for word in mods):
  512.         if any(word in ircmsg for word in secret):
  513.          rand = random.randint(1,3)
  514.          if rand == 1:
  515.                 ircsock.send("PRIVMSG "+ channel +" :Would you kindly fuck yourself with a barbed rake, Mister Matheus de Alcantara? \n")
  516.          if rand == 2:
  517.                 ircsock.send("PRIVMSG "+ channel +" :LOLNOPETEEHEE#2SMART4POOFY\n")
  518.          if rand == 3:
  519.                 ircsock.send("PRIVMSG "+ channel +" :I'm afraid I can't do that, Mat. \n")
  520.         else:  
  521.                 ircsock.send("PRIVMSG "+ channel +" :'Good night', says the moon.\n")
  522.                 ircsock.send("QUIT :H2Bot -- The modbot of #starmade")
  523.                 time.sleep(1)
  524.                 os._exit(1)
  525.    
  526.   if stringdetect(":HB fun off"):
  527.    secr = ircmsg.index("PRIVMSG")
  528.    ircmsg = ircmsg[:secr]
  529.    if any(word in ircmsg for word in mods):
  530.     funcommands = 0
  531.     ircsock.send("PRIVMSG "+ channel +" :FUNctions off.\n")    
  532.    
  533.   if stringdetect(":HB tban"):
  534.    sec = ircmsg
  535.    secr = ircmsg.index("PRIVMSG")
  536.    sec = sec[:secr]
  537.    if any(word in sec for word in mods):  
  538.         tban = ircmsg
  539.         tbanr = tban.index("tban")
  540.         print(tbanr)
  541.         tban = tban[tbanr:]
  542.         tban = tban[5:]
  543.         tban = tban.strip('\n\r')
  544.         tban = tban.split(" ")
  545.         if len(tban) == 1:
  546.           wrongarg(1 , 2)
  547.         tbanned[tban[0]] = tban[1]
  548.         tbanned2.append(tban[0])    
  549.         ircsock.send("PRIVMSG "+ channel +" :User "+tban[0]+" banned until "+tban[1]+"\n")
  550.         ircsock.send("MODE "+ channel +" +b "+tban[0]+"\n")    
  551.         print(tbanned)
  552.         print(tbanned2)
  553.         tbf2 = open(filelocation+'tbanned2', 'w')
  554.         tbf = open(filelocation+'tbanned', 'w')
  555.         tbf.write(str(tbanned))
  556.         tbf2.write(str(tbanned2))
  557.         tbf.close()
  558.         tbf2.close()   
  559.         tban = []
  560.  
  561.   if stringdetect(":HB tkban"):
  562.    sec = ircmsg
  563.    secr = ircmsg.index("PRIVMSG")
  564.    sec = sec[:secr]
  565.    if any(word in sec for word in mods):  
  566.         tban = ircmsg
  567.         tbanr = tban.index("tkban")
  568.         print(tbanr)
  569.         tban = tban[tbanr:]
  570.         tban = tban[6:]
  571.         tban = tban.strip('\n\r')
  572.         tban = tban.split(" ")
  573.         if len(tban) == 1:
  574.           wrongarg(1 , 2)
  575.         tbanned[tban[0]] = tban[1]
  576.         tbanned2.append(tban[0])    
  577.         ircsock.send("PRIVMSG "+ channel +" :User "+tban[0]+" banned until "+tban[1]+"\n")
  578.         ircsock.send("MODE "+ channel +" +b "+tban[0]+"\n")
  579.         ircsock.send("KICK "+ channel +" "+tban[0]+"\n")       
  580.         print(tbanned)
  581.         print(tbanned2)
  582.         tbf2 = open(filelocation+'tbanned2', 'w')
  583.         tbf = open(filelocation+'tbanned', 'w')
  584.         tbf.write(str(tbanned))
  585.         tbf2.write(str(tbanned2))
  586.         tbf.close()
  587.         tbf2.close()   
  588.         tban = []
  589.  
  590.   if stringdetect("slaps "+botnick):
  591.     ircmsg = ircmsg[1:]
  592.     print(ircmsg)
  593.     ircmsgr = ircmsg.index("!")
  594.     print(ircmsg)
  595.     ircmsg = ircmsg[:ircmsgr]
  596.     print(ircmsg)
  597.     ircsock.send("PRIVMSG "+ channel +" :\x01ACTION returns " + ircmsg + " the favor with a large robotic trout! \x01 \n")
  598.  
  599.   if stringdetect("slapped "+botnick):
  600.     ircmsg = ircmsg[1:]
  601.     print(ircmsg)
  602.     ircmsgr = ircmsg.index("!")
  603.     print(ircmsg)
  604.     ircmsg = ircmsg[:ircmsgr]
  605.     print(ircmsg)
  606.     ircsock.send("PRIVMSG "+ channel +" :\x01ACTION returns " + ircmsg + " the favor with a large robotic trout! \x01 \n")      
  607.  
  608.   if timelimit > 0:
  609.    timelimit = timelimit - 1
  610.    
  611.   if stringdetect(":HB adminhelp"):
  612.    secr = ircmsg.index("PRIVMSG")
  613.    ircmsg = ircmsg[:secr]
  614.    if any(word in ircmsg for word in mods):
  615.      adminhelp(ircmsg)
  616.  
  617.   if threadsrunning == 0:
  618.    if mods != []: #time to start multithreading!
  619.         thread.start_new_thread(unbanloop,())
  620.         print("Tempban thread running!")
  621.         threadsrunning = 1
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top