Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
BotGen
#1
OK, I posted this on HF but no one liked it Sad 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::.
Reply
#2
What does it do?
GamerCraft

Visit it, and tell me what you think. Tongue
Reply
#3
Works well, but I quite don't understand it... ;)
You have done something like this for word list...

Code:
def define_word(*args):
    for arg in args:
        print arg
Reply
#4
Looks nice and quite long to look over, just a suggestion,
Code:
server = raw_input('       Server: ')

You can make your pretty tabs with this:
Code:
server = raw_input('\tServer: ')
This will save you some time.
Looks like a fully functional program with error handling and all, I love the idea of it, great for those struggling with IRC bots.
[Image: izsyo6.jpg]


Reply
#5
(02-04-2010, 07:09 PM)uber1337 Wrote: Looks nice and quite long to look over, just a suggestion,
Code:
server = raw_input('       Server: ')

You can make your pretty tabs with this:
Code:
server = raw_input('\tServer: ')
This will save you some time.
Looks like a fully functional program with error handling and all, I love the idea of it, great for those struggling with IRC bots.
That helps a lot. Thanks for the suggestion. Oui But, they need to be centred not tabbed. Non
(02-04-2010, 06:45 PM)Master of The Universe Wrote: Works well, but I quite don't understand it... ;)
You have done something like this for word list...

Code:
def define_word(*args):
    for arg in args:
        print arg
Sorry. It creates a bot for folks who don't understand how to make them.

Quick note: User needs to be long, IDK why but it does; no one will see it. And nick is going to be your name on the IRC. And you need to specify all 10 statements or you'll get an error.
Do what thou wilt shall be the whole of the Law. Love is the law, love under will.
.::The Rights of Man::.
Reply
#6
http://www.supportforums.net/showthread.php?tid=4459

Might help.
[Image: nv70ad.png]
Terrorcore, unleash, extermination
Hyper real, cold blood, determination
fudge them, I like this sensation
Incredible, I from the annihilation
Reply
#7
Screeny and useage?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)