Bot irc python problème rejoindre channel

cs_Kuby Messages postés 1 Date d'inscription dimanche 17 juin 2007 Statut Membre Dernière intervention 10 juin 2008 - 10 juin 2008 à 13:05
xeolin Messages postés 336 Date d'inscription samedi 26 novembre 2005 Statut Membre Dernière intervention 8 novembre 2011 - 12 juil. 2008 à 03:37
Bonjour, voila, après avoir un petit peu fouiller sur le net, j'ai reussi a trouver / modifier ceci :
Mais je n'arrive pas à rejoindre de channel... aidez moi plz

#!/usr/bin/env python

import string
import socket

HOST='irc.quakenet.org'
PORT=6667
NICK='cequejeveux'
IDENT='jenesaispas'
REALNAME='jensaisrien'

global OWNER

CHANNEL='#peuimport' #the bot will connect to this channel first

 

IRC=socket.socket( )

IRC.connect((HOST, PORT))

IRC.send("NICK %s\r\n" % NICK)

IRC.send("USER %s %s bla :%s\r\n" % (IDENT, HOST, REALNAME))

IRC.send('JOIN %s\r\n' %CHANNEL) #Join a channel

global mute

mute = 0

 

def sendPrivateMessage(channel, message):#private message send function

    global mute

    if mute == 0:

        IRC.send("PRIVMSG " + channel + " :" + message + "\r\n")

 

 

def ownercommand(CHANNEL, COMMAND, PARAM1, MESSAGE):#commands that only 'admins' can use

    if PARAM1 == "<NULL>":

        if COMMAND == ":!mute":

            global mute

            mute = 1

        if COMMAND == ":!unmute":

            global mute

            mute = 0

    else:

        if COMMAND == ":!leave":

            IRC.send("PART %s\r\n" % PARAM1)

        if COMMAND == ":!join":

            IRC.send("JOIN %s\r\n" % PARAM1)

        if COMMAND == ":!addadmin":

            global OWNER

            OWNER.append(PARAM1)

            sendPrivateMessage(CHANNEL, "you can now control me %s" % PARAM1)

        if COMMAND == ":!adddata":

            data = open("DATA.DATA", "r")

            data.seek(0)

            while 1:

                line = data.readline()

                if not line:

                    file = open("DATA.DATA", "a")

                    file.write("|<>"+PARAM1 +" |||"+MESSAGE.replace("!adddata "+PARAM1,"").replace("\r\n","")+"|||\n")

                    file.close()

                    break

                line = line[:-1]

                if line.find(PARAM1)!=-1:

                    sendPrivateMessage(CHANNEL,"I already have an entry for that keyword and therefore it must be changed manually")

                    break

            data.close()

           

def allcommand(CHANNEL, COMMAND, PARAM1):#commands that anyone can use

    if PARAM1 == "<NULL>":

        if COMMAND == ":!about":

            sendPrivateMessage(CHANNEL,"about what... Idiot")

    else:

        if COMMAND == ":!about":

            data = open("DATA.DATA", "r")

            data.seek(0)

            while 1:

                line = data.readline()

                if not line:

                    sendPrivateMessage(CHANNEL, "I don't know about that")

                    break

                line = line[:-1]

                if line.find("|<>" + PARAM1)!=-1:

                    sendPrivateMessage(CHANNEL,line.split("|||")[1])

                    break

            data.close()

                                 

 

while 1:

    buffer = IRC.recv(1024)

    msg = string.split(buffer)

    talk = buffer.split(" :")

    sender = buffer.split("!") [ 0 ].replace (":", "" )

    msg.append("<NULL>")

    print sender + " " +msg[2] + " :" + talk[1] #output a message that mostly makes sense

    if msg[0] == "PING": #server pings

        IRC.send("PONG %s\r\n" % msg[1])

    if msg [1] == "JOIN" and sender != NICK:

        sendPrivateMessage(msg[2].replace(":",""), "I agree the earth is flat.")

    if msg [1] == "PRIVMSG":

        if msg[2] == NICK: #private message

            if msg[3].startswith(":!"):

                allcommand(sender, msg[3],msg[4])

                if sender in OWNER:

                    ownercommand(sender, msg[3], msg[4], talk[1])

            else:

                sendPrivateMessage( sender, "Don't talk to me %s" %sender )

        else: # message recieved from a channel

            if talk[1].find("LOL WOT")!=-1:

                sendPrivateMessage(msg[2], "%s you are a retard." %sender)

            elif talk[1].find(" hi ")!=-1:

                sendPrivateMessage(msg[2], "hi")

            if  str.lower(talk[1]).find("a")!=-1:

                sendPrivateMessage(msg[2], "you used the letter 'a' in that message %s" %sender)

            if msg[3].startswith(":!"):

                allcommand(msg[2], msg[3],msg[4])

                if sender in OWNER:

                    ownercommand(msg[2], msg[3], msg[4], talk[1])

1 réponse

xeolin Messages postés 336 Date d'inscription samedi 26 novembre 2005 Statut Membre Dernière intervention 8 novembre 2011 2
12 juil. 2008 à 03:37
Est-ce-que ca a marcher le premier coup, et ce n'est que aprés que ca a arréter de marcher ? On appele ca un ban causer par un anti-bot.
0
Rejoignez-nous