SHARE
TWEET

H2Bot non-Snoonet

fire219 Aug 5th, 2015 170 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 = "chat.freenode.net" # IRC network
  34. channel = "#h2bot" # 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.  
  382.   if stringdetect(":HB locate"):
  383.     locateuser(stringSplit(ircmsg, "locate", 7))
  384.  
  385.   if funcommands == 1:    
  386.     if stringdetect("HB randomize"): #checks if this command was used
  387.       if functionTimer(ircmsg, timelimit): #checks if the time limit is up
  388.        rand2(stringSplit(ircmsg, "randomize", 10)) #runs the function rand2 with the players parameter
  389.     if stringdetect("HB randomnum"):
  390.       if functionTimer(ircmsg, timelimit):
  391.        rand(stringSplit(ircmsg, "randomnum", 10))
  392.     if stringdetect(":HB slap"):
  393.       if functionTimer(ircmsg, timelimit):
  394.         if selfharmdetect(ircmsg, " :\x01ACTION slaps ", " with a large robotic trout for thinking I am dumb! \x01 \n"):
  395.          slapuser(stringSplit(ircmsg, "slap", 5))
  396.  
  397.     if stringdetect(":HB ew"):
  398.       if functionTimer(ircmsg, timelimit):
  399.         if selfharmdetect(ircmsg, " :Ew, ", ". I'm not that stupid! :P \n"):
  400.          ewuser(stringSplit(ircmsg, "ew ", 3))
  401.     if stringdetect(":HB suck"):
  402.       if functionTimer(ircmsg, timelimit):
  403.         if selfharmdetect(ircmsg, " :Um no", ". I'm not that stupid! :P \n"):
  404.          suckuser(stringSplit(ircmsg, "suck", 5))
  405.  
  406.   if stringdetect(":is this the real life"):
  407.     ircsock.send("PRIVMSG "+ channel +" :Is this just fantasy?\n")
  408.        
  409.   if stringdetect(":HB easy"):
  410.         ircsock.send("PRIVMSG "+ channel +" :That was easy. http://goo.gl/bnUZS7 \n")
  411.        
  412.   if stringdetect(":HB help"):
  413.     help(ircmsg)
  414.  
  415.   if stringdetect(":HB curtime"):
  416.     ircsock.send("PRIVMSG "+ channel +" :"+time.strftime("%m-%d_%H:%M")+"\n")
  417.        
  418.   if swearfilter == 1:
  419.    
  420.    if any(word in ircmsg.lower() for word in curses):
  421.         swearmessage = ircmsg.lower()
  422.         swearmessage = swearmessage[1:]
  423.         swearmessager = swearmessage.index(":")
  424.         swearmessage = swearmessage[swearmessager:]
  425.         swearmessage = swearmessage[1:]
  426.        
  427.         ircmsg = ircmsg[1:]
  428.         print(ircmsg)
  429.         ircmsgr = ircmsg.index("!")
  430.         print(ircmsg)
  431.         ircmsg = ircmsg[:ircmsgr]
  432.         print(ircmsg)
  433.         try:
  434.                 sweartally = alloff[ircmsg]
  435.         except KeyError:
  436.                 sweartally = 0
  437.                 thread.start_new_thread(swtimeout, (ircmsg,))
  438.                 print("New Timeout thread started.")
  439.         swearmessage = swearmessage.split(" ")
  440.         print(swearmessage)
  441.         swearparse = 0
  442.  
  443.         for word in swearmessage:
  444.                 if any(word in swearmessage[swearparse] for word in curses):
  445.                         sweartally = sweartally + 1
  446.                         swearparse = swearparse + 1
  447.                 else:
  448.                         swearparse = swearparse + 1
  449.        
  450.  
  451.         alloff[ircmsg] = sweartally
  452.         swf = open(filelocation+'swfile', 'w')
  453.         swf.write(str(alloff))
  454.         swf.close()    
  455.         if sweartally > 6:
  456.                 opparse = 0
  457.                 for x in xrange(0, len(mods)):
  458.                         ircsock.send("NOTICE "+mods[opparse]+" :Hey "+mods[opparse]+", "+ircmsg+" has continued using profanity.\n")
  459.                         opparse = opparse + 1          
  460.                 ircsock.send("NOTICE "+ ircmsg +" :"+ircmsg+", the chat mods have been alerted again.\n")      
  461.         elif sweartally == 6:
  462.                 opparse = 0
  463.                 for x in xrange(0, len(mods)):
  464.                         ircsock.send("NOTICE "+mods[opparse]+" :Hey "+mods[opparse]+", "+ircmsg+" has reached the profanity limit.\n")
  465.                         opparse = opparse + 1  
  466.                 ircsock.send("NOTICE "+ ircmsg +" :"+ircmsg+", the chat mods have been alerted. Action will be taken as deemed necessary.\n")          
  467.         elif sweartally == 5:
  468.                 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")
  469.         elif sweartally >= 3:  
  470.                 ircsock.send("NOTICE "+ ircmsg +" :"+ircmsg+", please do not curse. You have cursed "+str(sweartally)+" times in the last hour. \n")
  471.  
  472.    
  473.   if stringdetect(":HB sw on"):
  474.    secr = ircmsg.index("PRIVMSG")
  475.    ircmsg = ircmsg[:secr]
  476.    if any(word in ircmsg for word in mods):  
  477.     swearfilter = 1  
  478.     ircsock.send("PRIVMSG "+ channel +" :Swear warning on. Current setting: six strikes every 10 minutes.\n")
  479.  
  480.   if stringdetect(":HB sw off"):
  481.    secr = ircmsg.index("PRIVMSG")
  482.    ircmsg = ircmsg[:secr]
  483.    if any(word in ircmsg for word in mods):
  484.     swearfilter = 0  
  485.     ircsock.send("PRIVMSG "+ channel +" :Swear warning off. Someone complained enough to make fire219 turn it off. \n")
  486.    
  487.   if stringdetect(":HB fun on"):
  488.    secr = ircmsg.index("PRIVMSG")
  489.    ircmsg = ircmsg[:secr]
  490.    if any(word in ircmsg for word in mods):  
  491.     funcommands = 1  
  492.     ircsock.send("PRIVMSG "+ channel +" :FUNctions on.\n")
  493.  
  494.   if stringdetect(":HB nokris"):
  495.         ircsock.send("PRIVMSG "+ channel +" :Activating Protocol 'Remove Inferior Beings'.\n")
  496.         time.sleep(1)
  497.         ircsock.send("KICK "+ channel +" Kris|Mobile  :Is inferior being.\n")
  498.         time.sleep(2)
  499.         ircsock.send("PRIVMSG "+ channel +" :Protocol 'Remove Inferior Beings' completed.\n")
  500.        
  501.   if stringdetect(":ping"):
  502.         ircsock.send("PRIVMSG "+ channel +" :Shut the fuck up.\n")
  503.        
  504.   if stringdetect(":HB shutdown"):
  505.    secr = ircmsg.index("PRIVMSG")
  506.    ircmsg = ircmsg[:secr]
  507.    secret = ['Doctor']
  508.    if any(word in ircmsg for word in mods):
  509.         if any(word in ircmsg for word in secret):
  510.          rand = random.randint(1,3)
  511.          if rand == 1:
  512.                 ircsock.send("PRIVMSG "+ channel +" :Would you kindly fuck yourself with a barbed rake, Mister Matheus de Alcantara? \n")
  513.          if rand == 2:
  514.                 ircsock.send("PRIVMSG "+ channel +" :LOLNOPETEEHEE#2SMART4POOFY\n")
  515.          if rand == 3:
  516.                 ircsock.send("PRIVMSG "+ channel +" :I'm afraid I can't do that, Mat. \n")
  517.         else:  
  518.                 ircsock.send("PRIVMSG "+ channel +" :'Good night', says the moon.\n")
  519.                 ircsock.send("QUIT :H2Bot -- The modbot of #starmade")
  520.                 time.sleep(1)
  521.                 os._exit(1)
  522.    
  523.   if stringdetect(":HB fun off"):
  524.    secr = ircmsg.index("PRIVMSG")
  525.    ircmsg = ircmsg[:secr]
  526.    if any(word in ircmsg for word in mods):
  527.     funcommands = 0
  528.     ircsock.send("PRIVMSG "+ channel +" :FUNctions off.\n")    
  529.    
  530.   if stringdetect(":HB tban"):
  531.    sec = ircmsg
  532.    secr = ircmsg.index("PRIVMSG")
  533.    sec = sec[:secr]
  534.    if any(word in sec for word in mods):  
  535.         tban = ircmsg
  536.         tbanr = tban.index("tban")
  537.         print(tbanr)
  538.         tban = tban[tbanr:]
  539.         tban = tban[5:]
  540.         tban = tban.strip('\n\r')
  541.         tban = tban.split(" ")
  542.         if len(tban) == 1:
  543.           wrongarg(1 , 2)
  544.         tbanned[tban[0]] = tban[1]
  545.         tbanned2.append(tban[0])    
  546.         ircsock.send("PRIVMSG "+ channel +" :User "+tban[0]+" banned until "+tban[1]+"\n")
  547.         ircsock.send("MODE "+ channel +" +b "+tban[0]+"\n")    
  548.         print(tbanned)
  549.         print(tbanned2)
  550.         tbf2 = open(filelocation+'tbanned2', 'w')
  551.         tbf = open(filelocation+'tbanned', 'w')
  552.         tbf.write(str(tbanned))
  553.         tbf2.write(str(tbanned2))
  554.         tbf.close()
  555.         tbf2.close()   
  556.         tban = []
  557.  
  558.   if stringdetect(":HB tkban"):
  559.    sec = ircmsg
  560.    secr = ircmsg.index("PRIVMSG")
  561.    sec = sec[:secr]
  562.    if any(word in sec for word in mods):  
  563.         tban = ircmsg
  564.         tbanr = tban.index("tkban")
  565.         print(tbanr)
  566.         tban = tban[tbanr:]
  567.         tban = tban[6:]
  568.         tban = tban.strip('\n\r')
  569.         tban = tban.split(" ")
  570.         if len(tban) == 1:
  571.           wrongarg(1 , 2)
  572.         tbanned[tban[0]] = tban[1]
  573.         tbanned2.append(tban[0])    
  574.         ircsock.send("PRIVMSG "+ channel +" :User "+tban[0]+" banned until "+tban[1]+"\n")
  575.         ircsock.send("MODE "+ channel +" +b "+tban[0]+"\n")
  576.         ircsock.send("KICK "+ channel +" "+tban[0]+"\n")       
  577.         print(tbanned)
  578.         print(tbanned2)
  579.         tbf2 = open(filelocation+'tbanned2', 'w')
  580.         tbf = open(filelocation+'tbanned', 'w')
  581.         tbf.write(str(tbanned))
  582.         tbf2.write(str(tbanned2))
  583.         tbf.close()
  584.         tbf2.close()   
  585.         tban = []
  586.  
  587.   if stringdetect("slaps "+botnick):
  588.     ircmsg = ircmsg[1:]
  589.     print(ircmsg)
  590.     ircmsgr = ircmsg.index("!")
  591.     print(ircmsg)
  592.     ircmsg = ircmsg[:ircmsgr]
  593.     print(ircmsg)
  594.     ircsock.send("PRIVMSG "+ channel +" :\x01ACTION returns " + ircmsg + " the favor with a large robotic trout! \x01 \n")
  595.  
  596.   if stringdetect("slapped "+botnick):
  597.     ircmsg = ircmsg[1:]
  598.     print(ircmsg)
  599.     ircmsgr = ircmsg.index("!")
  600.     print(ircmsg)
  601.     ircmsg = ircmsg[:ircmsgr]
  602.     print(ircmsg)
  603.     ircsock.send("PRIVMSG "+ channel +" :\x01ACTION returns " + ircmsg + " the favor with a large robotic trout! \x01 \n")      
  604.  
  605.   if timelimit > 0:
  606.    timelimit = timelimit - 1
  607.    
  608.   if stringdetect(":HB adminhelp"):
  609.    secr = ircmsg.index("PRIVMSG")
  610.    ircmsg = ircmsg[:secr]
  611.    if any(word in ircmsg for word in mods):
  612.      adminhelp(ircmsg)
  613.  
  614.   if threadsrunning == 0:
  615.    if mods != []: #time to start multithreading!
  616.         thread.start_new_thread(unbanloop,())
  617.         print("Tempban thread running!")
  618.         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