djthyrax Posted June 23, 2008 at 07:49 PM Report Share #193115 Posted June 23, 2008 at 07:49 PM class Message: maxLen = 512 prefix = '' command = '' params = [] terminator = "\r\n" _repr = '' def __init__(self, prefix = '', command = '', params = []): self.prefix = prefix self.command = command self.params = params if self.getRepr() is None: raise RuntimeError, 'Invalid message' def getRepr(self): if self.prefix.strip() != '': self._repr = "%s %s %s%s" % (self.prefix, self.command, ' '.join(self.params), self.terminator) else: self._repr = "%s %s%s" % (self.command, ' '.join(self.params), self.terminator) if len(self._repr) > self.maxLen: return None return self._repr def ParseMessage(message): if message[-2:] == "\r\n": message = message[:-2] if message[0] == ':' and message.find(' ') > 1: #we have a prefix. prefix, command, params = message.split(' ', 2) params = params.split(' ') else: prefix = '' command, params = message.split(' ', 1) params = params.split(' ') return Message(prefix, command, params) if __name__ == '__main__': print ParseMessage(":simplesnet.ptnet.org NOTICE :LULZ OIS OIS\r\n").getRepr() Docs to be written. Para os mais curiosos, isto está relacionado com o ponto 2.3 do RFC 1459: http://www.faqs.org/ftp/rfc/pdf/rfc1459.txt.pdf Não peças ajuda por PM! A tua dúvida vai ter menos atenção do que se for postada na secção correcta do fórum! Link to comment Share on other sites More sharing options...
Triton Posted June 23, 2008 at 09:49 PM Report Share #193129 Posted June 23, 2008 at 09:49 PM Parece nice! 😛 Vais escrever um bot ou servidor IRC? <3 life Link to comment Share on other sites More sharing options...
djthyrax Posted June 23, 2008 at 09:59 PM Author Report Share #193131 Posted June 23, 2008 at 09:59 PM Lib para fazer clientes (primeiro cliente vai ser mesmo um bot) (tou a pensar fazer isto por hooks), depois se tiver com pica suficiente, faço um standalone IRCd (ie., sem me preocupar em ter uma network com vários servers), e se estiver muito bored, meto isto para poder fazer uma network com vários servers. Não peças ajuda por PM! A tua dúvida vai ter menos atenção do que se for postada na secção correcta do fórum! Link to comment Share on other sites More sharing options...
Betovsky Posted June 23, 2008 at 11:09 PM Report Share #193152 Posted June 23, 2008 at 11:09 PM Se tu estiveres realmente mesmo muito bored. Metes o teu bot todo pipi, para testar código automaticamente que é posto no canal ou no pastebin, etc... "Give a man a fish and he will eat for a day; Teach a man to fish and he will eat for a lifetime. The moral? READ THE MANUAL !" Sign on a computer system consultant's desk Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now