Advertisement
Aha2Y

Python IRC parser o.o

Apr 4th, 2012
408
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1. ef parse(line):
  2.     line = line.lstrip(":")
  3.     temp = line.split(" :", 1)
  4.     data = []
  5.     data.extend(temp[0].split(" "))
  6.     try:
  7.         data.append(temp[1])
  8.     except IndexError:
  9.         pass
  10.     return data
  11.  
  12. def readline(sock):
  13.    global buffer
  14.    try:
  15.       buffer[sock]
  16.    except:
  17.       buffer[sock] = ""
  18.    while "\n" not in buffer[sock]:
  19.       new = sock.recv(2**12)
  20.       buffer[sock] += new
  21.       if len(new) == 0:
  22.          break
  23.    splt = buffer[sock].split("\n", 1)
  24.    try:
  25.       buffer[sock] = splt[1]
  26.    except:
  27.       buffer[sock] = ""
  28.    return splt[0].rstrip("\r\n")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement