Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import socket, ssl, sys
- def irc_command(sock, command):
- sock.send(command)
- bot_buffer = ''
- commands = ['PONG', 'JOIN', 'PART', 'PRIVMSG', 'WHO', 'QUIT']
- bot_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- if len(sys.argv) == 11:
- if sys.argv[1] == '-server' and sys.argv[3] == '-port' and sys.argv[5] == '-nick' and sys.argv[7] == '-pass' and sys.argv[9] == '-user':
- bot_sock.connect((sys.argv[2], int(sys.argv[4])))
- elif len(sys.argv) == 12:
- if sys.argv[1] == '-server' and sys.argv[3] == '-port' and sys.argv[5] == '-nick' and sys.argv[7] == '-pass' and sys.argv[9] == '-user' and sys.argv[11] == '-ssl':
- bot_sock = ssl.wrap_socket(bot_sock)
- bot_sock.connect((sys.argv[2], int(sys.argv[4])))
- server = sys.argv[2]
- port = int(sys.argv[4])
- nick = sys.argv[6]
- password = sys.argv[8]
- username = sys.argv[10] + ' BOT FOR IRC'
- irc_command(bot_sock, 'PASS ' + password)
- irc_command(bot_sock, 'NICK ' + nick)
- irc_command(bot_sock, 'USER ' + username)
- bot_buffer = bot_sock.recv(65565)
- if bot_buffer.count('PING') > 0:
- irc_command(bot_sock, commands[0] + ' ' + bot_buffer[bot_buffer.find('PING') : '\n'])
- print bot_buffer
- bot_buffer = ''
- first_channel = raw_input('enter the first channel to join to:\n')
- irc_command(bot_sock, commands[1] + ' ' + first_channel)
- while 1:
- bot_buffer = bot_sock.recv(65565)
- if bot_buffer.count('PING') > 0:
- irc_command(bot_sock, commands[0] + ' ' + bot_buffer[bot_buffer.find('PING'):])
- bot_buffer = ''
- bot_sock.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement