Advertisement
Guest User

Untitled

a guest
Sep 16th, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.49 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import socket, ssl, sys
  4.  
  5. def irc_command(sock, command):
  6.     sock.send(command)
  7. bot_buffer = ''
  8. commands = ['PONG', 'JOIN', 'PART', 'PRIVMSG', 'WHO', 'QUIT']
  9. bot_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  10. if len(sys.argv) == 11:
  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':
  12.         bot_sock.connect((sys.argv[2], int(sys.argv[4])))
  13. elif len(sys.argv) == 12:
  14.     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':
  15.         bot_sock = ssl.wrap_socket(bot_sock)
  16.         bot_sock.connect((sys.argv[2], int(sys.argv[4])))
  17. server = sys.argv[2]
  18. port = int(sys.argv[4])
  19. nick = sys.argv[6]
  20. password = sys.argv[8]
  21. username = sys.argv[10] + ' BOT FOR IRC'
  22. irc_command(bot_sock, 'PASS ' + password)
  23. irc_command(bot_sock, 'NICK ' + nick)
  24. irc_command(bot_sock, 'USER ' + username)
  25. bot_buffer = bot_sock.recv(65565)
  26. if bot_buffer.count('PING') > 0:
  27.     irc_command(bot_sock, commands[0] + ' ' + bot_buffer[bot_buffer.find('PING') : '\n'])
  28. print bot_buffer
  29. bot_buffer = ''
  30. first_channel = raw_input('enter the first channel to join to:\n')
  31. irc_command(bot_sock, commands[1] + ' ' + first_channel)
  32. while 1:
  33.     bot_buffer = bot_sock.recv(65565)
  34.     if bot_buffer.count('PING') > 0:
  35.         irc_command(bot_sock, commands[0] + ' ' + bot_buffer[bot_buffer.find('PING'):])
  36.     bot_buffer = ''
  37. bot_sock.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement