02-04-2010, 06:21 PM
OK, I posted this on HF but no one liked it But I think I can get some honest views on how well the innovation and coding is here on SF. Thanks.
Code:
import random
import socket
import time
import os
os.system('clear')
#setting user input variables
server = raw_input(' Server: ')
port = raw_input(' Port: ')
channel = raw_input(' Channel: ')
nick = raw_input(' Nick: ')
user = raw_input(' User: ')
qcommand = raw_input(' Quit Command: ')
delay = raw_input('Command Delay: ')
if0 = raw_input(' If: ')
then0 = raw_input(' Then: ')
if1 = raw_input(' If: ')
then1 = raw_input(' Then: ')
if2 = raw_input(' If: ')
then2 = raw_input(' Then: ')
if3 = raw_input(' If: ')
then3 = raw_input(' Then: ')
if4 = raw_input(' If: ')
then4 = raw_input(' Then: ')
if5 = raw_input(' If: ')
then5 = raw_input(' Then: ')
if6 = raw_input(' If: ')
then6 = raw_input(' Then: ')
if7 = raw_input(' If: ')
then7 = raw_input(' Then: ')
if8 = raw_input(' If: ')
then8 = raw_input(' Then: ')
if9 = raw_input(' If: ')
then9 = raw_input(' Then: ')
os.system('clear')
#calling user input variables and placing syntax error messages for empty strings
(server)
if ((server) == ('')):
print('. . .did not specify \'Server\'')
os.close(0)
(port)
if ((port) == ('')):
print('. . .did not specify \'Port\'')
os.close(0)
(channel)
if ((channel) == ('')):
print('. . .did not specify \'Channel\'')
os.close(0)
(nick)
if ((nick) == ('')):
print('. . .did not specify \'Nick\'')
os.close(0)
(user)
if ((user) == ('')):
print('. . .did not specify \'User\'')
os.close(0)
(qcommand)
if ((qcommand) == ('')):
print('. . .did not specify \'Quit Command\'')
os.close(0)
(delay)
if ((delay) == ('')):
print('. . .did not specify \'Command Delay\'')
os.close(0)
(if0)
if ((if0) is ('')):
print('. . .did not specify \'If\'')
os.close(0)
(then0)
if ((then0) is ('')):
print('. . .did not specify \'Then\'')
os.close(0)
(if1)
if ((if1) is ('')):
print('. . .did not specify \'If\'')
os.close(0)
(then1)
if ((then1) is ('')):
print('. . .did not specify \'Then\'')
os.close(0)
(if2)
if ((if2) is ('')):
print('. . .did not specify \'If\'')
os.close(0)
(then2)
if ((then2) is ('')):
print('. . .did not specify \'Then\'')
os.close(0)
(if3)
if ((if3) is ('')):
print('. . .did not specify \'If\'')
os.close(0)
(then3)
if ((then3) is ('')):
print('. . .did not specify \'Then\'')
os.close(0)
(if4)
if ((if4) is ('')):
print('. . .did not specify \'If\'')
os.close(0)
(then4)
if ((then4) is ('')):
print('. . .did not specify \'Then\'')
os.close(0)
(if5)
if ((if5) is ('')):
print('. . .did not specify \'If\'')
os.close(0)
(then5)
if ((then5) is ('')):
print('. . .did not specify \'Then\'')
os.close(0)
(if6)
if ((if6) is ('')):
print('. . .did not specify \'If\'')
os.close(0)
(then6)
if ((then6) is ('')):
print('. . .did not specify \'Then\'')
os.close(0)
(if7)
if ((if7) is ('')):
print('. . .did not specify \'If\'')
os.close(0)
(then7)
if ((then7) is ('')):
print('. . .did not specify \'Then\'')
os.close(0)
(if8)
if ((if8) is ('')):
print('. . .did not specify \'If\'')
os.close(0)
(then8)
if ((then8) is ('')):
print('. . .did not specify \'Then\'')
os.close(0)
(if9)
if ((if9) is ('')):
print('. . .did not specify \'If\'')
os.close(0)
(then9)
if ((if9) is ('')):
print('. . .did not specify \'Then\'')
os.close(0)
#setting strings to integers so they can be called in the time.sleep() and port number
n = int(port)
d = int(delay)
irc = socket.socket ( socket.AF_INET, socket.SOCK_STREAM )
#added feature displaying the (if[x]) variables set by the user
print('Captured words are:')
print(if0)
print(if1)
print(if2)
print(if3)
print(if4)
print(if5)
print(if6)
print(if7)
print(if8)
print(if9)
print('In order to view the selected words, type: !vifs')
print('In order to view statements, type: !vthens')
time.sleep(15)
#actual connection to the IRC server with specified options set by the user input
irc.connect ( ( server, n ) )
print irc.recv ( 4096 )
irc.send ( 'NICK '+(nick)+'\r\n' )
irc.send ( 'USER '+(user)+' :Python IRC\r\n' )
irc.send ( 'JOIN '+(channel)+'\r\n' )
while True:
data = irc.recv ( 4096 )
#the actual implementation of the (then[x]) and (if[x]) variables
if data.find ( 'PING' ) != -1:
irc.send ( 'PONG ' + data.split() [ 1 ] + '\r\n' )
if data.find (qcommand) != -1:
irc.send ( 'QUIT\r\n' )
if data.find (if0) != -1:
time.sleep(d)
irc.send ( 'PRIVMSG '+channel+' : '+(then0)+'\r\n' )
if data.find (if1) != -1:
time.sleep(d)
irc.send ( 'PRIVMSG '+channel+' : '+(then1)+'\r\n' )
if data.find (if2) != -1:
time.sleep(d)
irc.send ( 'PRIVMSG '+channel+' : '+(then2)+'\r\n' )
if data.find (if3) != -1:
time.sleep(d)
irc.send ( 'PRIVMSG '+channel+' : '+(then3)+'\r\n' )
if data.find (if4) != -1:
time.sleep(d)
irc.send ( 'PRIVMSG '+channel+' : '+(then4)+'\r\n' )
if data.find (if5) != -1:
time.sleep(d)
irc.send ( 'PRIVMSG '+channel+' : '+(then5)+'\r\n' )
if data.find (if6) != -1:
time.sleep(d)
irc.send ( 'PRIVMSG '+channel+' : '+(then6)+'\r\n' )
if data.find (if7) != -1:
time.sleep(d)
irc.send ( 'PRIVMSG '+channel+' : '+(then7)+'\r\n' )
if data.find (if8) != -1:
time.sleep(d)
irc.send ( 'PRIVMSG '+channel+' : '+(then8)+'\r\n' )
if data.find (if9) != -1:
time.sleep(d)
irc.send ( 'PRIVMSG '+channel+' : '+(then9)+'\r\n' )
if data.find (':!vthens') != -1:
irc.send ( 'PRIVMSG '+nick+' : Selected statements are: '+(then0)+''+(then1)+'['+(then2)+'] ['+(then3)+'] ['+(then4)+'] ['+(then5)+'] ['+(then6)+'] ['+(then7)+'] ['+(then8)+'] ['+(then9)+']\r\n' )
if data.find (':!vifs') != -1:
time.sleep(d)
irc.send ( 'PRIVMSG '+nick+' : ['+(if1)+'] ['+(if2)+'] ['+(if3)+'] ['+(if4)+'] ['+(if5)+'] ['+(if6)+'] ['+(if7)+'] ['+(if8)+'] ['+(if9)+']\r\n' )
print data
Do what thou wilt shall be the whole of the Law. Love is the law, love under will.
.::The Rights of Man::.
.::The Rights of Man::.