Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- import socket, time, json, os, urllib, sys, webbrowser, IRC # Imports, ne pas modifier sauf si vous connaissez Python.
- bot = IRC.IRC()
- os.chdir("C:/Users/thoma/LifeBot")
- # Destination chan
- chan = "#popular"
- # Whitelist init
- trust = []
- # Username
- user_bot = "CastelBot"
- ver = "1.0"
- #Et dessus, vous voyez le nom de version du bot ! Ajoutez après Variante de votre pseudo !
- host = "irc.freenode.net"
- #Le bot se connecte grâce à ce qu'il y a entre les guillemets qui sont à côté de host.
- port = 6667
- #Le port du réseau IRC.
- #Début de la partie à ne pas modifier sauf si vous connaîssez Python.
- #Version de LifeBot :
- ver_LifeBot = "1.1"
- lang_LifeBot = "fr"
- print "CastelBot v.", ver
- #Mot de passe :
- password = raw_input("Mot de passe : ")
- print "Connecting to IRC..."
- #Connexion à IRC :
- identify = False
- IRC = socket.socket()
- IRC.connect((host, port))
- IRC.send("NICK %s\r\n" % user_bot)
- IRC.send("USER LifeBot %s bla :%s\r\n" % (host, user_bot))
- #Boucle de connnexion :
- print "Authenticating and connecting to channel", chan, "..."
- while True:
- rep = IRC.recv(2048)
- rep2 = rep.split()
- text = " ".join(rep2[3:]).lower()
- print(rep)
- try:
- if ":End of /MOTD command." in rep and identify == False:
- IRC.send("PRIVMSG NickServ :identify %s\r\n" % password)
- IRC.send("JOIN %s\r\n" % chan)
- identify = True
- #Réponse au ping du réseau IRC :
- if rep2[0] == "PING":
- IRC.send("PONG %s\r\n" % rep2[1])
- #Réponse aux invitations du bot :
- if rep2[1] == "INVITE":
- IRC.send("JOIN %s\r\n" % rep2[3])
- except IndexError:
- rep2[1] = ""
- if rep2[1] == "PRIVMSG":
- try:
- user = rep2[0].split("!")
- user[0] = user[0].strip(":")
- if rep2[2].find("#") > -1:
- #Fin de la partie.
- if " please ban " in text or "please ban " in text:
- text = text.split(" ")
- uname = text[text.index('ban')+1]
- IRC.send("PRIVMSG %s :%s\r\n" % (rep2[2], "Banning in 5 seconds..."))
- time.sleep(5)
- try:
- bot.ban(rep2[2], uname)
- except:
- banError = "==== I encountered an error while banning '" + uname + "' ===="
- IRC.send("PRIVMSG %s :%s\r\n" % (rep2[2], banError))
- if rep2[3].lower() == ":$deco":
- bot.disconnect()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement