CaptainMiller

Bot commands

Feb 11th, 2015
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 30.65 KB | None | 0 0
  1.  
  2. * This is the file where the bot commands are located
  3. *
  4. * @license MIT license
  5. */
  6.  
  7. var http = require('http');
  8. var sys = require('sys');
  9.  
  10. //Google doesn't like http
  11. var https = require('https');
  12. var csv = require('csv-parse');
  13.  
  14. exports.commands = {
  15. /**
  16. * Help commands
  17. *
  18. * These commands are here to provide information about the bot.
  19. */
  20.  
  21. about: function(arg, by, room, con) {
  22. if (this.hasRank(by, '#~') || room.charAt(0) === ',') {
  23. var text = '';
  24. } else {
  25. var text = '/pm ' + by + ', ';
  26. }
  27. text += '**Pokémon Showdown Bot** by: Quinella and TalkTakesTime';
  28. this.say(con, room, text);
  29. },
  30. help: 'guide',
  31. guide: function(arg, by, room, con) {
  32. if (this.hasRank(by, '#~') || room.charAt(0) === ',') {
  33. var text = '';
  34. } else {
  35. var text = '/pm ' + by + ', ';
  36. }
  37. if (config.botguide) {
  38. text += 'A guide on how to use this bot can be found here: ' + config.botguide;
  39. } else {
  40. text += 'There is no guide for this bot. PM the owner with any questions.';
  41. }
  42. this.say(con, room, text);
  43. },
  44.  
  45. /**
  46. * Dev commands
  47. *
  48. * These commands are here for highly ranked users (or the creator) to use
  49. * to perform arbitrary actions that can't be done through any other commands
  50. * or to help with upkeep of the bot.
  51. */
  52.  
  53. reload: function(arg, by, room, con) {
  54. if (!by === 'Void Neo') return false;
  55. try {
  56. this.uncacheTree('./commands.js');
  57. Commands = require('./commands.js').commands;
  58. this.say(con, room, 'Commands reloaded.');
  59. } catch (e) {
  60. error('failed to reload: ' + sys.inspect(e));
  61. }
  62. },
  63. custom: function(arg, by, room, con) {
  64. if (!this.hasRank(by, '~')) return false;
  65. // Custom commands can be executed in an arbitrary room using the syntax
  66. // ".custom [room] command", e.g., to do !data pikachu in the room lobby,
  67. // the command would be ".custom [lobby] !data pikachu". However, using
  68. // "[" and "]" in the custom command to be executed can mess this up, so
  69. // be careful with them.
  70. if (arg.indexOf('[') === 0 && arg.indexOf(']') > -1) {
  71. var tarRoom = arg.slice(1, arg.indexOf(']'));
  72. arg = arg.substr(arg.indexOf(']') + 1).trim();
  73. }
  74. this.say(con, tarRoom || room, arg);
  75. },
  76. js: function(arg, by, room, con) {
  77. if (config.excepts.indexOf(toId(by)) === -1) return false;
  78. try {
  79. var result = eval(arg.trim());
  80. this.say(con, room, JSON.stringify(result));
  81. } catch (e) {
  82. this.say(con, room, e.name + ": " + e.message);
  83. }
  84. },
  85.  
  86. /**
  87. * Room Owner commands
  88. *
  89. * These commands allow room owners to personalise settings for moderation and command use.
  90. */
  91.  
  92. settings: 'set',
  93. set: function(arg, by, room, con) {
  94. if (!this.hasRank(by, '%@&#~') || room.charAt(0) === ',') return false;
  95.  
  96. var settable = {
  97. say: 1,
  98. joke: 1,
  99. choose: 1,
  100. usagestats: 1,
  101. buzz: 1,
  102. helix: 1,
  103. survivor: 1,
  104. games: 1,
  105. wifi: 1,
  106. monotype: 1,
  107. autoban: 1,
  108. happy: 1,
  109. guia: 1,
  110. studio: 1,
  111. 'switch': 1,
  112. banword: 1
  113. };
  114. var modOpts = {
  115. flooding: 1,
  116. caps: 1,
  117. stretching: 1,
  118. bannedwords: 1
  119. };
  120.  
  121. var opts = arg.split(',');
  122. var cmd = toId(opts[0]);
  123. if (cmd === 'mod' || cmd === 'm' || cmd === 'modding') {
  124. if (!opts[1] || !toId(opts[1]) || !(toId(opts[1]) in modOpts)) return this.say(con, room, 'Incorrect command: correct syntax is ' + config.commandcharacter + 'set mod, [' +
  125. Object.keys(modOpts).join('/') + '](, [on/off])');
  126.  
  127. if (!this.settings['modding']) this.settings['modding'] = {};
  128. if (!this.settings['modding'][room]) this.settings['modding'][room] = {};
  129. if (opts[2] && toId(opts[2])) {
  130. if (!this.hasRank(by, '#~')) return false;
  131. if (!(toId(opts[2]) in {on: 1, off: 1})) return this.say(con, room, 'Incorrect command: correct syntax is ' + config.commandcharacter + 'set mod, [' +
  132. Object.keys(modOpts).join('/') + '](, [on/off])');
  133. if (toId(opts[2]) === 'off') {
  134. this.settings['modding'][room][toId(opts[1])] = 0;
  135. } else {
  136. delete this.settings['modding'][room][toId(opts[1])];
  137. }
  138. this.writeSettings();
  139. this.say(con, room, 'Moderation for ' + toId(opts[1]) + ' in this room is now ' + toId(opts[2]).toUpperCase() + '.');
  140. return;
  141. } else {
  142. this.say(con, room, 'Moderation for ' + toId(opts[1]) + ' in this room is currently ' +
  143. (this.settings['modding'][room][toId(opts[1])] === 0 ? 'OFF' : 'ON') + '.');
  144. return;
  145. }
  146. } else {
  147. if (!Commands[cmd]) return this.say(con, room, config.commandcharacter + '' + opts[0] + ' is not a valid command.');
  148. var failsafe = 0;
  149. while (!(cmd in settable)) {
  150. if (typeof Commands[cmd] === 'string') {
  151. cmd = Commands[cmd];
  152. } else if (typeof Commands[cmd] === 'function') {
  153. if (cmd in settable) {
  154. break;
  155. } else {
  156. this.say(con, room, 'The settings for ' + config.commandcharacter + '' + opts[0] + ' cannot be changed.');
  157. return;
  158. }
  159. } else {
  160. this.say(con, room, 'Something went wrong. PM TalkTakesTime here or on Smogon with the command you tried.');
  161. return;
  162. }
  163. failsafe++;
  164. if (failsafe > 5) {
  165. this.say(con, room, 'The command "' + config.commandcharacter + '' + opts[0] + '" could not be found.');
  166. return;
  167. }
  168. }
  169.  
  170. var settingsLevels = {
  171. off: false,
  172. disable: false,
  173. '+': '+',
  174. '%': '%',
  175. '@': '@',
  176. '&': '&',
  177. '#': '#',
  178. '~': '~',
  179. on: true,
  180. enable: true
  181. };
  182. if (!opts[1] || !opts[1].trim()) {
  183. var msg = '';
  184. if (!this.settings[cmd] || (!this.settings[cmd][room] && this.settings[cmd][room] !== false)) {
  185. msg = '.' + cmd + ' is available for users of rank ' + ((cmd === 'autoban' || cmd === 'banword') ? '#' : config.defaultrank) + ' and above.';
  186. } else if (this.settings[cmd][room] in settingsLevels) {
  187. msg = '.' + cmd + ' is available for users of rank ' + this.settings[cmd][room] + ' and above.';
  188. } else if (this.settings[cmd][room] === true) {
  189. msg = '.' + cmd + ' is available for all users in this room.';
  190. } else if (this.settings[cmd][room] === false) {
  191. msg = '' + config.commandcharacter+''+ cmd + ' is not available for use in this room.';
  192. }
  193. this.say(con, room, msg);
  194. return;
  195. } else {
  196. if (!this.hasRank(by, '#~')) return false;
  197. var newRank = opts[1].trim();
  198. if (!(newRank in settingsLevels)) return this.say(con, room, 'Unknown option: "' + newRank + '". Valid settings are: off/disable, +, %, @, &, #, ~, on/enable.');
  199. if (!this.settings[cmd]) this.settings[cmd] = {};
  200. this.settings[cmd][room] = settingsLevels[newRank];
  201. this.writeSettings();
  202. this.say(con, room, 'The command ' + config.commandcharacter + '' + cmd + ' is now ' +
  203. (settingsLevels[newRank] === newRank ? ' available for users of rank ' + newRank + ' and above.' :
  204. (this.settings[cmd][room] ? 'available for all users in this room.' : 'unavailable for use in this room.')))
  205. }
  206. }
  207. },
  208. blacklist: 'autoban',
  209. ban: 'autoban',
  210. ab: 'autoban',
  211. autoban: function(arg, by, room, con) {
  212. if (!this.canUse('autoban', room, by) || room.charAt(0) === ',') return false;
  213. if (!this.hasRank(this.ranks[room] || ' ', '@&#~')) return this.say(con, room, config.nick + ' requires rank of @ or higher to (un)blacklist.');
  214.  
  215. arg = arg.split(',');
  216. var added = [];
  217. var illegalNick = [];
  218. var alreadyAdded = [];
  219. if (!arg.length || (arg.length === 1 && !arg[0].trim().length)) return this.say(con, room, 'You must specify at least one user to blacklist.');
  220. for (var i = 0; i < arg.length; i++) {
  221. var tarUser = toId(arg[i]);
  222. if (tarUser.length < 1 || tarUser.length > 18) {
  223. illegalNick.push(tarUser);
  224. continue;
  225. }
  226. if (!this.blacklistUser(tarUser, room)) {
  227. alreadyAdded.push(tarUser);
  228. continue;
  229. }
  230. this.say(con, room, '/roomban ' + tarUser + ', Blacklisted user');
  231. this.say(con,room, '/modnote ' + tarUser + ' was added to the blacklist by ' + by + '.');
  232. added.push(tarUser);
  233. }
  234.  
  235. var text = '';
  236. if (added.length) {
  237. text += 'User(s) "' + added.join('", "') + '" added to blacklist successfully. ';
  238. this.writeSettings();
  239. }
  240. if (alreadyAdded.length) text += 'User(s) "' + alreadyAdded.join('", "') + '" already present in blacklist. ';
  241. if (illegalNick.length) text += 'All ' + (text.length ? 'other ' : '') + 'users had illegal nicks and were not blacklisted.';
  242. this.say(con, room, text);
  243. },
  244. unblacklist: 'unautoban',
  245. unban: 'unautoban',
  246. unab: 'unautoban',
  247. unautoban: function(arg, by, room, con) {
  248. if (!this.canUse('autoban', room, by) || room.charAt(0) === ',') return false;
  249. if (!this.hasRank(this.ranks[room] || ' ', '@&#~')) return this.say(con, room, config.nick + ' requires rank of @ or higher to (un)blacklist.');
  250.  
  251. arg = arg.split(',');
  252. var removed = [];
  253. var notRemoved = [];
  254. if (!arg.length || (arg.length === 1 && !arg[0].trim().length)) return this.say(con, room, 'You must specify at least one user to unblacklist.');
  255. for (var i = 0; i < arg.length; i++) {
  256. var tarUser = toId(arg[i]);
  257. if (tarUser.length < 1 || tarUser.length > 18) {
  258. notRemoved.push(tarUser);
  259. continue;
  260. }
  261. if (!this.unblacklistUser(tarUser, room)) {
  262. notRemoved.push(tarUser);
  263. continue;
  264. }
  265. this.say(con, room, '/roomunban ' + tarUser);
  266. removed.push(tarUser);
  267. }
  268.  
  269. var text = '';
  270. if (removed.length) {
  271. text += 'User(s) "' + removed.join('", "') + '" removed from blacklist successfully. ';
  272. this.writeSettings();
  273. }
  274. if (notRemoved.length) text += (text.length ? 'No other ' : 'No ') + 'specified users were present in the blacklist.';
  275. this.say(con, room, text);
  276. },
  277. viewbans: 'viewblacklist',
  278. vab: 'viewblacklist',
  279. viewautobans: 'viewblacklist',
  280. viewblacklist: function(arg, by, room, con) {
  281. if (!this.canUse('autoban', room, by) || room.charAt(0) === ',') return false;
  282.  
  283. var text = '';
  284. if (!this.settings.blacklist || !this.settings.blacklist[room]) {
  285. text = 'No users are blacklisted in this room.';
  286. } else {
  287. if (arg.length) {
  288. var nick = toId(arg);
  289. if (nick.length < 1 || nick.length > 18) {
  290. text = 'Invalid nickname: "' + nick + '".';
  291. } else {
  292. text = 'User "' + nick + '" is currently ' + (nick in this.settings.blacklist[room] ? '' : 'not ') + 'blacklisted in ' + room + '.';
  293. }
  294. } else {
  295. var nickList = Object.keys(this.settings.blacklist[room]);
  296. if (!nickList.length) return this.say(con, room, '/pm ' + by + ', No users are blacklisted in this room.');
  297. this.uploadToHastebin(con, room, by, 'The following users are banned in ' + room + ':\n\n' + nickList.join('\n'))
  298. return;
  299. }
  300. }
  301. this.say(con, room, '/pm ' + by + ', ' + text);
  302. },
  303. banphrase: 'banword',
  304. banword: function(arg, by, room, con) {
  305. if (!this.canUse('banword', room, by)) return false;
  306. if (!this.settings.bannedphrases) this.settings.bannedphrases = {};
  307. arg = arg.trim().toLowerCase();
  308. if (!arg) return false;
  309. var tarRoom = room;
  310.  
  311. if (room.charAt(0) === ',') {
  312. if (!this.hasRank(by, '~')) return false;
  313. tarRoom = 'global';
  314. }
  315.  
  316. if (!this.settings.bannedphrases[tarRoom]) this.settings.bannedphrases[tarRoom] = {};
  317. if (arg in this.settings.bannedphrases[tarRoom]) return this.say(con, room, "Phrase \"" + arg + "\" is already banned.");
  318. this.settings.bannedphrases[tarRoom][arg] = 1;
  319. this.writeSettings();
  320. this.say(con, room, "Phrase \"" + arg + "\" is now banned.");
  321. },
  322. unbanphrase: 'unbanword',
  323. unbanword: function(arg, by, room, con) {
  324. if (!this.canUse('banword', room, by)) return false;
  325. arg = arg.trim().toLowerCase();
  326. if (!arg) return false;
  327. var tarRoom = room;
  328.  
  329. if (room.charAt(0) === ',') {
  330. if (!this.hasRank(by, '~')) return false;
  331. tarRoom = 'global';
  332. }
  333.  
  334. if (!this.settings.bannedphrases || !this.settings.bannedphrases[tarRoom] || !(arg in this.settings.bannedphrases[tarRoom]))
  335. return this.say(con, room, "Phrase \"" + arg + "\" is not currently banned.");
  336. delete this.settings.bannedphrases[tarRoom][arg];
  337. if (!Object.size(this.settings.bannedphrases[tarRoom])) delete this.settings.bannedphrases[tarRoom];
  338. if (!Object.size(this.settings.bannedphrases)) delete this.settings.bannedphrases;
  339. this.writeSettings();
  340. this.say(con, room, "Phrase \"" + arg + "\" is no longer banned.");
  341. },
  342. viewbannedphrases: 'viewbannedwords',
  343. vbw: 'viewbannedwords',
  344. viewbannedwords: function(arg, by, room, con) {
  345. if (!this.canUse('banword', room, by)) return false;
  346. arg = arg.trim().toLowerCase();
  347. var tarRoom = room;
  348.  
  349. if (room.charAt(0) === ',') {
  350. if (!this.hasRank(by, '~')) return false;
  351. tarRoom = 'global';
  352. }
  353.  
  354. var text = "";
  355. if (!this.settings.bannedphrases || !this.settings.bannedphrases[tarRoom]) {
  356. text = "No phrases are banned in this room.";
  357. } else {
  358. if (arg.length) {
  359. text = "The phrase \"" + arg + "\" is currently " + (arg in this.settings.bannedphrases[tarRoom] ? "" : "not ") + "banned " +
  360. (room.charAt(0) === ',' ? "globally" : "in " + room) + ".";
  361. } else {
  362. var banList = Object.keys(this.settings.bannedphrases[tarRoom]);
  363. if (!banList.length) return this.say(con, room, "No phrases are banned in this room.");
  364. this.uploadToHastebin(con, room, by, "The following phrases are banned " + (room.charAt(0) === ',' ? "globally" : "in " + room) + ":\n\n" + banList.join('\n'))
  365. return;
  366. }
  367. }
  368. this.say(con, room, text);
  369. },
  370.  
  371. /**
  372. * General commands
  373. *
  374. * Add custom commands here.
  375. */
  376.  
  377. tell: 'say',
  378. say: function(arg, by, room, con) {
  379. if (!this.canUse('say', room, by)) return false;
  380. this.say(con, room, stripCommands(arg) + ' (' + by + ' said this)');
  381. },
  382. joke: function(arg, by, room, con) {
  383. if (!this.canUse('joke', room, by) || room.charAt(0) === ',') return false;
  384. var self = this;
  385.  
  386. var reqOpt = {
  387. hostname: 'api.icndb.com',
  388. path: '/jokes/random',
  389. method: 'GET'
  390. };
  391. var req = http.request(reqOpt, function(res) {
  392. res.on('data', function(chunk) {
  393. try {
  394. var data = JSON.parse(chunk);
  395. self.say(con, room, data.value.joke.replace(/&quot;/g, "\""));
  396. } catch (e) {
  397. self.say(con, room, 'Sorry, couldn\'t fetch a random joke... :(');
  398. }
  399. });
  400. });
  401. req.end();
  402. },
  403. choose: function(arg, by, room, con) {
  404. if (arg.indexOf(',') === -1) {
  405. var choices = arg.split(' ');
  406. } else {
  407. var choices = arg.split(',');
  408. }
  409. choices = choices.filter(function(i) {return (toId(i) !== '')});
  410. if (choices.length < 2) return this.say(con, room, (room.charAt(0) === ',' ? '': '/pm ' + by + ', ') + '.choose: You must give at least 2 valid choices.');
  411.  
  412. var choice = choices[Math.floor(Math.random()*choices.length)];
  413. this.say(con, room, ((this.canUse('choose', room, by) || room.charAt(0) === ',') ? '':'/pm ' + by + ', ') + stripCommands(choice));
  414. },
  415. usage: 'usagestats',
  416. usagestats: function(arg, by, room, con) {
  417. if (this.canUse('usagestats', room, by) || room.charAt(0) === ',') {
  418. var text = '';
  419. } else {
  420. var text = '/pm ' + by + ', ';
  421. }
  422. text += 'http://www.smogon.com/stats/2015-01/';
  423. this.say(con, room, text);
  424. },
  425. seen: function(arg, by, room, con) { // this command is still a bit buggy
  426. var text = (room.charAt(0) === ',' ? '' : '/pm ' + by + ', ');
  427. arg = toId(arg);
  428. if (!arg || arg.length > 18) return this.say(con, room, text + 'Invalid username.');
  429. if (arg === toId(by)) {
  430. text += 'Have you looked in the mirror lately?';
  431. } else if (arg === toId(config.nick)) {
  432. text += 'You might be either blind or illiterate. Might want to get that checked out.';
  433. } else if (!this.chatData[arg] || !this.chatData[arg].seenAt) {
  434. text += 'The user ' + arg + ' has never been seen.';
  435. } else {
  436. text += arg + ' was last seen ' + this.getTimeAgo(this.chatData[arg].seenAt) + ' ago' + (
  437. this.chatData[arg].lastSeen ? ', ' + this.chatData[arg].lastSeen : '.');
  438. }
  439. this.say(con, room, text);
  440. },
  441. helix: function(arg, by, room, con) {
  442. if (this.canUse('helix', room, by) || room.charAt(0) === ',') {
  443. var text = '';
  444. } else {
  445. var text = '/pm ' + by + ', ';
  446. }
  447.  
  448. var rand = ~~(20 * Math.random()) + 1;
  449.  
  450. switch (rand) {
  451. case 1: text += "Signs point to yes."; break;
  452. case 2: text += "Yes."; break;
  453. case 3: text += "Reply hazy, try again."; break;
  454. case 4: text += "Without a doubt."; break;
  455. case 5: text += "My sources say no."; break;
  456. case 6: text += "As I see it, yes."; break;
  457. case 7: text += "You may rely on it."; break;
  458. case 8: text += "Concentrate and ask again."; break;
  459. case 9: text += "Outlook not so good."; break;
  460. case 10: text += "It is decidedly so."; break;
  461. case 11: text += "Better not tell you now."; break;
  462. case 12: text += "Very doubtful."; break;
  463. case 13: text += "Yes - definitely."; break;
  464. case 14: text += "It is certain."; break;
  465. case 15: text += "Cannot predict now."; break;
  466. case 16: text += "Most likely."; break;
  467. case 17: text += "Ask again later."; break;
  468. case 18: text += "My reply is no."; break;
  469. case 19: text += "Outlook good."; break;
  470. case 20: text += "Don't count on it."; break;
  471. }
  472. this.say(con, room, text);
  473. },
  474.  
  475. /**
  476. * Room specific commands
  477. *
  478. * These commands are used in specific rooms on the Smogon server.
  479. */
  480. espaol: 'esp',
  481. ayuda: 'esp',
  482. esp: function(arg, by, room, con) {
  483. // links to relevant sites for the Wi-Fi room
  484. if ((room !== 'espaol' && room.charAt(0) !== ',') || config.serverid !== 'showdown') return false;
  485. var text = '';
  486. if (room.charAt(0) === ',' || !this.canUse('guia', room, by)) {
  487. text += '/pm ' + by + ', ';
  488. }
  489. var messages = {
  490. reglas: 'Recuerda seguir las reglas de nuestra sala en todo momento: http://ps-salaespanol.weebly.com/reglas.html',
  491. faq: 'Preguntas frecuentes sobre el funcionamiento del chat: http://ps-salaespanol.weebly.com/faq.html',
  492. faqs: 'Preguntas frecuentes sobre el funcionamiento del chat: http://ps-salaespanol.weebly.com/faq.html',
  493. foro: '¡Visita nuestro foro para participar en multitud de actividades! http://ps-salaespanol.proboards.com/',
  494. guia: 'Desde este índice (http://ps-salaespanol.proboards.com/thread/575/ndice-de-gu) podrás acceder a toda la información importante de la sala. By: Lost Seso',
  495. liga: '¿Tienes alguna duda sobre la Liga? ¡Revisa el **índice de la Liga** aquí!: (http://goo.gl/CxH2gi) By: xJoelituh'
  496. };
  497. text += (toId(arg) ? (messages[toId(arg)] || '¡Bienvenidos a la comunidad de habla hispana! Si eres nuevo o tienes dudas revisa nuestro índice de guías: http://ps-salaespanol.proboards.com/thread/575/ndice-de-gu') : '¡Bienvenidos a la comunidad de habla hispana! Si eres nuevo o tienes dudas revisa nuestro índice de guías: http://ps-salaespanol.proboards.com/thread/575/ndice-de-gu');
  498. this.say(con, room, text);
  499. },
  500. studio: function(arg, by, room, con) {
  501. if ((room !== 'thestudio' && room.charAt(0) !== ',') || config.serverid !== 'showdown') return false;
  502. var text = '';
  503. if (room.charAt(0) === ',' || !this.canUse('studio', room, by)) {
  504. text += '/pm ' + by + ', ';
  505. }
  506. var messages = {
  507. plug: '/announce The Studio\'s plug.dj can be found here: https://plug.dj/the-studio/'
  508. };
  509. this.say(con, room, text + (messages[toId(arg)] || ('Welcome to The Studio, a music sharing room on PS!. If you have any questions, feel free to PM a room staff member. Available commands for .studio: ' + Object.keys(messages).join(', '))));
  510. },
  511. 'switch': function(arg, by, room, con) {
  512. if (room !== 'gamecorner' || config.serverid !== 'showdown' || !this.canUse('switch', room, by)) return false;
  513. this.say(con, room, 'Taking over the world. Starting with Game Corner. Room deregistered.');
  514. this.say(con, room, '/k ' + (toId(arg) || by) + ', O3O YOU HAVE TOUCHED THE SWITCH');
  515. },
  516. wifi: function(arg, by, room, con) {
  517. // links to relevant sites for the Wi-Fi room
  518. if ((room !== 'wifi' && room.charAt(0) !== ',') || config.serverid !== 'showdown') return false;
  519. var text = '';
  520. if (room.charAt(0) === ',' || !this.canUse('wifi', room, by)) {
  521. text += '/pm ' + by + ', ';
  522. }
  523. var messages = {
  524. intro: 'Here is an introduction to Wi-Fi: http://tinyurl.com/welcome2wifi',
  525. rules: 'The rules for the Wi-Fi room can be found here: http://pstradingroom.weebly.com/rules.html',
  526. faq: 'Wi-Fi room FAQs: http://pstradingroom.weebly.com/faqs.html',
  527. faqs: 'Wi-Fi room FAQs: http://pstradingroom.weebly.com/faqs.html',
  528. scammers: 'List of known scammers: http://tinyurl.com/psscammers',
  529. cloners: 'List of approved cloners: http://goo.gl/WO8Mf4',
  530. tips: 'Scamming prevention tips: http://pstradingroom.weebly.com/scamming-prevention-tips.html',
  531. breeders: 'List of breeders: http://tinyurl.com/WiFIBReedingBrigade',
  532. signup: 'Breeders Sign Up: http://tinyurl.com/GetBreeding',
  533. bans: 'Ban appeals: http://tinyurl.com/WifiBanAppeals',
  534. banappeals: 'Ban appeals: http://tinyurl.com/WifiBanAppeals',
  535. lists: 'Major and minor list compilation: http://tinyurl.com/WifiSheets',
  536. trainers: 'List of EV trainers: http://tinyurl.com/WifiEVtrainingCrew',
  537. youtube: 'Wi-Fi room\'s official YouTube channel: http://tinyurl.com/wifiyoutube',
  538. league: 'Wi-Fi Room Pokemon League: http://tinyurl.com/wifiroomleague'
  539. };
  540. if (!this.wifiRoom) {
  541. this.wifiRoom = {
  542. docRevs : ['', ''],
  543. scammers : {},
  544. cloners : []
  545. };
  546. }
  547. var args = arg.trim().split(',');
  548. var that = this;
  549. switch (toId(args[0])) {
  550. case 'checkfc':
  551. if (!config.googleapikey) {
  552. this.say(con, room, text + 'A Google API key has not been provided and is required for this command to work.');
  553. return;
  554. }
  555. if (args.length < 2) {
  556. this.say(con, room, text + 'Usage: .wifi checkfc, <fc>');
  557. return;
  558. }
  559. that.getDocMeta('0AvygZBLXTtZZdFFfZ3hhVUplZm5MSGljTTJLQmJScEE', function (err, meta) {
  560. if (err) {
  561. console.log(err);
  562. that.say(con, room, text + 'An error occured while processing your command. Please report this!');
  563. return;
  564. }
  565. if (that.wifiRoom.docRevs[1] == meta.version) {
  566. var value = that.wifiRoom.scammers[args[1].replace(/\D/g, '')];
  567. if (value) {
  568. text += "The FC " + args[1] + " **BELONGS TO A KNOWN SCAMMER**. Known names: " + value.substring(0, 61) + (value.length > 61 ? '...' : '.');
  569. } else {
  570. text += "This FC does **NOT** belong to a known scammer.";
  571. }
  572. that.say(con, room, text);
  573. return;
  574. }
  575. that.say(con, room, text + 'Scammers List changed. Updating...');
  576. that.wifiRoom.docRevs[1] = meta.version;
  577. that.getDocCsv(meta, function (data) {
  578. csv(data, function (err, data) {
  579. if (err) {
  580. console.log(err);
  581. that.say(con, room, text + 'An error occured while processing your command. Please report this!');
  582. return;
  583. }
  584. data.forEach(function (ent) {
  585. var str = ent[1].replace(/\D/g, '');
  586. if (str && str.length >= 12) {
  587. for (var i = 0; i < str.length / 12; i++) {
  588. that.wifiRoom.scammers[str.substr(12 * i, 12 * i + 12)] = ent[0];
  589. }
  590. }
  591. });
  592. var value = that.wifiRoom.scammers[args[1].replace(/\D/g, '')];
  593. if (value) {
  594. text += "The FC " + args[1] + " **BELONGS TO A KNOWN SCAMMER**. Known names: " + value.substring(0, 61) + (value.length > 61 ? '...' : '.');
  595. } else {
  596. text += "This FC does **NOT** belong to a known scammer.";
  597. }
  598. that.say(con, room, text);
  599. });
  600. });
  601. });
  602. break;
  603. /*
  604. case 'ocloners':
  605. case 'onlinecloners':
  606. //Let's pretend this doesn't exist yet
  607. this.say(con, room, text + 'Unknown option. General links can be found here: http://pstradingroom.weebly.com/links.html');
  608. break;
  609. if (!config.googleapikey) {
  610. this.say(con, room, text + 'A Google API key has not been provided and is required for this command to work.');
  611. return;
  612. }
  613. that.getDocMeta('0Avz7HpTxAsjIdFFSQ3BhVGpCbHVVdTJ2VVlDVVV6TWc', function (err, meta) {
  614. if (err) {
  615. console.log(err);
  616. that.say(con, room, text + 'An error occured while processing your command. Please report this!');
  617. return;
  618. }
  619. text = '/pm ' + by + ', ';
  620. if (that.wifiRoom.docRevs[0] == meta.version) {
  621. var found = [];
  622. for (var i in that.wifiRoom.cloners) {
  623. if (that.chatData[toId(that.wifiRoom.cloners[i][0])]) {
  624. found.push('Name: ' + that.wifiRoom.cloners[i][0] + ' | FC: ' + that.wifiRoom.cloners[i][1] + ' | IGN: ' + that.wifiRoom.cloners[i][2]);
  625. }
  626. }
  627. if (!found.length) {
  628. that.say(con, room, text + 'No cloners were found online.');
  629. return;
  630. }
  631. var foundstr = found.join(' ');
  632. if(foundstr.length > 266) {
  633. that.uploadToHastebin(con, room, by, "The following cloners are online :\n\n" + found.join('\n'));
  634. return;
  635. }
  636. that.say(con, room, by, "The following cloners are online :\n\n" + foundstr);
  637. return;
  638. }
  639. that.say(con, room, text + 'Cloners List changed. Updating...');
  640. that.wifiRoom.docRevs[0] = meta.version;
  641. that.getDocCsv(meta, function (data) {
  642. csv(data, function (err, data) {
  643. if (err) {
  644. console.log(err);
  645. this.say(con, room, text + 'An error occured while processing your command. Please report this!');
  646. return;
  647. }
  648. data.forEach(function (ent) {
  649. var str = ent[1].replace(/\D/g, '');
  650. if (str && str.length >= 12) {
  651. that.wifiRoom.cloners.push([ent[0], ent[1], ent[2]]);
  652. }
  653. });
  654. var found = [];
  655. for (var i in that.wifiRoom.cloners) {
  656. if (that.chatData[toId(that.wifiRoom.cloners[i][0])]) {
  657. found.push('Name: ' + that.wifiRoom.cloners[i][0] + ' | FC: ' + that.wifiRoom.cloners[i][1] + ' | IGN: ' + that.wifiRoom.cloners[i][2]);
  658. }
  659. }
  660. if (!found.length) {
  661. that.say(con, room, text + 'No cloners were found online.');
  662. return;
  663. }
  664. var foundstr = found.join(' ');
  665. if (foundstr.length > 266) {
  666. that.uploadToHastebin(con, room, by, "The following cloners are online :\n\n" + found.join('\n'));
  667. return;
  668. }
  669. that.say(con, room, by, "The following cloners are online :\n\n" + foundstr);
  670. });
  671. });
  672. });
  673. break;
  674. */
  675.  
  676. default:
  677. this.say(con, room, text + (toId(args[0]) ? (messages[toId(args[0])] || 'Unknown option. General links can be found here: http://pstradingroom.weebly.com/links.html') : 'Links can be found here: http://pstradingroom.weebly.com/links.html'));
  678. }
  679. },
  680. mono: 'monotype',
  681. monotype: function(arg, by, room, con) {
  682. // links and info for the monotype room
  683. if ((room !== 'monotype' && room.charAt(0) !== ',') || config.serverid !== 'showdown') return false;
  684. var text = '';
  685. if (room.charAt(0) === ',' || !this.canUse('monotype', room, by)) {
  686. text += '/pm ' + by + ', ';
  687. }
  688. var messages = {
  689. forums: 'The monotype room\'s forums can be found here: http://psmonotypeforum.createaforum.com/index.php',
  690. plug: 'The monotype room\'s plug can be found here: http://plug.dj/monotype-3-am-club/',
  691. rules: 'The monotype room\'s rules can be found here: http://psmonotype.wix.com/psmono#!rules/cnnz',
  692. site: 'The monotype room\'s site can be found here: http://www.psmonotype.wix.com/psmono',
  693. league: 'Information on the Monotype League can be found here: http://themonotypeleague.weebly.com/'
  694. };
  695. text += (toId(arg) ? (messages[toId(arg)] || 'Unknown option. General information can be found here: http://www.psmonotype.wix.com/psmono') : 'Welcome to the monotype room! Please visit our site to find more information. The site can be found here: http://www.psmonotype.wix.com/psmono');
  696. this.say(con, room, text);
  697. },
  698. survivor: function(arg, by, room, con) {
  699. // contains links and info for survivor in the Survivor room
  700. if ((room !== 'survivor' && room.charAt(0) !== ',') || config.serverid !== 'showdown') return false;
  701. var text = '';
  702. if (room.charAt(0) === ',' || !this.canUse('survivor', room, by)) {
  703. text += '/pm ' + by + ', ';
  704. }
  705. var gameTypes = {
  706. hg: "http://survivor-ps.weebly.com/hunger-games.html",
  707. hungergames: "http://survivor-ps.weebly.com/hunger-games.html",
  708. classic: "http://survivor-ps.weebly.com/classic.html"
  709. };
  710. if (arg) {
  711. if (!gameTypes[toId(arg)]) return this.say(con, room, "Invalid game type. The game types can be found here: http://survivor-ps.weebly.com/themes.html");
  712. text += "The rules for this game type can be found here: " + gameTypes[toId(arg)];
  713. } else {
  714. text += "The list of game types can be found here: http://survivor-ps.weebly.com/themes.html";
  715. }
  716. this.say(con, room, text);
  717. },
  718. games: function(arg, by, room, con) {
  719. // lists the games for the games room
  720. if ((room !== 'gamecorner' && room.charAt(0) !== ',') || config.serverid !== 'showdown') return false;
  721. var text = '';
  722. if (room.charAt(0) === ',' || !this.canUse('games', room, by)) {
  723. text += '/pm ' + by + ', ';
  724. }
  725. this.say(con, room, text + 'Game List: 1. Would You Rather, 2. NickGames, 3. Scattegories, 4. Commonyms, 5. Questionnaires, 6. Funarios, 7. Anagrams, 8. Spot the Reference, 9. Pokemath, 10. Liar\'s Dice');
  726. this.say(con, room, text + '11. Pun Game, 12. Dice Cup, 13. Who\'s That Pokemon?, 14. Pokemon V Pokemon (BST GAME), 15. Letter Getter, 16. Missing Link, 17. Parameters! More information can be found here: http://psgamecorner.weebly.com/games.html');
  727. },
  728. happy: function(arg, by, room, con) {
  729. // info for The Happy Place
  730. if ((room !== 'thehappyplace' && room.charAt(0) !== ',') || config.serverid !== 'showdown') return false;
  731. var text = "";
  732. if (room.charAt(0) === ',' || !this.canUse('happy', room, by)) text += "/pm " + by + ", ";
  733. arg = toId(arg);
  734. if (arg === 'askstaff' || arg === 'ask' || arg === 'askannie') {
  735. text += "http://thepshappyplace.weebly.com/ask-the-staff.html";
  736. } else {
  737. text += "The Happy Place, at its core, is a friendly environment for anyone just looking for a place to hang out and relax. We also specialize in taking time to give advice on life problems for users. Need a place to feel at home and unwind? Look no further!";
  738. }
  739. this.say(con, room, text);
  740. },
  741.  
  742.  
  743. /**
  744. * Jeopardy commands
  745. *
  746. * The following commands are used for Jeopardy in the Academics room
  747. * on the Smogon server.
  748. */
  749.  
  750.  
  751. b: 'buzz',
  752. buzz: function(arg, by, room, con) {
  753. if (this.buzzed || !this.canUse('buzz', room, by) || room.charAt(0) === ',') return false;
  754. this.say(con, room, '**' + by.substr(1) + ' has buzzed in!**');
  755. this.buzzed = by;
  756. this.buzzer = setTimeout(function(con, room, buzzMessage) {
  757. this.say(con, room, buzzMessage);
  758. this.buzzed = '';
  759. }.bind(this), 7 * 1000, con, room, by + ', your time to answer is up!');
  760. },
  761. reset: function(arg, by, room, con) {
  762. if (!this.buzzed || !this.hasRank(by, '%@&#~') || room.charAt(0) === ',') return false;
  763. clearTimeout(this.buzzer);
  764. this.buzzed = '';
  765. this.say(con, room, 'The buzzer has been reset.');
  766. },
  767. };
Advertisement
Add Comment
Please, Sign In to add comment