Advertisement
Guest User

Untitled

a guest
Jul 20th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. function(context, args){ // target:#s.t1npc.corp
  2. // checks if the user didnt enter args, or if they didnt enter a target
  3. if (!args||!args.target){
  4. return {ok:false, msg:"usage: YOURUSER.test {target:#s.t1npc.corp}"}
  5. }
  6. // searches a page (response) looking for regex matches, and storing them in an array
  7. function search(regex, response) {
  8. let resultOfMatch = [];
  9. let matches = regex.exec(response);
  10. while (matches) {
  11. if (matches.index === regex.lastIndex) {
  12. regex.lastIndex++;
  13. }
  14. resultOfMatch.push(matches[1] || matches[2] || matches[3])
  15. matches = regex.exec(response);
  16. }
  17. return [...new Set(resultOfMatch)];
  18. }
  19. // main source of output, also used for development purposes
  20. function logicController(){
  21. var page = {};
  22. var response = args.target.call();
  23. // regex for pub pages
  24. var pubPages = search(/\s(\w+)\s\|/g, response);
  25. // get the navigation arg
  26. response = args.target.call({});
  27. var navArg = search(/\s(\w+):/g, response);
  28. // add the nav arg to the public pages to get the full arg:value string
  29. page[navArg] = pubPages[0];
  30. // gets the wall of text on the news page
  31. response = args.target.call(page);
  32. // search the page for relevant info
  33. var usernames = search(/([A-Za-z0-9_-]+)\sof\sproject|-{2}\s(\w+)\s/g, response);
  34. var projects = search(/continues\son\s([A-Za-z0-9_()]+)|on\s([A-Za-z0-9_()]+)\sprogress/g, response);
  35. // searches for the password
  36. page[navArg] = pubPages[1];
  37. response = args.target.call(page);
  38. let password = search(/\sstrategy\s(\w+)\s/g, response);
  39. // displays all of the info
  40. return [["`5usernames`", usernames], ["`5projects`", projects], ["`5password`", password]];
  41. return response;
  42. }
  43. return logicController();
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement