archive

- Random tools & helpful resources for IRC
git clone git://git.acid.vegas/archive.git
Log | Files | Refs | Archive

spiderweb.py (1628B)

      1 #!/usr/bin/env python
      2 # SpiderWeb IRC Bot - Developed by acidvegas in Python (https://acid.vegas/trollbots)
      3 
      4 '''
      5 This bot requires network operator privledges in order to use the SAJOIN command.
      6 The bot will idle in the #spiderweb channel. Anyone leaving the channel will be force joined back.
      7 '''
      8 
      9 import socket
     10 import ssl
     11 import time
     12 
     13 nickserv_password='CHANGEME'
     14 operator_password='CHANGEME'
     15 
     16 def raw(msg):
     17 	sock.send(bytes(msg + '\r\n', 'utf-8'))
     18 
     19 while True:
     20 	try:
     21 		sock = ssl.wrap_socket(socket.socket(socket.AF_INET, socket.SOCK_STREAM))
     22 		sock.connect(('localhost', 6697))
     23 		raw(f'USER spider 0 * :CAUGHT IN THE WEB')
     24 		raw('NICK spider')
     25 		while True:
     26 			try:
     27 				data = sock.recv(1024).decode('utf-8')
     28 				for line in (line for line in data.split('\r\n') if len(line.split()) >= 2):
     29 					print('{0} | [~] - {1}'.format(time.strftime('%I:%M:%S'), line))
     30 					args=line.split()
     31 					if line.startswith('ERROR :Closing Link:'):
     32 						raise Exception('Connection has closed.')
     33 					elif args[0] == 'PING':
     34 						raw('PONG ' + args[1][1:])
     35 					elif args[1] == '001':
     36 						raw('MODE spider +BDd')
     37 						raw('PRIVMSG NickServ IDENTIFY spider ' + nickserv_password)
     38 						raw('OPER spider ' + operator_password)
     39 						raw('JOIN #spiderweb')
     40 					elif args[1] == 'PART' and len(args) >= 3:
     41 						if args[2]=='#spiderweb':
     42 							nick = args[0].split('!')[0][1:]
     43 							raw(f'SAJOIN {nick} #spiderweb')
     44 							raw(f'PRIVMSG #spiderweb :HA HA HA! IM A BIG ASSHOLE SPIDER AND {nick} IS CAUGHT IN MY SPIDER WEB!!!')
     45 			except (UnicodeDecodeError, UnicodeEncodeError):
     46 				pass
     47 	except:
     48 		sock.close()
     49 	finally:
     50 		time.sleep(15)