Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import socket
- from Tkinter import *
- network = 'irc.iz-smart.net'
- port = 6667
- channel = '#espadon1'
- irc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- irc.connect((network,port))
- irc.settimeout(0.1)
- irc.send('NICK Blume\r\n')
- irc.send('USER Blume Blume Blume : Baconmans Client\r\n')
- irc.send('JOIN ' + channel + '\r\n')
- irc.send('PRIVMSG ' + channel + 'Hi\r\n')
- irc.send('WHO ' + channel + '\r\n')
- def PONG(income):
- income = income.split(':')
- if income[0] == 'PING ':
- irc.send('PONG ' + income[1])
- print 'Blume >> PONG ' + income[1]
- def NICK(income):
- income = income.split()
- if income[1] == 'PRIVMSG':
- income = income[0].split('!')
- income = income[0].split(':')
- return income[1]
- def CLOSE(income):
- if NICK(income) == 'Baconman':
- income = income.split(':')
- if len(income) >= 2:
- print income[2]
- if income[2] == 'off\r\n':
- irc.send('QUIT\r\n')
- def COMMAND(income):
- income = income.split()
- if len(income) >= 2:
- if income[1] == 'PRIVMSG':
- return 'PRIVMSG'
- if income[1] == 'JOIN':
- return 'JOIN'
- if income[1] == 'PART':
- return 'PART'
- def MESSAGE(income):
- income = income.split(':', 2)
- return income[2]
- def SEND(event):
- msg = INPUT.get('1.0', END)
- INPUT.delete(1.0, END)
- irc.send('PRIVMSG ' + channel + ' ' + msg)
- text = ''
- root = Tk()
- IN = Text(root)
- IN.config(state = DISABLED)
- IN.pack()
- INPUT = Text(root)
- INPUT.bind('<Return>', SEND)
- INPUT.pack()
- Nicklist = Listbox(root)
- Nicklist.pack()
- while True:
- root.update()
- try:
- text = text + irc.recv(4096)
- except socket.error:
- text = ''
- if len(text) >= 3:
- if text[len(text) - 1] == '\n' and text[len(text) - 2] == '\r':
- lines = text.splitlines()
- for line in lines:
- print COMMAND(line)
- if COMMAND(text) == 'PRIVMSG':
- line = NICK(text) + ' >> ' + MESSAGE(text) + '\r'
- IN.insert(END, line)
- print repr(text)
- PONG(text)
- CLOSE(text)
- text = ''
Add Comment
Please, Sign In to add comment