Advertisement
Guest User

Botz

a guest
Sep 16th, 2018
748
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.31 KB | None | 0 0
  1. Bots made by nucleardom, vouch if u like
  2.  
  3. 2to3 Botz.py,import json, pycurl, io, os, hashlib, re, urllib
  4.  
  5. from StringIO import StringIO
  6. from bs4 import BeautifulSoup
  7. from datetime import date
  8.  
  9. class RoPy:
  10. __location__ = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__)))
  11. strCookieJar = 'cookies'
  12. currentUser = ''
  13. boolDebug = False
  14.  
  15. def Debug(self, d1, d2):
  16. if d1 is not 3:
  17. print '[{0}]: {1}'.format(d1, d2)
  18.  
  19. def GetCountry(self, strCountry):
  20. try:
  21. arrList = json.loads(open(os.path.join(__location__, 'countries.json'), 'r').readline())
  22.  
  23. return arrList[strCountry]
  24. except:
  25. return 1
  26.  
  27. def GetPrivacySetting(self, strType, intID):
  28. try:
  29. arrList = json.loads(open(os.path.join(__location__, 'privacy.json'), 'r').readline())
  30.  
  31. return arrList[strType][intID]
  32. except:
  33. return False
  34.  
  35. def GetGenreSetting(self, strType):
  36. try:
  37. arrList = json.loads(open(os.path.join(__location__, 'genre.json'), 'r').readline())
  38.  
  39. return arrList[strType]
  40. except:
  41. return 1
  42.  
  43. def GetGender(self, strGender):
  44. if strGender.upper() == "FEMALE":
  45. return 3
  46.  
  47. return 2
  48.  
  49. def GetLanguage(self, strLanguage):
  50. if strLanguage.upper() == 'GERMAN':
  51. return 3
  52.  
  53. return 1
  54.  
  55. def RemoveCookie(self, strUser):
  56. try:
  57. os.remove(os.path.join(self.__location__, self.strCookieJar, hashlib.md5(strUser).hexdigest()))
  58. except:
  59. return False
  60.  
  61. def GetCookie(self, strUser):
  62. try:
  63. return os.path.join(self.__location__, self.strCookieJar, hashlib.md5(strUser).hexdigest())
  64. except:
  65. return False
  66.  
  67. def GetToken(self, strToken):
  68. if strToken == 'VERIFICATION':
  69. m = re.search('\<input name="__RequestVerificationToken" type="hidden" value="(.*?)"', self.NetworkRequest('https://m.roblox.com/home', None, True))
  70. elif strToken == 'CSRF':
  71. m = re.search("Roblox\.XsrfToken\.setToken\('(.*?)'\)", self.NetworkRequest('http://www.roblox.com/home', None, True))
  72. else:
  73. m = re.search('\<input type="hidden" name="'+strToken+'" id="'+strToken+'" value="(.*?)"' , cachedPage)
  74.  
  75. try:
  76. return m.group(1)
  77. except:
  78. return False
  79.  
  80. def NetworkRequest(self, strURL, arrData = None, boolCookie = False, strToken = None):
  81. buffer = StringIO()
  82. c = pycurl.Curl()
  83.  
  84. c.setopt(c.URL, strURL)
  85. c.setopt(c.REFERER, strURL)
  86. c.setopt(c.USERAGENT, 'Googlebot/2.1')
  87. c.setopt(c.SSL_VERIFYPEER, False)
  88. c.setopt(c.FOLLOWLOCATION, True)
  89.  
  90. if self.boolDebug is True:
  91. c.setopt(c.DEBUGFUNCTION, self.Debug)
  92. c.setopt(c.VERBOSE, 1)
  93.  
  94. if arrData is not None:
  95. c.setopt(c.POSTFIELDS, urllib.urlencode(arrData))
  96.  
  97. if boolCookie is True:
  98. c.setopt(c.COOKIEFILE, self.GetCookie(self.currentUser))
  99. c.setopt(c.COOKIEJAR, self.GetCookie(self.currentUser))
  100.  
  101. if strToken is not None:
  102. c.setopt(c.HTTPHEADER, ['Connection: keep-alive', 'X-CSRF-TOKEN: ' + strToken, 'X-Requested-With: XMLHttpRequest',])
  103.  
  104. c.setopt(c.WRITEDATA, buffer)
  105. c.perform()
  106. c.close()
  107.  
  108. return buffer.getvalue()
  109.  
  110. #
  111. # User API
  112. #
  113.  
  114. def GetUserID(self, strName):
  115. try:
  116. return json.loads(self.NetworkRequest('http://api.roblox.com/users/get-by-username?username=' + strName))['Id']
  117. except:
  118. return False
  119.  
  120. def GetUsername(self, intID):
  121. try:
  122. return json.loads(self.NetworkRequest('http://api.roblox.com/users/' + `intID`))['Username']
  123. except:
  124. return False
  125.  
  126. def GetUsernames(self, intID):
  127. try:
  128. soup = BeautifulSoup(self.NetworkRequest('http://www.roblox.com/users/' + `intID` + '/profile'), 'html.parser')
  129.  
  130. return [element['data-original-title'].split(',') for element in soup.find_all('span', {'data-toggle' : 'tooltip'})]
  131. except:
  132. return False
  133.  
  134. def GetUserAbout(self, intID):
  135. try:
  136. soup = BeautifulSoup(self.NetworkRequest('http://www.roblox.com/users/' + `intID` + '/profile'), 'html.parser')
  137.  
  138. return soup.find_all('span', {'class' : 'profile-about-content-text'})[0].text
  139. except:
  140. return False
  141.  
  142. def GetUserAge(self, intID):
  143. try:
  144. soup = BeautifulSoup(self.NetworkRequest('http://www.roblox.com/users/' + `intID` + '/profile'), 'html.parser')
  145.  
  146. return soup.find_all('p', {'class' : 'rbx-lead'})[0].text
  147. except:
  148. return False
  149.  
  150. def IsFollower(self, intID, intTarget):
  151. try:
  152. return True if 'true' in json.loads(self.NetworkRequest('http://api.roblox.com/user/following-exists?userId=' + `intID` + '&followerUserId=' + `intTarget`, None, True))['isFollowing'] else False
  153. except:
  154. return False
  155.  
  156. def IsFriend(self, intID, intTarget):
  157. try:
  158. return True if 'true' in self.NetworkRequest('http://www.roblox.com/Game/LuaWebService/HandleSocialRequest.ashx?method=IsFriendsWith&playerId=' + `intID` + '&userId=' + `intTarget`) else False
  159. except:
  160. return False
  161.  
  162. def GetUserPlaces(self, intID):
  163. try:
  164. return json.loads(self.NetworkRequest('http://www.roblox.com/Contests/Handlers/Showcases.ashx?userId=' + `intID`))['Showcase']
  165. except:
  166. return False
  167.  
  168. #
  169. # Group API
  170. #
  171.  
  172. def GetGroupInfo(self, intID):
  173. try:
  174. return json.loads(self.NetworkRequest('http://api.roblox.com/groups/' + `intID`))
  175. except:
  176. return False
  177.  
  178. def GetGroupOwner(self, intID):
  179. try:
  180. return json.loads(self.NetworkRequest('http://api.roblox.com/groups/' + `intID`))['Owner']['Id']
  181. except:
  182. return False
  183.  
  184. def GetGroupName(self, intID):
  185. try:
  186. return json.loads(self.NetworkRequest('http://api.roblox.com/groups/' + `intID`))['Name']
  187. except:
  188. return False
  189.  
  190. def GetGroupMemberCount(self, intID):
  191. try:
  192. soup = BeautifulSoup(self.NetworkRequest('http://www.roblox.com/Groups/group.aspx?gid=' + `intID`), 'html.parser')
  193.  
  194. return [element.text.replace('Members: ', '') for element in soup.find_all('div', {'id' : 'MemberCount'})]
  195. except:
  196. return False
  197.  
  198. def GetGroupDescription(self, intID):
  199. try:
  200. return json.loads(self.NetworkRequest('http://api.roblox.com/groups/' + `intID`))['Description']
  201. except:
  202. return False
  203.  
  204. def GetGroupImg(self, intID):
  205. try:
  206. return json.loads(self.NetworkRequest('http://api.roblox.com/groups/' + `intID`))['EmblemUrl']
  207. except:
  208. return False
  209.  
  210. def GetGroupEnemies(self, intID):
  211. try:
  212. return json.loads(self.NetworkRequest('http://api.roblox.com/groups/' + `intID` + '/enemies'))['Groups']
  213. except:
  214. return False
  215.  
  216. def GetGroupAllies(self, intID):
  217. try:
  218. return json.loads(self.NetworkRequest('http://api.roblox.com/groups/' + `intID` + '/allies'))['Groups']
  219. except:
  220. return False
  221.  
  222. def GetGroupRoles(self, intID):
  223. try:
  224. return json.loads(self.NetworkRequest('http://www.roblox.com/api/groups/' + `intID` + '/RoleSets'))
  225. except:
  226. return False
  227.  
  228. def IsInGroup(self, intID, intTarget):
  229. try:
  230. return json.loads(self.NetworkRequest('http://www.roblox.com/Game/LuaWebService/HandleSocialRequest.ashx?method=IsInGroup&playerid=' + `intTarget` + '&groupid=' + `intID`))
  231. except:
  232. return False
  233.  
  234. def GetUserRank(self, intID, intTarget):
  235. try:
  236. return json.loads(self.NetworkRequest('http://www.roblox.com/Game/LuaWebService/HandleSocialRequest.ashx?method=GetGroupRole&playerid=' + `intTarget` + '&groupid=' + `intID`))
  237. except:
  238. return False
  239.  
  240. def GetUserRankID(self, intID, intTarget):
  241. try:
  242. return json.loads(self.NetworkRequest('http://www.roblox.com/Game/LuaWebService/HandleSocialRequest.ashx?method=GetGroupRank&playerid=' + `intTarget` + '&groupid=' + `intID`))
  243. except:
  244. return False
  245.  
  246. def GetPrimaryGroup(self, strUser):
  247. try:
  248. return json.loads(self.NetworkRequest('http://www.roblox.com/Groups/GetPrimaryGroupInfo.ashx?users=' + strUser))
  249. except:
  250. return False
  251.  
  252. #
  253. # Auth API [User]
  254. #
  255.  
  256. def DoLogin(self, strPassword):
  257. try:
  258. return True if '<head><title>Object moved</title></head>' in self.NetworkRequest('https://m.roblox.com/login', {'UserName' : self.currentUser ,'Password' : strPassword, 'IdentificationCode': ''}, True) else False
  259. except:
  260. return False
  261.  
  262. # DOES NOT REMOVE & INVALIDATE COOKIE!
  263. def Logout(self):
  264. try:
  265. self.NetworkRequest('https://www.roblox.com/MobileAPI/Logout', {}, True)
  266. except:
  267. return False
  268.  
  269. def IsLoggedIn(self):
  270. try:
  271. if not 'null' in self.NetworkRequest('http://www.roblox.com/Game/GetCurrentUser.ashx', None, True):
  272. return True
  273.  
  274. self.RemoveCookie(self.currentUser)
  275. return False
  276. except:
  277. return False
  278.  
  279. def ModifyAccount(self, strPersonalBlurb, boolNewsletter, intBirthDay, intBirthMonth, intBirth intSocialNetworksVisibilityPrivacy, intPrivateMessagePrivacy, intPrivateServerInvitePrivacy, intFollowMePrivacy):
  280. try:
  281. return True if 'succ=true' in self.NetworkRequest('https://www.roblox.com/my/account/update', {'__RequestVerificationToken': self.GetToken('VERIFICATION'), 'ReceiveNewsletter': boolNewsletter, 'BirthDay': intBirthDay, 'BirthMonth': intBirthMonth, 'BirthYear': intBirthYear, 'Gender': GetGender(strGender), 'CountryId': GetCountry(strCountry), 'strLanguage': GetLanguage(strLanguage), 'YouTube': strYouTube, 'Twitch': strTwitch, 'SocialNetworksVisibilityPrivacy': GetPrivacySetting(intSocialNetworksVisibilityPrivacy), 'PrivateMessagePrivacy': GetPrivacySetting(intPrivateMessagePrivacy), 'PrivateServerInvitePrivacy': GetPrivacySetting(intPrivateServerInvitePrivacy), 'FollowMePrivacy': GetPrivacySetting(intFollowMePrivacy)},True) else False
  282. except:
  283. return False
  284.  
  285. def ChangePassword(self, strOldPassword, strNewPassword):
  286. try:
  287. return True if 'true' in self.NetworkRequest('https://www.roblox.com/account/changepassword', {'oldPassword': strOldPassword, 'newPassword': strNewPassword, 'confirmNewPassword': strNewPassword}, True, self.GetToken('CSRF')) else False
  288. except:
  289. return False
  290.  
  291. def GetUserFunds(self):
  292. try:
  293. return json.loads(self.NetworkRequest('http://api.roblox.com/my/balance', None, True))
  294. except:
  295. return False
  296.  
  297. def SetFeeling(self, strFeeling):
  298. try:
  299. return True if self.NetworkRequest('http://m.roblox.com/Account/SetStatus', {'__RequestVerificationToken': self.GetToken('VERIFICATION'), 'Status': strFeeling}, True) == 'true' else False
  300. except:
  301. return False
  302.  
  303. def SetPlaceState(self, intID, boolState):
  304. try:
  305. return True if 'true' in self.NetworkRequest('http://www.roblox.com/build/set-place-state?placeId=' + `intID` + '&active=' + `boolState`, None, True, self.GetToken('CSRF')) else False
  306. except:
  307. return False
  308.  
  309. def SendMessage(self, intID, strSubject, strContent):
  310. try:
  311. return True if 'Your message has been sent to' in self.NetworkRequest('http://m.roblox.com/messages/sendmessagework', {'__RequestVerificationToken': self.GetToken('VERIFICATION'), 'RecipientId': `intID`, 'Subject': strSubject, 'Body': strContent}, True) else False
  312. except:
  313. return False
  314.  
  315. def GetMessages(self, intPage, intPageSize):
  316. try:
  317. return json.loads(self.NetworkRequest('http://www.roblox.com/messages/api/get-messages?messageTab=0&pageNumber=' + `intPage` + '&pageSize=' + `intPageSize`, None, True))
  318. except:
  319. return False
  320.  
  321. def GetUnreadMessages(self):
  322. try:
  323. return json.loads(self.NetworkRequest('http://api.roblox.com/incoming-items/counts', None, True))['unreadMessageCount']
  324. except:
  325. return False
  326.  
  327. def SendFriendRequest(self, intID):
  328. try:
  329. return True if 'true' in self.NetworkRequest('http://www.roblox.com/friends/sendfriendrequest', {'targetUserId': `intID`}, True, self.GetToken('CSRF')) else False
  330. except:
  331. return False
  332.  
  333. def FollowUser(self, intID):
  334. try:
  335. return True if 'true' in self.NetworkRequest('http://www.roblox.com/user/follow', {'targetUserId': `intID`}, True, self.GetToken('CSRF')) else False
  336. except:
  337. return False
  338.  
  339. def UnfollowUser(self, intID):
  340. try:
  341. return True if 'true' in self.NetworkRequest('http://www.roblox.com/user/unfollow', {'targetUserId': `intID`}, True, self.GetToken('CSRF')) else False
  342. except:
  343. return False
  344.  
  345. def BlockUser(self, intID):
  346. try:
  347. return True if 'true' in self.NetworkRequest('http://www.roblox.com/userblock/blockuser', {'blockeeId': `intID`}, True, self.GetToken('CSRF')) else False
  348. except:
  349. return False
  350.  
  351. def UnblockUser(self, intID):
  352. try:
  353. return True if 'true' in self.NetworkRequest('http://www.roblox.com/userblock/unblockuser', {'blockeeId': `intID`}, True, self.GetToken('CSRF')) else False
  354. except:
  355. return False
  356.  
  357. #
  358. # Auth API [Group]
  359. #
  360.  
  361. def SetGroupShout(self, intID, strMessage):
  362. try:
  363. cache = self.NetworkRequest('http://www.roblox.com/My/Groups.aspx?gid=' + `intID`, None, True)
  364.  
  365. self.NetworkRequest('http://www.roblox.com/My/Groups.aspx?gid=' + `intID`, {'__RequestVerificationToken': self.GetToken('VERIFICATION', cache), '__VIEWSTATE': self.GetToken('__VIEWSTATE', cache), '__EVENTARGUMENT': self.GetToken('__EVENTARGUMENT', cache), '__EVENTVALIDATION': self.GetToken('__EVENTVALIDATION', cache), 'ctl00$cphRoblox$GroupStatusPane$StatusTextBox': strMessage, 'ctl00$cphRoblox$GroupStatusPane$StatusSubmitButton': 'Group Shout'}, True)
  366. except:
  367. return False
  368.  
  369. def SetGroupRole(self, intID, intTarget, strRole):
  370. try:
  371. if isinstance( strRole, (int, long) ):
  372. self.NetworkRequest('http://www.roblox.com/groups/api/change-member-rank?groupId=' + `group` + '&newRoleSetId=' + `strRole` + '&targetUserId=' + `intTarget`, None, True, self.GetToken('CSRF'))
  373. else:
  374. for arrRole in GetGroupRoles(intID):
  375. if arrRole['Name'] == strRole:
  376. self.NetworkRequest('http://www.roblox.com/groups/api/change-member-rank?groupId=' + `group` + '&newRoleSetId=' + `arrRole['ID']` + '&targetUserId=' + `intTarget`, None, True, self.GetToken('CSRF'))
  377. except:
  378. return False
  379.  
  380. def KickFromGroup(self, intID, intTarget):
  381. try:
  382. self.NetworkRequest('http://www.roblox.com/group/kick-from-clan', {'userIdToKick': `intTarget`,'groupId': `intID`, '__RequestVerificationToken': self.GetToken('VERIFICATION')}, True)
  383. except:
  384. return False
  385.  
  386. def LeaveGroup(self, intID):
  387. try:
  388. cache = self.NetworkRequest('http://www.roblox.com/My/Groups.aspx?gid=' + `intID`, None, True)
  389.  
  390. self.NetworkRequest('http://www.roblox.com/My/Groups.aspx?gid=' + `intID`, {'__RequestVerificationToken': self.GetToken('VERIFICATION', cache), '__VIEWSTATE': self.GetToken('__VIEWSTATE', cache), '__EVENTARGUMENT': self.GetToken('__EVENTARGUMENT', cache), '__EVENTVALIDATION': self.GetToken('__EVENTVALIDATION', cache), 'ctl00$cphRoblox$GroupStatusPane$LeaveButton': 'Leave Group'}, True)
  391. except:
  392. return False
  393.  
  394. def JoinGroup(self, intID):
  395. try:
  396. cache = self.NetworkRequest('http://www.roblox.com/Groups/Group.aspx?gid=' + `intID`, None, True)
  397.  
  398. self.NetworkRequest('http://www.roblox.com/My/Groups.aspx?gid=' + `intID`, {'__RequestVerificationToken': self.GetToken('VERIFICATION', cache), '__VIEWSTATE': self.GetToken('__VIEWSTATE', cache), '__EVENTARGUMENT': 'Click', '__EVENTTARGET': 'JoinGroupDiv', '__EVENTVALIDATION': self.GetToken('__EVENTVALIDATION', cache)}, True)
  399. except:
  400. return False
  401.  
  402. def MakePrimary(self, intID):
  403. try:
  404. cache = self.NetworkRequest('http://www.roblox.com/My/Group.aspx?gid=' + `intID`, None, True)
  405.  
  406. self.NetworkRequest('http://www.roblox.com/My/Groups.aspx?gid=' + `intID`, {'__RequestVerificationToken': self.GetToken('VERIFICATION', cache), '__VIEWSTATE': self.GetToken('__VIEWSTATE', cache), '__EVENTARGUMENT': self.GetToken('__EVENTARGUMENT', cache), '__EVENTVALIDATION': self.GetToken('__EVENTVALIDATION', cache), 'ctl00$cphRoblox$GroupStatusPane$MakePrimaryGroup': 'Make Primary'}, True)
  407. except:
  408. return False
  409.  
  410. def InviteToClan(self, intID, intTarget):
  411. try:
  412. cache = self.NetworkRequest('http://www.roblox.com/My/Groups.aspx?gid=' + `intID`, None, True)
  413.  
  414. return True if 'true' in self.NetworkRequest('http://www.roblox.com/group/invite-to-clan', {'userIdToInvite': `intTarget`, 'groupId': `intID`, '__RequestVerificationToken': self.GetToken('VERIFICATION', cache)}, True, self.GetToken('CSRF', cache)) else False
  415. except:
  416. return False
  417.  
  418. def CancelClanInvite(self, intID, intTarget):
  419. try:
  420. cache = self.NetworkRequest('http://www.roblox.com/My/Groups.aspx?gid=' + `intID`, None, True)
  421.  
  422. return True if 'true' in self.NetworkRequest('http://www.roblox.com/group/cancel-invitation', {'inviteeUserId': `intTarget`, 'groupId': `intID`, '__RequestVerificationToken': self.GetToken('VERIFICATION', cache)}, True, self.GetToken('CSRF', cache)) else False
  423. except:
  424. return False
  425.  
  426. def AcceptClanInvite(self, intID, boolAccept):
  427. try:
  428. cache = self.NetworkRequest('http://www.roblox.com/My/Groups.aspx?gid=' + `intID`, None, True)
  429.  
  430. return True if 'true' in self.NetworkRequest('http://www.roblox.com/group/accept-decline-clan-invitation', {'isAccepting': `boolAccept`, 'groupId': `intID`, '__RequestVerificationToken': self.GetToken('VERIFICATION', cache)}, True, self.GetToken('CSRF', cache)) else False
  431. except:
  432. return False
  433.  
  434. def KickFromClan(self, intID, intTarget):
  435. try:
  436. cache = self.NetworkRequest('http://www.roblox.com/My/Groups.aspx?gid=' + `intID`, None, True)
  437.  
  438. return True if 'true' in self.NetworkRequest('http://www.roblox.com/group/kick-from-clan', {'userIdToKick': `intTarget`, 'groupId': `intID`, '__RequestVerificationToken': self.GetToken('VERIFICATION', cache)}, True, self.GetToken('CSRF', cache)) else False
  439. except:
  440. return False
  441.  
  442. def LeaveClan(self, intID):
  443. try:
  444. cache = self.NetworkRequest('http://www.roblox.com/My/Groups.aspx?gid=' + `intID`, None, True)
  445.  
  446. return True if 'true' in self.NetworkRequest('http://www.roblox.com/group/leave-clan', {'groupId': `intID`, '__RequestVerificationToken': self.GetToken('VERIFICATION', cache)}, True, self.GetToken('CSRF', cache)) else False
  447. except:
  448. return False
  449.  
  450. #
  451. # Asset API
  452. #
  453.  
  454. def GetAsset(self, intID):
  455. try:
  456. return json.loads(self.NetworkRequest('http://api.roblox.com/Marketplace/ProductInfo?assetId=' + `intID`))
  457. except:
  458. return False
  459.  
  460. def BuyAsset(self, intID, intCurrency):
  461. try:
  462. arrData = self.GetAsset(intID)
  463. if arrData['IsPublicDomain'] is False:
  464. expectedCurrency = 1 if intCurrency == 1 and arrData['PriceInRobux'] is not 'null' else 2
  465. expectedPrice = arrData['PriceInRobux'] if intCurrency == 1 and arrData['PriceInRobux'] is not 'null' else arrData['PriceInTickets']
  466. self.NetworkRequest('http://www.roblox.com/API/Item.ashx?rqtype=purchase&productID=' + arrData['ProductId'] + '&expectedCurrency=' + `expectedCurrency` + '&expectedPrice=' + `expectedPrice` + '&expectedSellerID=' + `arrData['Creator']['Id']`, {}, True, self.GetToken('CSRF'))
  467. else:
  468. self.NetworkRequest('http://www.roblox.com/API/Item.ashx?rqtype=purchase&productID=' + arrData['ProductId'] + '&expectedCurrency=1&expectedPrice=0&expectedSellerID=' + arrData['Creator']['Id'], {}, True, self.GetToken('CSRF'))
  469. except:
  470. return False
  471.  
  472. def HasAsset(self, intUser, intID):
  473. try:
  474. return True if 'true' in self.NetworkRequest('http://api.roblox.com/Ownership/HasAsset?userId=' + `intUser` + '&assetId=' + `intID`) else False
  475. except:
  476. return False
  477.  
  478. def UpdateAsset(self, intID, strName, srtDesc, boolComments, intGenre, boolForSale, intRobux = 0, intTickets = 0):
  479. try:
  480. cache = self.NetworkRequest('http://www.roblox.com/My/Item.aspx?ID=' + `intID`, None, True)
  481.  
  482. if intRobux <= 0 or intTickets <= 0:
  483. self.NetworkRequest('http://www.roblox.com/My/Item.aspx?ID=' + `intID`, {'__EVENTTARGET': 'ctl00$cphRoblox$SubmitButtonTop', '__EVENTARGUMENT': '', '__VIEWSTATE': self.GetToken('VIEWSTATE', cache), '__EVENTVALIDATION': self.GetToken('EVENTVALIDATION', cache), 'ctl00$cphRoblox$NameTextBox': strName, 'ctl00$cphRoblox$DescriptionTextBox': srtDesc, 'ctl00$cphRoblox$EnableCommentsCheckBox': ('on' if boolComments == True else ''), 'GenreButtons2': self.GetGenreSetting(intGenre), 'ctl00$cphRoblox$actualGenreSelection': self.GetGenreSetting(intGenre), 'ctl00$cphRoblox$PublicDomainCheckBox': ('on' if boolForSale == True else '')}, True)
  484. else:
  485. self.NetworkRequest('http://www.roblox.com/My/Item.aspx?ID=' + `intID`, {'__EVENTTARGET': 'ctl00$cphRoblox$SubmitButtonTop', '__EVENTARGUMENT': '', '__VIEWSTATE': self.GetToken('VIEWSTATE', cache), '__EVENTVALIDATION': self.GetToken('EVENTVALIDATION', cache), 'ctl00$cphRoblox$NameTextBox': strName, 'ctl00$cphRoblox$DescriptionTextBox': srtDesc, 'ctl00$cphRoblox$EnableCommentsCheckBox': ('on' if boolComments == True else ''), 'GenreButtons2': self.GetGenreSetting(intGenre), 'ctl00$cphRoblox$actualGenreSelection': self.GetGenreSetting(intGenre), 'ctl00$cphRoblox$SellThisItemCheckBox': ('on' if boolForSale == True else ''), 'SellForRobux': ('on' if intRobux > 0 else ''), 'SellForTickets': 'on' if intTickets > 0 else None, 'RobuxPrice': `intRobux`, 'TicketsPrice': `intTickets`}, True)
  486. except:
  487. return False
  488.  
  489. def ToggleFavoriteAsset(self, intID):
  490. try:
  491. return True if 'True' in self.NetworkRequest('http://www.roblox.com/favorite/toggle', {'assetId' : `intID`}, True) else False
  492. except:
  493. return False
  494.  
  495. # NOTICE: this will only return true if the current user that is logged in has the asset favorited
  496. def IsAssetFavorited():
  497. try:
  498. soup = BeautifulSoup(self.NetworkRequest('http://www.roblox.com/games/' + `intID` + '/-'), 'html.parser')
  499.  
  500. return True if len(soup.find_all('span', {'class' : 'rbx-icon-favorite favorited'})) > 0 else False
  501. except:
  502. return False
  503.  
  504. def VoteAsset(self, intID, boolVote):
  505. try:
  506. self.NetworkRequest('http://www.roblox.com/voting/vote?assetId=' + `intID` + '&vote=' + `boolVote`, {}, True)
  507. except:
  508. return False
  509.  
  510. #
  511. # Misc API
  512. #
  513.  
  514. def RedeemPromocode(self, strCode):
  515. try:
  516. return True if 'true' in self.NetworkRequest('http://www.roblox.com/promocodes/redeem?code=' + strCode, {}, True) else False
  517. except:
  518. return False
  519.  
  520. #
  521. # Chat API
  522. #
  523.  
  524. currentConversation = None
  525. currentMessage = None
  526. currentMethod = None
  527.  
  528. # Gets all the conversations that were ever started
  529. def GetConversations(self, intPage = 1, intSize = 9999):
  530. try:
  531. return json.loads(self.NetworkRequest('https://chat.roblox.com/v1.0/get-user-conversations?pageNumber=' + `intPage` + '&pageSize=' + `intSize`, None, True))
  532. except:
  533. return False
  534.  
  535. # Gets the creator of the covnersation
  536. def GetInitiator(self):
  537. try:
  538. return self.currentConversation['InitiatorUser']['Id']
  539. except:
  540. return False
  541.  
  542. # Gets all the particpants in a chat, it also returns the current user
  543. def GetParticipants(self):
  544. try:
  545. arrResult = []
  546.  
  547. for Participant in self.currentConversation['ParticipantUsers']:
  548. arrResult.append(Participant['Id'])
  549.  
  550. return arrResult
  551. except:
  552. return False
  553.  
  554. # Returns the current's chat id
  555. def GetChatID(self):
  556. try:
  557. return self.currentConversation['Id']
  558. except:
  559. return False
  560.  
  561. # Checks if the chat is a groupchat (aka party)
  562. def IsGroupChat(self):
  563. try:
  564. return self.currentConversation['IsGroupChat']
  565. except:
  566. return False
  567.  
  568. def HasUnreadMessages(self):
  569. try:
  570. return self.currentConversation['HasUnreadMessages']
  571. except:
  572. return False
  573.  
  574. def GetChatMessages(self, intConversation, intSize = 9999):
  575. try:
  576. return json.loads(self.NetworkRequest('https://chat.roblox.com/v1.0/get-messages?conversationId=' + `intConversation` + '&pageSize=' + `intSize`, None, True))
  577. except:
  578. return False
  579.  
  580. def GetLastMessage(self, intConversation):
  581. try:
  582. return self.GetMessages(intConversation, 1)[0]
  583. except:
  584. return False
  585.  
  586. def GetMessageContent(self):
  587. try:
  588. return self.currentMessage['Content']
  589. except:
  590. return False
  591.  
  592. def GetMessageID(self):
  593. try:
  594. return self.currentMessage['Id']
  595. except:
  596. return False
  597.  
  598. def IsMessageRead(self):
  599. try:
  600. return self.currentMessage['Read']
  601. except:
  602. return False
  603.  
  604. def GetSender(self):
  605. try:
  606. return self.currentMessage['SenderUserId']
  607. except:
  608. return False
  609.  
  610. def GetDate(self):
  611. try:
  612. return self.currentMessage['Sent']
  613. except:
  614. return False
  615.  
  616. def StartConversation(self, intID):
  617. try:
  618. return json.loads(self.NetworkRequest('https://chat.roblox.com/v1.0/start-one-to-one-conversation', {'participantUserID': `intID`}, True, self.GetToken('CSRF')))['Conversation']
  619. except:
  620. return False
  621.  
  622. def IsSucces(self):
  623. try:
  624. return self.currentMethod['Succes']
  625. except:
  626. return False
  627.  
  628. def SendChatMessage(self, intConversation, strMessage):
  629. try:
  630. return json.loads(self.NetworkRequest('https://chat.roblox.com/v1.0/send-message', {'conversationId': `intConversation`, 'message': strMessage}, True, self.GetToken('CSRF')))
  631. except:
  632. return False
  633.  
  634. def GetSentID(self):
  635. try:
  636. return self.currentMethod['MessageId']
  637. except:
  638. return False
  639.  
  640. def GetUnreadCount(self):
  641. try:
  642. return self.NetworkRequest('https://chat.roblox.com/v1.0/get-unread-conversation-count', None, True)
  643. except:
  644. return False
  645.  
  646. def MarkAsRead(self, intConversation, intID):
  647. try:
  648. return json.loads(self.NetworkRequest('https://chat.roblox.com/v1.0/mark-as-read', {'conversationId': `intConversation`, 'endMessageId': `intID`}, True, self.GetToken('CSRF')))
  649. except:
  650. return False
  651.  
  652. def AddToConversation(self, intConversation, arrIDs):
  653. try:
  654. return True if 'true' in self.NetworkRequest('https://chat.roblox.com/v1.0/add-to-conversation', {'conversationId': `intConversation`, 'participantUserIds': arrIDs}, True, self.GetToken('CSRF')) else False
  655. except:
  656. return False
  657.  
  658. def RemoveFromConversation(self, intID):
  659. try:
  660. return True if 'true' in self.NetworkRequest('https://chat.roblox.com/v1.0/remove-from-conversation', {'conversationId': `intConversation`, 'participantUserIds': intID}, True, self.GetToken('CSRF')) else False
  661. except:
  662. return False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement