<s> from twisted . words . protocols import irc <EOL> class IRCBot ( irc . IRCClient ) : <EOL> def connectionMade ( self ) : <EOL> self . nickname = self . factory . nickname <EOL> irc . IRCClient . connectionMade ( self ) <EOL> def signedOn ( self ) : <EOL> self . join ( self . factory . channel ) <EOL> def joined ( self , channel ) : <EOL> self . msg ( channel , <EOL> "<STR_LIT>" % ( channel , ) ) <EOL> def userJoined ( self , user , channel ) : <EOL> self . msg ( channel , "<STR_LIT>" + user + "<STR_LIT>" ) <EOL> def privmsg ( self , user , channel , msg ) : <EOL> user = user . split ( '<STR_LIT:!>' , <NUM_LIT:1> ) [ <NUM_LIT:0> ] <EOL> if channel == self . nickname : <EOL> msg = "<STR_LIT>" <EOL> self . msg ( user , msg ) <EOL> elif msg . startswith ( self . nickname ) : <EOL> response = "<STR_LIT>" <EOL> m = [ m for m in msg . split ( '<STR_LIT:U+0020>' ) if m ] <EOL> command = m [ <NUM_LIT:1> : ] <EOL> if len ( command ) > <NUM_LIT:2> and command [ <NUM_LIT:0> ] == "<STR_LIT>" : <EOL> recipient = command [ <NUM_LIT:1> ] <EOL> text = '<STR_LIT:U+0020>' . join ( command [ <NUM_LIT:2> : ] ) <EOL> self . factory . send_sms ( recipient , text ) <EOL> response = "<STR_LIT>" % ( user , recipient , text ) <EOL> else : <EOL> response = "<STR_LIT>" % ( '<STR_LIT:U+0020>' . join ( command ) , ) <EOL> self . msg ( channel , response ) </s>
