All pastes #800466 Raw Edit

Something

public python v1 · immutable
#800466 ·published 2007-11-28 13:49 UTC
rendered paste body
# -*- coding: iso-8859-1 -*-import pygtkpygtk.require('2.0')import gtk#commencement de la socketclass sockbot:    import sys    import socket    import string        SERV="irc.project-x.fr"    PORT=6667    NICK="Python_Bot"    IDENT="Python_Bot"    REALNAME="Bot En Python"    readbuffer=""    sock=socket.socket( )    def callback(self, widget, data):        if data == "Connexion":            sock.connect((SERV, PORT))            sock.send("NICK %s\r\n" % NICK)            sock.send("USER %s %s bla :%s\r\n" % (IDENT, SERV, REALNAME))                while 1:                readbuffer=readbuffer+sock.recv(1024)                temp=string.split(readbuffer, "\n")                readbuffer=temp.pop( )                for line in temp:                    line=string.rstrip(line)                    line=string.split(line)                    print line                                if (line[0]=="PING"):                         sock.send("PONG %s\r\n" % line[1])                #commencement de l'interface        class sockbotface:    def __init__(self):        #Creation de la fenetre        self.fenetre = gtk.Window(gtk.WINDOW_TOPLEVEL)        self.fenetre.set_title("SockBot By Street")        self.fenetre.set_resizable(False)        self.fenetre.set_size_request(500,450)                #Creation des boutons                        #Creation du textview        self.scroll = gtk.ScrolledWindow()        self.scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)        self.textv = gtk.TextView()        self.textbuf = self.textv.get_buffer()                 #conteneur et affichage des widgets        self.conteneur = gtk.Fixed()        self.fenetre.add(self.conteneur)        #self.conteneur.put(self.textv,5,40)        self.scroll.add(self.textv)        self.conteneur.put(self.scroll,440,40)        self.fenetre.show_all()            def boucle(self):        gtk.main()        if __name__ == "__main__":     base = sockbotface()     base.boucle()