Guest User

ANY HELP SCRIPTING THIS??

a guest
Dec 28th, 2015
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.91 KB | None | 0 0
  1. CAN ANYONE HELP ME DO THIS?
  2.  
  3.  
  4. --[[
  5. IF YOU DONT KNOW HOW TO SCRIPT GET OUT YOU WONT KNOW HOW TO USE THIS!
  6. When something returns a table try running a recruisive loop to see what is inside the table
  7. If Private board then follow this
  8. -Instructions
  9. 1. Go to this link and click allow: https://trello.com/1/authorize?key=aded73d328dce4a0698a6744856b3326&name=Roblox+Api&expiration=never&response_type=token&scope=read,write
  10. 2. Copy the random numbers and letters in the page sent to you
  11. 3. Paste the random numbers and letters in the Value of Token
  12. 4. If anywhere an error occurs when in use with "Unauthorized" you didnt copy the full link!
  13. -Functions
  14. --------------
  15. GetBoardID([Board Name]) return Board ID
  16. --------------
  17. GetListID([List Name],[Board ID]) return List ID
  18. --------------
  19. GetCardID([Name],[Board ID]) returns Card ID
  20. --------------
  21. GetBoardInfo([Board ID]) returns a table like this except not JSON
  22. {
  23. "id": "4eea4ffc91e31d1746000046",
  24. "name": "Example Board",
  25. "desc": "This board is used in the API examples",
  26. "lists": [{
  27. "id": "4eea4ffc91e31d174600004a",
  28. "name": "To Do Soon"
  29. }, {
  30. "id": "4eea4ffc91e31d174600004b",
  31. "name": "Doing"
  32. }, {
  33. "id": "4eea4ffc91e31d174600004c",
  34. "name": "Done"
  35. }]
  36. }
  37. --------------
  38. GetCardInfo([Card ID],[Board ID]) returns an table
  39. -----------
  40. GetLists([Board ID]) returns a table
  41. ------------
  42. AddCard([Name],[Decription],[List ID],Optional[AddUrl],Optional[Position **Valid Values: A position. top, bottom, or a positive number.**],Optional[Due*Default=null*],Optional[Label**Valid Values: all or a comma-separated list of: blue,green,orange,purple,red,yellow**],Optional[CardToCopyID]) returns a Table
  43. ------------
  44. AddList([Name],[Board ID],Optional[List to Copy],Optional[Position *Valid Values: position. top, bottom, or a positive number.*])
  45. ------------
  46. AddBoard([Name],[Description])
  47. ------------
  48. *DEPRICATED*AddLabelName([Board ID],[Name],[Color]) WILL BE REMOVED
  49. ------------
  50. AddCardAtt([Card ID],[Name],[File,URL],[Value])
  51. ------------
  52. AddLabel([Name],[Color],[Board ID]) returns Label ID
  53. ------------
  54. AddCardLabel([Card ID],[Label ID])
  55. ------------
  56. GetLabels([Board ID]) returns a table such as bellow except not in JSON
  57. [
  58. {"id":"559adc5e19ad3a5dc2b9c003","idBoard":"559adc5e9ad91e64b569a4d9","name":"","color":"green","uses":0},
  59. {"id":"559adc5e19ad3a5dc2b9c004","idBoard":"559adc5e9ad91e64b569a4d9","name":"","color":"yellow","uses":0},
  60. {"id":"559adc5e19ad3a5dc2b9c006","idBoard":"559adc5e9ad91e64b569a4d9","name":"","color":"red","uses":0},
  61. {"id":"559adc5e19ad3a5dc2b9c007","idBoard":"559adc5e9ad91e64b569a4d9","name":"","color":"purple","uses":0},
  62. {"id":"559adc5e19ad3a5dc2b9c008","idBoard":"559adc5e9ad91e64b569a4d9","name":"","color":"blue","uses":0},
  63. ]
  64. ------------
  65. GetCardsInList([List ID]) returns a table containing the cards tables
  66. ------------
  67. PostComment([Card ID],Text)
  68. ------------
  69. AddCheckList()
  70. ------------
  71. GetLabelID(LabelName,BoardID) OUCH MY BACK!
  72. ]]--
  73. local Private=true
  74. local addon
  75. local HS=game:GetService("HttpService")
  76. local IS=game:GetService("InsertService")
  77. local T = {}
  78. function getAddon()
  79. if script.Token.Value~="77241781bfa741a94e0fad58e9be275c26304391ca0b0e12d885e027ce4be9d3" then
  80. addon="?key=aded73d328dce4a0698a6744856b3326&token="..script.Token.Value
  81. else
  82. error([[-Instructions
  83. \n 1. Go to this link and click allow: https://trello.com/1/authorize?key=aded73d328dce4a0698a6744856b3326&name=Roblox+Api&expiration=30days&response_type=token&scope=read,write
  84. \n 2. Copy the token in the page sent to you
  85. \n 3. Paste the token in the Value of Token]])
  86. end
  87. end
  88. --[[
  89. POST /1/cards/[card id or shortlink]/actions/comments
  90. Required permissions: comments
  91. Arguments
  92. text (required)
  93. Valid Values: a string with a length from 1 to 16384
  94. --]]
  95. function T:PostComment(cid,t)
  96. local url
  97. if Private then
  98. getAddon()
  99. url="https://api.trello.com/1/cards/"..tostring(cid).."/actions/comments"..addon
  100. else
  101. url="https://api.trello.com/1/cards/"..tostring(cid).."/actions/comments"..addon
  102. end
  103. local dat={
  104. text=t
  105. }
  106. local data=HS:JSONEncode(dat)
  107. local re=HS:PostAsync(url,data)
  108. local red=HS:JSONDecode(re)
  109. return red
  110. end
  111. --/1/lists/[idList]/cards
  112. --[[
  113. [{
  114. "id": "4eea503791e31d1746000080",
  115. "checkItemStates": [],
  116. "closed": false,
  117. "dateLastActivity": "2011-12-15T19:53:27.228Z",
  118. "desc": "",
  119. "descData": null,
  120. "email": null,
  121. "idAttachmentCover": null,
  122. "idBoard": "4eea4ffc91e31d1746000046",
  123. "idLabels": [],
  124. "idList": "4eea4ffc91e31d174600004a",
  125. "idMembersVoted": [],
  126. "idShort": 3,
  127. "manualCoverAttachment": false,
  128. "name": "Finish my awesome application",
  129. "pos": 65536,
  130. "shortLink": "XlG8S7ll",
  131. "badges": {
  132. "votes": 0,
  133. "viewingMemberVoted": false,
  134. "subscribed": false,
  135. "fogbugz": "",
  136. "checkItems": 0,
  137. "checkItemsChecked": 0,
  138. "comments": 0,
  139. "attachments": 0,
  140. "description": false,
  141. "due": null
  142. },
  143. "due": null,
  144. "idChecklists": [],
  145. "idMembers": [],
  146. "labels": [],
  147. "shortUrl": "https://trello.com/c/XlG8S7ll",
  148. "subscribed": false,
  149. "url": "https://trello.com/c/XlG8S7ll/3-finish-my-awesome-application"
  150. }]
  151. --]]
  152. function T:GetCardsInList(lid)
  153. local url
  154. if Private then
  155. getAddon()
  156. url="https://api.trello.com/1/lists/"..tostring(lid).."/cards"..addon
  157. else
  158. getAddon()
  159. url="https://api.trello.com/1/lists/"..tostring(lid).."/cards"..addon
  160. end
  161. local re=HS:GetAsync(url,true)
  162. local dat=HS:JSONDecode(re)
  163. return dat
  164. end
  165. --[[
  166. POST /1/labels
  167. Required permissions: write
  168. Arguments
  169. name (required)
  170. Valid Values: a string with a length from 0 to 16384
  171. color (required)
  172. Valid Values: A valid label color or null
  173. idBoard (required)
  174. Valid Values: An id
  175. --]]
  176. function T:AddLabel(nae,col,boardid)
  177. local url
  178. if Private then
  179. getAddon()
  180. url="https://api.trello.com/1/labels"..addon
  181. else
  182. url="https://api.trello.com/1/labels"..addon
  183. end
  184. local dat={
  185. name=nae,
  186. color=col,
  187. idBoard=boardid
  188. }
  189. local data=HS:JSONEncode(dat)
  190. local re=HS:PostAsync(url,data)
  191. --print(re)
  192. return (HS:JSONDecode(re)).id
  193. end
  194. --[[
  195. POST /1/cards/[card id or shortlink]/idLabels
  196. Required permissions: write
  197. Arguments
  198. value (required)
  199. Valid Values: The id of the label to add
  200. --]]
  201. function T:AddCardLabel(card,lid)
  202. local url
  203. local cardi=tostring(card)
  204. if Private then
  205. getAddon()
  206. url="https://api.trello.com/1/cards/"..cardi.."/idLabels"..addon
  207. else
  208. url="https://api.trello.com/1/cards/"..cardi.."/idLabels"..addon
  209. end
  210. --print(card,"IS THE CARD ID \n",lid,"IS THE LABEL ID")
  211. local da={
  212. value=lid
  213. }
  214. local dat=HS:JSONEncode(da)
  215. local data=HS:PostAsync(url,dat)
  216. --print(data)
  217. return HS:JSONDecode(data)
  218. end
  219. --[[
  220. POST /1/boards
  221. Required permissions: write
  222. Arguments
  223. name (required)
  224. Valid Values: a string with a length from 1 to 16384
  225. desc (optional)
  226. Valid Values: a string with a length from 0 to 16384
  227. idOrganization (optional)
  228. Valid Values: The id or name of the organization to add the board to.
  229. idBoardSource (optional)
  230. Valid Values: The id of the board to copy into the new board
  231. keepFromSource (optional)
  232. Default: all
  233. Valid Values: Components of the source board to copy.
  234. powerUps (optional)
  235. Valid Values: all or a comma-separated list of:
  236. calendar
  237. cardAging
  238. recap
  239. voting
  240. prefs_permissionLevel (optional)
  241. Default: private
  242. Valid Values: One of:
  243. org
  244. private
  245. public
  246. prefs_voting (optional)
  247. Default: disabled
  248. Valid Values: One of:
  249. disabled
  250. members
  251. observers
  252. org
  253. public
  254. prefs_comments (optional)
  255. Default: members
  256. Valid Values: One of:
  257. disabled
  258. members
  259. observers
  260. org
  261. public
  262. prefs_invitations (optional)
  263. Default: members
  264. Valid Values: One of:
  265. admins
  266. members
  267. prefs_selfJoin (optional)
  268. Default: true
  269. Valid Values:
  270. true
  271. false
  272. prefs_cardCovers (optional)
  273. Default: true
  274. Valid Values:
  275. true
  276. false
  277. prefs_background (optional)
  278. Default: blue
  279. Valid Values: a string with a length from 0 to 16384
  280. prefs_cardAging (optional)
  281. Default: regular
  282. Valid Values: One of:
  283. pirate
  284. regular
  285. --]]
  286. function T:AddBoard(nae,dec)
  287. local url
  288. if Private then
  289. getAddon()
  290. url="https://api.trello.com/1/boards"..addon
  291. else
  292. getAddon()
  293. url="https://api.trello.com/1/boards"..addon
  294. end
  295. local dat={
  296. name=nae,
  297. desc=dec
  298. }
  299. local data=HS:JSONEncode(dat)
  300. local re=HS:PostAsync(url,data)
  301. local red=HS:JSONDecode(re)
  302. return red
  303. end
  304. function T:GetCardID(name,boardid)
  305. local url
  306. if Private then
  307. getAddon()
  308. url="https://api.trello.com/1/boards/"..boardid.."/cards"..addon
  309. else
  310. getAddon()
  311. url="https://api.trello.com/1/boards/"..boardid.."/cards"..addon
  312. end
  313. local tab=HS:GetAsync(url,true)
  314. local tabl=HS:JSONDecode(tab)
  315. for k,ta in pairs(tabl) do
  316. for p,t in pairs(ta) do
  317. if p=="name" and t==name then
  318. return ta.id
  319. end
  320. end
  321. end
  322. end
  323. function T:GetCardInfo(cardid)
  324. --/1/boards/[board_id]/cards/[idCard]
  325. local url
  326. if Private then
  327. getAddon()
  328. url="https://api.trello.com/1/cards/"..cardid..""..addon
  329. else
  330. getAddon()
  331. url="https://api.trello.com/1/cards/"..cardid..""..addon
  332. end
  333. local re=HS:GetAsync(url,true)
  334. local tab=HS:JSONDecode(re)
  335. return tab
  336. end
  337. function T:GetBoardInfo(boardid)
  338. local url
  339. if Private then
  340. getAddon()
  341. url="https://api.trello.com/1/members/my/boards/"..boardid..addon
  342. else
  343. getAddon()
  344. url="https://api.trello.com/1/members/my/boards/"..boardid..addon
  345. end
  346. local re=HS:GetAsync(url,true)
  347. local data=HS:JSONDecode(re)
  348. return data
  349. end
  350. function T:GetLists(boardid)
  351. local url
  352. if Private then
  353. getAddon()
  354. url="https://api.trello.com/1/members/my/boards/"..boardid.."/lists"..addon
  355. else
  356. getAddon()
  357. url="https://api.trello.com/1/members/my/boards/"..boardid.."/lists"..addon
  358. end
  359. local re=HS:GetAsync(url,true)
  360. local data=HS:JSONDecode(re)
  361. return data
  362. end
  363. function T:GetBoardID(name)
  364. local url
  365. if Private then
  366. getAddon()
  367. url="https://api.trello.com/1/members/my/boards"..addon
  368. else
  369. getAddon()
  370. url="https://api.trello.com/1/members/my/boards"..addon
  371. end
  372. local tball=HS:GetAsync(url,true)
  373. local dt=HS:JSONDecode(tball)
  374. for _,tab in pairs(dt) do
  375. for p,it in pairs(tab) do
  376. if p=="name" and it==name then
  377. return tab.id
  378. end
  379. end
  380. end
  381. error(name.." not found!")
  382. return nil
  383. end
  384. --[[
  385. POST /1/cards
  386. Required permissions: write
  387. Arguments
  388. name (optional)
  389. Valid Values: The name of the new card. It isn't required if the name is being copied from provided by a URL, file or card that is being copied.
  390. desc (optional)
  391. Valid Values: a string with a length from 0 to 16384
  392. pos (optional)
  393. Default: bottom
  394. Valid Values: A position. top, bottom, or a positive number.
  395. due (required)
  396. Valid Values: A date, or null
  397. labels (optional)
  398. Valid Values: all or a comma-separated list of:
  399. blue
  400. green
  401. orange
  402. purple
  403. red
  404. yellow
  405. idList (required)
  406. Valid Values: id of the list that the card should be added to
  407. idMembers (optional)
  408. Valid Values: A comma-separated list of objectIds, 24-character hex strings
  409. idLabels (optional)
  410. Valid Values: A comma-separated list of objectIds, 24-character hex strings
  411. urlSource (required)
  412. Valid Values: A URL starting with http:// or https:// or null
  413. fileSource (optional)
  414. Valid Values: A file
  415. idCardSource (optional)
  416. Valid Values: The id of the card to copy into a new card.
  417. keepFromSource (optional)
  418. Default: all
  419. Valid Values: Properties of the card to copy over from the source.
  420.  
  421. --]]
  422. function T:AddCard(...)
  423. local url
  424. local args={...}
  425. local dat
  426. if #args==3 then
  427. local nam,des,lid=args[1],args[2],args[3]
  428. dat={
  429. name=nam,
  430. desc=des.."",
  431. idList=lid,
  432. urlSource=nil,
  433. due=nil
  434. }
  435. elseif #args==4 then
  436. local nam,des,lid,url=args[1],args[2],args[3],args[4]
  437. dat={
  438. name=nam,
  439. desc=""..des,
  440. idList=lid,
  441. urlSource=url,
  442. due=nil
  443. }
  444. elseif #args==5 then
  445. local nam,des,lid,url,po=args[1],args[2],args[3],args[4],args[5]
  446. dat={
  447. name=nam,
  448. desc=""..des,
  449. idList=lid,
  450. urlSource=url,
  451. pos=po,
  452. due=nil
  453. }
  454. elseif #args==6 then
  455. local nam,des,lid,url,po,de=args[1],args[2],args[3],args[4],args[5],args[6]
  456. dat={
  457. name=nam,
  458. desc=""..des,
  459. idList=lid,
  460. urlSource=url,
  461. pos=po,
  462. due=de
  463. }
  464. elseif #args==7 then
  465. local nam,des,lid,url,po,de,label=args[1],args[2],args[3],args[4],args[5],args[6],args[7]
  466. dat={
  467. name=nam,
  468. desc=""..des,
  469. idList=lid,
  470. urlSource=url,
  471. pos=po,
  472. due=de,
  473. labels=label
  474. }
  475. elseif #args==8 then
  476. local nam,des,lid,url,po,de,label,cc=args[1],args[2],args[3],args[4],args[5],args[6],args[7],args[8]
  477. dat={
  478. name=nam,
  479. desc=""..des,
  480. idList=lid,
  481. urlSource=url,
  482. pos=po,
  483. due=de,
  484. labels=label,
  485. idCardSource=cc
  486. }
  487. end
  488. local data=HS:JSONEncode(dat)
  489. if Private then
  490. getAddon()
  491. url="https://api.trello.com/1/cards"..addon
  492. else
  493. getAddon()
  494. url="https://api.trello.com/1/cards"..addon
  495. end
  496. local re=HS:PostAsync(url,data)
  497. return HS:JSONDecode(re)
  498. end
  499. --[[
  500. POST /1/cards/[card id or shortlink]/attachments
  501. Required permissions: write
  502. Arguments
  503. file (optional)
  504. Valid Values: A file
  505. url (optional)
  506. Valid Values: A URL starting with http:// or https:// or null
  507. name (optional)
  508. Valid Values: a string with a length from 0 to 256
  509. mimeType (optional)
  510. Valid Values: a string with a length from 0 to 256
  511. --]]
  512. function T:AddCardAtt(cardid,nae,type,value)
  513. local url
  514. local dat
  515. if string.lower(type)=="file" then
  516. dat={
  517. name=nae,
  518. file=value
  519. }
  520. elseif string.lower(type)=="url" then
  521. dat={
  522. name=nae,
  523. url=value
  524. }
  525. elseif string.lower(type)=="mime" then
  526. dat={
  527. name=nae,
  528. mimeType=value
  529. }
  530. end
  531. local cardi=tostring(cardid)
  532. if Private then
  533. getAddon()
  534. url="https://api.trello.com/1/cards/"..cardi.."/attachments"..addon
  535. else
  536. getAddon()
  537. url="https://api.trello.com/1/cards/"..cardi.."/attachments"..addon
  538. end
  539. local data=HS:JSONEncode(dat)
  540. local re=HS:PostAsync(url,data)
  541. return re
  542. end
  543. --[[
  544. GET /1/boards/[board_id]/labels
  545. Required permissions: read
  546. Arguments
  547. fields (optional)
  548. Default: all
  549. Valid Values: all or a comma-separated list of:
  550. color
  551. idBoard
  552. name
  553. uses
  554. limit (optional)
  555. Default: 50
  556. Valid Values: a number from 0 to 1000
  557. --]]
  558. function T:GetLabels(boardid)
  559. local url
  560. local dat
  561. if Private then
  562. getAddon()
  563. url="https://api.trello.com/1/boards/"..boardid.."/labels"..addon
  564. else
  565. getAddon()
  566. url="https://api.trello.com/1/boards/"..boardid.."/labels"..addon
  567. end
  568. local re=HS:GetAsync(url,true)
  569. --print(re)
  570. local dat=HS:JSONDecode(re)
  571. return dat
  572. end
  573. --[[
  574. GET /1/boards/[board_id]/labels
  575. Required permissions: read
  576. Arguments
  577. fields (optional)
  578. Default: all
  579. Valid Values: all or a comma-separated list of:
  580. color
  581. idBoard
  582. name
  583. uses
  584. limit (optional)
  585. Default: 50
  586. Valid Values: a number from 0 to 1000
  587. --]]
  588. function T:GetLabelID(LabelName,boardid)
  589. local url
  590. local dat
  591. if Private then
  592. getAddon()
  593. url="https://api.trello.com/1/boards/"..boardid.."/labels"..addon
  594. else
  595. getAddon()
  596. url="https://api.trello.com/1/boards/"..boardid.."/labels"..addon
  597. end
  598. local re=HS:GetAsync(url,true)
  599. --print(re)
  600. local dat=HS:JSONDecode(re)
  601. local id
  602. for i,v in next,dat do
  603. if v.name==LabelName then
  604. id=v.id
  605. break
  606. end
  607. end
  608. return id
  609. end
  610.  
  611. --[[
  612. GET /1/boards/[board_id]/lists
  613. Required permissions: read
  614. Arguments
  615. cards (optional)
  616. Default: none
  617. Valid Values: One of:
  618. all
  619. closed
  620. none
  621. open
  622. visible
  623. card_fields (optional)
  624. Default: all
  625. Valid Values: all or a comma-separated list of:
  626. badges
  627. checkItemStates
  628. closed
  629. dateLastActivity
  630. desc
  631. descData
  632. due
  633. email
  634. idAttachmentCover
  635. idBoard
  636. idChecklists
  637. idLabels
  638. idList
  639. idMembers
  640. idMembersVoted
  641. idShort
  642. labels
  643. manualCoverAttachment
  644. name
  645. pos
  646. shortLink
  647. shortUrl
  648. subscribed
  649. url
  650. filter (optional)
  651. Default: open
  652. Valid Values: One of:
  653. all
  654. closed
  655. none
  656. open
  657. fields (optional)
  658. Default: all
  659. Valid Values: all or a comma-separated list of:
  660. closed
  661. idBoard
  662. name
  663. pos
  664. subscribed
  665. --]]
  666. function T:GetListID(name,boardid)
  667. local url
  668. if Private then
  669. getAddon()
  670. url="https://api.trello.com/1/boards/"..boardid.."/lists"..addon
  671. else
  672. getAddon()
  673. url="https://api.trello.com/1/boards/"..boardid.."/lists"..addon
  674. end
  675. local tab=HS:GetAsync(url,true)
  676. local tabl=HS:JSONDecode(tab)
  677. for k,ta in pairs(tabl) do
  678. for p,t in pairs(ta) do
  679. if p=="name" and t==name then
  680. return ta.id
  681. end
  682. end
  683. end
  684. end
  685. --[[
  686. POST /1/lists
  687. Required permissions: write
  688. Arguments
  689. name (required)
  690. Valid Values: a string with a length from 1 to 16384
  691. idBoard (required)
  692. Valid Values: id of the board that the list should be added to
  693. idListSource (optional)
  694. Valid Values: The id of the list to copy into a new list.
  695. pos (optional)
  696. Default: top
  697. Valid Values: A position. top, bottom, or a positive number.
  698. --]]
  699. function T:AddList(...)
  700. local args={...}
  701. local nam,boid,idsource,po
  702. local url
  703. local dat
  704. if #args==2 then
  705. nam,boid=args[1],args[2]
  706. dat={name=nam,idBoard=boid}
  707. elseif #args==3 then
  708. nam,boid,idsource=args[1],args[2],args[3]
  709. dat={name=nam,idBoard=boid,idListSource=idsource}
  710. elseif #args==4 then
  711. nam,boid,idsource,po=args[1],args[2],args[3],args[4]
  712. dat={name=nam,idBoard=boid,idListSource=idsource,pos=po}
  713. else
  714. error("Invalid arguments: "..table.concat(args,","))
  715. end
  716. --
  717. if Private then
  718. getAddon()
  719. url="https://api.trello.com/1/lists"..addon
  720. else
  721. getAddon()
  722. url="https://api.trello.com/1/lists"..addon
  723. end
  724. local data=HS:JSONEncode(dat)
  725. local re=HS:PostAsync(url,data)
  726. return re.id
  727. end
  728. return T
Advertisement
Add Comment
Please, Sign In to add comment