Advertisement
Guest User

Untitled

a guest
May 24th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.59 KB | None | 0 0
  1. # -*- coding: utf-8  -*-
  2.  
  3. import socket, time, json, os, urllib, sys, webbrowser, IRC # Imports, ne pas modifier sauf si vous connaissez Python.
  4. bot = IRC.IRC()
  5. os.chdir("C:/Users/thoma/LifeBot")
  6.  
  7.  
  8. # Destination chan
  9. chan = "#popular"
  10.  
  11. # Whitelist init
  12. trust = []
  13.  
  14. # Username
  15. user_bot = "CastelBot"
  16.  
  17.  
  18. ver = "1.0"
  19. #Et dessus, vous voyez le nom de version du bot ! Ajoutez après Variante de votre pseudo !
  20. host = "irc.freenode.net"
  21. #Le bot se connecte grâce à  ce qu'il y a entre les guillemets qui sont à  côté de host.
  22. port = 6667
  23. #Le port du réseau IRC.
  24.  
  25.  
  26. #Début de la partie à  ne pas modifier sauf si vous connaîssez Python.
  27. #Version de LifeBot :
  28. ver_LifeBot = "1.1"
  29. lang_LifeBot = "fr"
  30. print "CastelBot v.", ver
  31. #Mot de passe :
  32. password = raw_input("Mot de passe : ")
  33. print "Connecting to IRC..."
  34. #Connexion à  IRC :
  35. identify = False
  36. IRC = socket.socket()
  37. IRC.connect((host, port))
  38. IRC.send("NICK %s\r\n" % user_bot)
  39. IRC.send("USER LifeBot %s bla :%s\r\n" % (host, user_bot))
  40. #Boucle de connnexion :
  41. print "Authenticating and connecting to channel", chan, "..."
  42. while True:
  43.     rep = IRC.recv(2048)
  44.     rep2 = rep.split()
  45.     text = " ".join(rep2[3:]).lower()
  46.     print(rep)
  47.     try:
  48.         if ":End of /MOTD command." in rep and identify == False:
  49.             IRC.send("PRIVMSG NickServ :identify %s\r\n" % password)
  50.             IRC.send("JOIN %s\r\n" % chan)
  51.             identify = True
  52. #Réponse au ping du réseau IRC :
  53.         if rep2[0] == "PING":
  54.             IRC.send("PONG %s\r\n" % rep2[1])
  55. #Réponse aux invitations du bot :
  56.         if rep2[1] == "INVITE":
  57.             IRC.send("JOIN %s\r\n" % rep2[3])
  58.     except IndexError:
  59.         rep2[1] = ""
  60.     if rep2[1] == "PRIVMSG":
  61.         try:
  62.             user = rep2[0].split("!")
  63.             user[0] = user[0].strip(":")
  64.             if rep2[2].find("#") > -1:
  65. #Fin de la partie.
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.    
  81.                 if " please ban " in text or "please ban " in text:
  82.                     text = text.split(" ")
  83.                     uname = text[text.index('ban')+1]
  84.                     IRC.send("PRIVMSG %s :%s\r\n" % (rep2[2], "Banning in 5 seconds..."))
  85.                     time.sleep(5)
  86.                     try:
  87.                         bot.ban(rep2[2], uname)
  88.                     except:
  89.                         banError = "==== I encountered an error while banning '" + uname + "' ===="
  90.                         IRC.send("PRIVMSG %s :%s\r\n" % (rep2[2], banError))
  91.                    
  92.                 if rep2[3].lower() == ":$deco":
  93.                     bot.disconnect()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement