#!/usr/bin/env python
# Orpheus, Ynori7, RedSara

import sys
import socket
import ssl
import time


NICK='...'
IDENT='...'
REALNAME='...'
CHAN='#...'
PASSWORD='...'
data=""
start= 'start to connect'
connected = 'connection estblished'

# LOGIN IRC CHAT

print start
s=socket.socket ( socket.AF_INET, socket.SOCK_STREAM )
s.connect ( ( 'irc.psych0tik.net', 6697 ) )
ircsock=ssl.wrap_socket( s )
ircsock.send ( "USER %s %s %s :%s\r\n" %(NICK, IDENT, REALNAME, NICK ) )
ircsock.send ( "NICK %s\r\n" % NICK )
print connected
 
while True:
    # STAY CONNECTED
    data = ircsock.recv ( 4096 )
    if data.find ( 'PING' ) != -1:
       ircsock.send ( 'PONG ' + data.split() [ 1 ] + '\r\n' )
       # JOIN CHANNEL and IDENTIFY PASSWORD
    if data.find ( '001' ) != -1:
       ircsock.send ( "JOIN %s\r\n" % CHAN )
       ircsock.send ( 'PRIVMSG NickServ : IDENTIFY %s\r\n' % PASSWORD )
    if data.find ( 'KICK' ) != -1:
       ircsock.send ( 'JOIN %s\r\n' % CHAN )
    print data