Advertisement
pantteri

Oneliner IRC bot (human readable)

Jan 1st, 2013
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.77 KB | None | 0 0
  1. (lambda functionh, values: __import__('sys').setrecursionlimit(1000000) == functionh(functionh, values))(
  2.     # main loop
  3.     (lambda self, (socket, stdout, depth):
  4.         # cycle
  5.         (lambda (line, splitted_line, command, trailing):
  6.             stdout(line) ==
  7.             (
  8.                 # register
  9.                 command == '020' and socket.send('USER h h h h\r\nNICK oneliner\r\n')
  10.             )^(
  11.                 # rensponse to server pings
  12.                 command == 'PING' and socket.send('PONG'+line[4:])
  13.             )^(
  14.                 # join channels when invited
  15.                 command == 'INVITE'
  16.                 and socket.send('JOIN ' + trailing)
  17.             )^(
  18.                 # message stuff
  19.                 command == 'PRIVMSG'
  20.                 and ((
  21.                     # ping pong
  22.                     trailing.startswith('ping')
  23.                     and socket.send('PRIVMSG ' + splitted_line[2] + ' :pong'+trailing[4:])
  24.                 )^(
  25.                     trailing.startswith('!depth')
  26.                     and socket.send('PRIVMSG ' + splitted_line[2] + ' :Current recursion depth: ' + str(depth) + ' iterations\r\n')
  27.                 ))
  28.             )
  29.         )
  30.         # parse irc data
  31.         ((lambda string: (
  32.             string, # line
  33.             string.split(), # line.split()
  34.             string.split()[1] if string[0] == ':' else string.split()[0], # irc command
  35.             ' :'.join(string.split(' :')[1:])) # trailing, includes \r\n
  36.             )
  37.             (socket.recv(4096))
  38.         )
  39.         # loop again
  40.         ^self(self, (socket, stdout, depth + 1))
  41.     ),
  42.     # the irc socket, a print function and recursion depth
  43.     (__import__('socket').create_connection(('irc.inet.fi',6667)), __import__('sys').stdout.write, 1))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement