Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import socket
- import time
- import random
- import linecache
- import re
- ###
- # I want this:
- # If you type: kill <VICTIM> then it read random lines randomly (time .. um 3-6 seconds) until you say: "BOTNAME: stop!"
- ###
- ###
- HOST = "irc.gyaloglo.hu"
- PORT = 6667
- NICK = "VINCSENZO"
- PASS = "sziszi"
- USERNAME = "VINCSENZO"
- REALNAME = "VINCSENZO"
- CHAN = "#Afro_C"
- ###
- def randomLine(filename):
- fh = open(filename, "r")
- lineNum = 0
- it = ''
- while 1:
- aLine = fh.readline()
- lineNum = lineNum + 1
- if aLine != "":
- if random.uniform(0,lineNum)<1:
- it = aLine
- else:
- break
- fh.close()
- return it
- def countLine(filename):
- with open(filename) as f:
- for i, l in enumerate(f):
- pass
- return i + 1
- irc = socket.socket ( )
- irc.connect ( ( HOST, PORT ) )
- irc.send ( "NICK %s\r\n" % NICK )
- irc.send ( "USER %s %s %s :%s\r\n" % ( USERNAME, HOST, NICK, REALNAME ) )
- irc.send ( "PASS %s\r\n" % PASS )
- time.sleep( 5 )
- irc.send ( "JOIN %s\r\n" % CHAN )
- while True:
- data = irc.recv ( 4096 )
- IRC_NICK = str(data).split ( '!' ) [ 0 ] . split ( ":")[1]
- IRC_NICK = re.sub("_", " ", IRC_NICK)
- if data.find ( 'PING' ) != -1:
- irc.send ( 'PONG ' + data.split() [ 1 ] + '\r\n' )
- if data.find ( 'kcsg' ) != -1:
- irc.send ( "PRIVMSG %s :%s: %s\r\n" % ( CHAN, IRC_NICK, linecache.getline( 'test.txt', random.randint( 1, countLine( 'test.txt' ) ) ) ) )
- if data.find ( 'proba' ) != -1:
- irc.send ( "PRIVMSG #Afro_C :%s\r\n" % IRC_NICK )
- print data
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement