Advertisement
Guest User

gFG

a guest
Jul 31st, 2015
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.50 KB | None | 0 0
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. import urllib2
  4. print '[2015 Xat Bot] ~ =Perry' # Don't change this you greedy fuck.
  5. globals()['Developer'] = '420' # Don't change this you greedy fuck.
  6. globals()['Owners'] = [] # You can pre-append ids into here for ownering or use the !owner ID command.
  7. globals()['Verified'] = [] # You can pre-append ids into here for verifying or use the !verify ID command.
  8.  
  9. globals()['CommandHandler'] = '!' # This is the handler in which commands will be called from. I recommend "!", but whatever.
  10. globals()['Commands'] = ['say', 'yell', 'verify', 'owner', 'info'] # DON'T EDIT THESE. You'll fuck up the commands.
  11.  
  12. (globals()['Name'], globals()['Avatar'], globals()['Homepage']) = \
  13. ('pybot', '597', 'http://xat.com/dwbase') # Editable
  14. (globals()['WelcomeMessage'], globals()['TickleMessage']) = \
  15. ('Welcome to the chat.', 'Did you click me?') # Editable
  16. (globals()['VerifiedError'], globals()['OwnerError']) = \
  17. ('Sorry, you need to be [Verified] to use this command.',
  18. 'Sorry, you need to be an [Owner] to use this command.') # Editable
  19. (globals()['VerifiedMessage'], globals()['OwnerMessage']) = \
  20. ('You have been [Verified].', 'You are now an [Owner]') # Editable
  21.  
  22. globals()['NoFollow'] = True # Change to True to Enable or False to disable.
  23.  
  24. # Function to get the chat ID (Thanks to Miekl for giving me this url.)
  25.  
  26. Chat = raw_input('Chat:')
  27. Chat = urllib2.urlopen('http://xat.com/web_gear/chat/roomid.php?d='
  28. + Chat)
  29. Chat = Chat.read()
  30. globals()['Chat'] = Chat
  31.  
  32. # Function to grab the ID, etc. from Auser3.
  33.  
  34. Auser3DotPHP = urllib2.urlopen('http://xat.com/web_gear/chat/auser3.php'
  35. )
  36. Auser3DotPHP = Auser3DotPHP.read()
  37. Auser3DotPHP = Auser3DotPHP.split('&')
  38. (globals()['ID'], globals()['K1'], globals()['K2']) = \
  39. (Auser3DotPHP[1].split('=')[1], Auser3DotPHP[2].split('=')[1],
  40. Auser3DotPHP[3].split('=')[1])
  41.  
  42. import socket
  43. globals()['Sockets'] = []
  44. (globals()['Xat'], globals()['Bypass'], globals()['Authentication']) = \
  45. (socket.socket(), socket.socket(), socket.socket())
  46. (Sockets.append(Xat), Sockets.append(Bypass),
  47. Sockets.append(Authentication))
  48.  
  49. import json
  50. import random
  51. import xml.etree.ElementTree as xmlParse
  52.  
  53.  
  54. class Bot:
  55.  
  56. def __init__(self):
  57. Sockets[0].connect(('199.195.198.168', 10032))
  58. Handshake = "<y r=\"%s\" v=\"0\" m=\"1\" u=\"%s\" />\0" \
  59. % (Chat, ID)
  60. Sockets[0].send(Handshake)
  61. print 'Sent: ' + Handshake
  62. globals()['Attribs'] = \
  63. xmlParse.fromstring(Sockets[0].recv(1024).strip(chr(0))).attrib
  64. print 'Received: ' + str(Attribs)
  65. if 'i' not in Attribs:
  66. return False
  67. elif 'au' in Attribs and 'v' in Attribs:
  68.  
  69. # Credit to Astro for the bypass server.
  70.  
  71. Sockets[1].connect(('xat.space', 5000))
  72.  
  73. BypassValues = {
  74. 'i': Attribs['i'],
  75. 'v': Attribs['v'],
  76. 'au': Attribs['au'],
  77. 'p': Attribs['p'],
  78. }
  79. BypassValues = json.dumps(BypassValues)
  80.  
  81. Sockets[1].send(BypassValues)
  82. BypassValues = Sockets[1].recv(1024)
  83. BypassValues = json.loads(BypassValues)
  84.  
  85. Sockets[1].close()
  86. (self.l5, self.c) = (BypassValues['l5'], BypassValues['c'])
  87.  
  88. Sockets[2].connect(('199.195.198.168', 10032))
  89. Auth = "<ya u=\"%s\" k=\"%s\" c=\"%s\" r=\"%s\" />\0" \
  90. % (ID, Attribs['k'], self.c, Chat)
  91. Sockets[2].send(Auth)
  92. print 'Sent: ' + Auth
  93. Received = Sockets[2].recv(1024)
  94. print 'Received: ' + Received
  95. Sockets[2].close()
  96. else:
  97. Sockets[1].connect(('xat.space', 5000))
  98.  
  99. BypassValues = {'i': Attribs['i'], 'p': Attribs['p']}
  100. BypassValues = json.dumps(BypassValues)
  101.  
  102. Sockets[1].send(BypassValues)
  103. BypassValues = Sockets[1].recv(1024)
  104. BypassValues = json.loads(BypassValues)
  105.  
  106. Sockets[1].close()
  107. self.l5 = BypassValues['l5']
  108. (self.l4, self.l3, self.l2) = (str(random.randint(100, 500)),
  109. str(random.randint(100, 500)), 0)
  110. j2 = \
  111. "<j2 cb=\"%s\" Y=\"2\" l5=\"%s\" l4=\"%s\" l3=\"%s\" l2=\"%s\" y=\"%s\" k=\"%s\" k3=\"%s\" p=\"0\" c=\"%s\" f=\"0\" u=\"%s\" d0=\"0\" d2=\"1500007700\" n=\"%s\" a=\"%s\" h=\"%s\" v=\"0\" />\0" \
  112. % (
  113. Attribs['c'],
  114. self.l5,
  115. self.l4,
  116. self.l3,
  117. self.l2,
  118. Attribs['i'],
  119. K1,
  120. K2,
  121. Chat,
  122. ID,
  123. Name,
  124. Avatar,
  125. Homepage,
  126. )
  127. Sockets[0].send(j2)
  128. print 'Sent: ' + j2
  129. while Sockets[0]:
  130. try:
  131. Received = Sockets[0].recv(4500)
  132. if '<m' not in Received:
  133. print 'Received: ' + Received
  134. if '<logout' in Received:
  135. Sockets[0].close()
  136. Bot()
  137. else:
  138. if '<u' in Received:
  139. xml = xmlParse.fromstring(Received.strip('\0'))
  140. UserID = xml.attrib['u']
  141. self.PM(UserID, WelcomeMessage)
  142. if '<m' in Received:
  143. xml = xmlParse.fromstring(Received.strip('\0'))
  144. UserID = xml.attrib['u']
  145. UserIDNumber = UserID.split('_')
  146. UserIDNumber = UserIDNumber[0]
  147.  
  148. UserMessage = xml.attrib['t']
  149. Controller = UserMessage.split(' ', 1)
  150. Handler = Controller[0]
  151.  
  152. if 'RTypeOff' in UserMessage:
  153. pass
  154. elif 'RTypeOn' in UserMessage:
  155. pass
  156. elif '/u' in UserMessage:
  157. pass
  158. elif '/m' in UserMessage:
  159. pass
  160. elif '/s' in UserMessage:
  161. pass
  162. elif '/p' in UserMessage:
  163. pass
  164. elif '/d5' in UserMessage:
  165. pass
  166. elif '/d10' in UserMessage:
  167. pass
  168. elif '/d15' in UserMessage:
  169. pass
  170. else:
  171. print '[' + UserIDNumber + ']: ' \
  172. + UserMessage
  173. if Handler.lower() == CommandHandler \
  174. + Commands[0]:
  175. if UserIDNumber in Verified or UserIDNumber \
  176. in Owners or UserIDNumber in Developer:
  177. Message = Controller[1]
  178. self.Main(Message)
  179. else:
  180. self.PC(UserID, VerifiedError)
  181. if Handler.lower() == CommandHandler \
  182. + Commands[1]:
  183. if UserIDNumber in Verified or UserIDNumber \
  184. in Owners or UserIDNumber in Developer:
  185. Message = Controller[1]
  186. self.Main(Message.upper())
  187. else:
  188. self.PC(UserID, VerifiedError)
  189. if Handler.lower() == CommandHandler \
  190. + Commands[2]:
  191. if UserIDNumber in Owners or UserIDNumber \
  192. in Developer:
  193. Verified.append(Controller[1])
  194. self.PC(Controller[1], VerifiedMessage)
  195. else:
  196. self.PC(UserIDNumber, OwnerError)
  197. if Handler.lower() == CommandHandler \
  198. + Commands[3]:
  199. if UserIDNumber in Owners or UserIDNumber \
  200. in Developer:
  201. Owners.append(Controller[1])
  202. self.PC(Controller[1], OwnerMessage)
  203. else:
  204. self.PC(UserID, OwnerError)
  205. if Handler.lower() == CommandHandler \
  206. + Commands[4]:
  207. self.Main("I'm a xat bot coded in Python by Kondra."
  208. )
  209. if '<z' in Received:
  210. xml = xmlParse.fromstring(Received.strip('\0'))
  211. UserID = xml.attrib['u']
  212. if NoFollow:
  213. self.PM(UserID, '/a_NF')
  214. self.PM(UserIDNumber, TickleMessage)
  215. except:
  216. pass
  217.  
  218. def Main(self, Message):
  219. Sockets[0].send("<m u=\"%s\" t=\"%s\" />\0" % (ID, Message))
  220.  
  221. def PM(self, User, Message):
  222. Sockets[0].send("<z u=\"%s\" d=\"%s\" t=\"%s\" />\0" % (ID,
  223. User, Message))
  224.  
  225. def PC(self, User, Message):
  226. Sockets[0].send("<z u=\"%s\" d=\"%s\" t=\"%s\" s=\"2\" />\0"
  227. % (ID, User, Message))
  228.  
  229.  
  230. Bot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement