Advertisement
pantteri

Another oneliner IRC bot

Apr 4th, 2013
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.65 KB | None | 0 0
  1. import itertools, socket, sys, re; (lambda self: [setattr(self, 'connection', socket.socket(socket.AF_INET, socket.SOCK_STREAM)), self.connection.connect((sys.argv[1], int(sys.argv[2]))), setattr(self, 'socketfile', self.connection.makefile()), setattr(self, 'send', staticmethod(lambda data: [sys.stdout.write(str('<- %s\n' % data)), self.connection.send(data + '\r\n')] and None)), setattr(self, 'send_msg', staticmethod(lambda where, msg: [self.send('PRIVMSG %s :%s' % (where, line)) for line in str(msg).split('\n')])), setattr(self, 'reply', staticmethod(lambda msg: self.send_msg(self.destination, msg))), self.send('NICK onebot'), self.send('USER onebot h h :Oneliner Python IRC bot by Felixx.'), [[setattr(self, 'data', self.socketfile.readline().strip('\r\n')), sys.stdout.write('-> %s\n' % self.data), setattr(self, 'parsed', re.match(r'^(:(?P<prefix>(?P<nick>[^ @!]*)(!(?P<user>[^@]*)[^ ]*)?(@(?P<host>[^ ]*))?) )?(?P<command>[^ ]*)(?P<arguments>.*?)( :(?P<trailing>.*))?$', self.data)), setattr(self, 'command', self.parsed.group('command')), setattr(self, 'nick', self.parsed.group('nick')), setattr(self, 'arguments', self.parsed.group('arguments').split()), setattr(self, 'trailing', self.parsed.group('trailing')), self.command == 'PING' and self.send('PONG :%s' % self.trailing), self.command == 'INVITE' and self.send('JOIN %s' % self.trailing), self.command == 'PRIVMSG' and [setattr(self, 'destination', self.arguments[0] if self.arguments[0][0] in '#!+&' else self.nick), self.trailing.startswith('ping') and self.reply(self.trailing.replace('i', 'o', 1)), self.trailing.startswith('@cycle') and self.reply(i)]]for i in itertools.count()]])(type('olio', (object, ), {}))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement