Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import socket,sys,threading,time,irccore
- from irccore import *
- class Botloader (threading.Thread):
- def __init__(self, network, port, nick, user, channel):
- self.sock = socket.socket ( socket.AF_INET, socket.SOCK_STREAM )
- self.sock.connect ( ( network, port ) )
- self.running = True
- self.mybuff = ''
- threading.Thread.__init__ ( self )
- join_net(self,nick,user,network)
- join_channel(self,channel)
- # Convenience method to make it easy to reply from a function below
- def send(self, fmt, *args):
- if args:
- fmt %= args
- self.sock.send(fmt + '\r\n')
- def stop(self):
- self.running = False
- # Handle a single received line.
- def do_once(self):
- # Split up the line a bit, figure out what the command was.
- self.mybuff = self.sock.recv ( 4096 )
- if self.mybuff != '':
- print self.mybuff
- privmsg = re.compile('^.*!.*@.* PRIVMSG .*:')
- if self.mybuff.startswith("PING"):
- print "PING"
- for callback in COMMAND_HANDLERS.get('PING'):
- callback(self, self.mybuff)
- elif privmsg.match(self.mybuff):
- for callback in COMMAND_HANDLERS.get('PRIVMSG'):
- callback(self, self.mybuff)
- def run(self):
- while self.running:
- self.do_once()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement