Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys, socket, os
- readbuffer = ''
- step = 0
- channel = '#admin'
- username = 'WordBot'
- password = 'password'
- server = 'irc.minecraft.co.nz'
- port = 6667
- connected = False
- words = ['justinbeiber','onedirection','corrin','corrinlakeland']
- def IRCUser(line):
- return line[0].split(':')[1].split('!')[0]
- s = socket.socket( socket.AF_INET, socket.SOCK_STREAM )
- print('Connecting to '+server+':'+bin(port))
- try:
- s.connect( (server,port) )
- s.send('NICK '+username+'\r\n')
- s.send('USER '+username+' '+username+' '+username+' :TTOBOT\r\n' )
- except:
- print('Failed to connect.', sys.exc_info() )
- running = 1
- while running:
- readbuffer = readbuffer + s.recv(1024)
- lines = readbuffer.split('\n')
- readbuffer = lines.pop()
- for line in lines:
- print(line)
- line = line.rstrip().split()
- if 'PING' in line: s.send('PONG '+line[1] +'\r\n')
- if '/MOTD' in line:
- s.send('JOIN '+channel+'\r\n')
- connected = 1
- print("Connected!")
- s.send('PRIVMSG '+channel+' Watching for these words:\r\n')
- for word in words:
- s.send('PRIVMSG '+channel+' '+word+'\r\n')
- if connected==0:
- s.send('JOIN '+channel+'\r\n')
- connected = 1
- print("Connected!")
- if connected:
- #s.send('PING');
- if (len(line) > 3):
- for section in line:
- section = section.lower().replace(":","")
- if section in words:
- if(IRCUser(line)!=username):
- s.send('PRIVMSG '+channel+' Kicking '+IRCUser(line)+ ' for saying '+section+'\r\n')
- s.send('KICK '+channel+" "+IRCUser(line)+' saying '+section+'\r\n')
- print("Kicked: "+IRCUser(line))
- if("pissoffbot" in line[3]):
- s.send('PRIVMSG '+channel+' OK. Cya later.\r\n')
- print("Quitting: "+IRCUser(line))
- running = 0
- if 'KICK' in line:
- connected = 0
- if '353'in line:
- s.send('PRIVMSG MineBot !login '+password+'\r\n')
- s.close()
- sys.exit()
Add Comment
Please, Sign In to add comment