Advertisement
Guest User

.

a guest
Jul 4th, 2015
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 45.34 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. //A Game of Trivia
  11. var triviaQuestions = ['What is the Pokémon based off a chandelier','chandelure','What type of item makes Fling have a 20 Base Power?','wing','A two turn move which starts with the absorbtion of sunlight','solarbeam','Its the only Dark Type Pulsating Move','darkpulse','What is the only type whose moves can only affect one Pokémon and has no Double Battle exclusive moves?','steel','What Rock type has a 4x weakness to water and evolves into a pokemon with a 4x Weakness to Fighting','pupitar','What ability boosts the power of Fire-type moves when the Pokemon is below 1/3 of its health?','blaze', 'What item, belonging to Misty, did Pikachu destroy in the anime to make Misty join Ash on a journey?','bicycle','Name a move that can have a 100% chance of flinching the target barring Fake Out.','fling','What is the only Poison-Type Pokemon to learn Rock Polish?','garbodor','What cave lies between Mahogany Town and Blackthorn City?','icepath','This Electric-Type move increases the user\'s Special Defense.','charge','What is the only Pokémon available in the Yellow Forest Pokéwalker route?','pikachu','This is the nickname of the Pokemon acting as the light source of Glitter Lighthouse in Olivine City.','amphy','This Pokemon has the longest cry.','jynx','This Pokemon Conquest warlord has the warrior ability of "chesto!" at rank 2.','yoshihiro','What Pokemon is based on the mythological kitsune?','ninetales','This is the only pure Flying-Type Pokémon (excluding forms)','tornados','This evolutionary stone either removes a type immunity or adds type immunities when used on certain Pokemon that evolve via this stone.','dawnstone','What is the only single-typed Pokemon with Tangled Feet?','spinda','This is the most expensive item that you can obtain in-game.','gorgeousroyalribbon','This Pokémon is the first Pokémon to be revealed.','rhydon','Name a non Psychic-Type Pokémon that can learn Heart Stamp.','pikachu','This type of berry have the longest name.','marangaberry','Name the only Pokemon with a BST of 336.','unown','Name a Pokémon that can be obtained by breeding a Pokémon they cannot evolve into.','phione','This herbal medicine cures infatuation.','mentalherb','This was the only Dragon-type attack in Generation I.','dragonrage','In the games, baseball players are represented by this trainer class.','infielder','Name one of the six moves that is a Self-KO move.',',memento','How much Poke Dollars does an Escape Rope cost?','500','What starter does your rival have in Pokemon Yellow version?','eevee','In the Pokemon anime, Jessie gives herself this name during the Kanto Grand Festival.','jessadia','What is the only Pokemon able to learn Secret Power by leveling up?','audino','This Pokemon in Pokemon Mystery Dungeon: Explorers of Time/Darkness/Sky has the job of waking up you and your partner in the morning.','exploud','In the main series Pokemon games, there are various Pokemon that impede your path to new areas. Name one.','snorlax','Name the only Pokemon to weigh 0.9 kg.','floette','What Gym Leader gives out the TM for Dynamic Punch?','chuck','What is Castelia Park shaped like?','pokeball',' This Gym Leader doesn\'t have a Vs. Sprite.','juan'];
  12. var triviaRoom; // This var will check if trivia is going in other room or not..
  13. var triviaON = false; // A switch case to tell if trivia is going on not
  14. var triviaTimer; // Keeps the track of the timer of the trivia
  15. var triviaA; // The answer of the trivia
  16. var triviaQ; // Question of trivia
  17. var triviaPoints = []; // This empty object will keep the track off all the trivia points during a game of trivia
  18. clearInterval(triviaTimer);
  19.  
  20. exports.commands = {
  21. /**
  22. * Help commands
  23. *
  24. * These commands are here to provide information about the bot.
  25. */
  26.  
  27. about: function(arg, by, room, con) {
  28. if (this.hasRank(by, '#~') || room.charAt(0) === ',') {
  29. var text = '';
  30. } else {
  31. var text = '/pm ' + by + ', ';
  32. }
  33. text += 'Hey, this is a Bot made by user: Chimechoo with special contribution and help of Sexyperior. If you want to use this bot in your room, simply PM Anri Sonahara. If you want a name change, its 3 Frost bucks. Thanks';
  34. this.say(con, room, text);
  35. },
  36. help: 'guide',
  37. guide: function(arg, by, room, con) {
  38. if (this.hasRank(by, '#~') || room.charAt(0) === ',') {
  39. var text = '';
  40. } else {
  41. var text = '/pm ' + by + ', ';
  42. }
  43. if (config.botguide) {
  44. text += 'A guide on how to use this bot can be found here: ' + config.botguide;
  45. } else {
  46. text += 'There is no guide for this bot. PM the owner with any questions.';
  47. }
  48. this.say(con, room, text);
  49. },
  50.  
  51. /**
  52. * Dev commands
  53. *
  54. * These commands are here for highly ranked users (or the creator) to use
  55. * to perform arbitrary actions that can't be done through any other commands
  56. * or to help with upkeep of the bot.
  57. */
  58.  
  59. reload: function(arg, by, room, con) {
  60. if (!this.hasRank(by, '#~')) return false;
  61. try {
  62. this.uncacheTree('./commands.js');
  63. Commands = require('./commands.js').commands;
  64. this.say(con, room, 'Commands reloaded.');
  65. } catch (e) {
  66. error('failed to reload: ' + sys.inspect(e));
  67. }
  68. },
  69. c: function(arg, by, room, con) {
  70. if (!this.hasRank(by, '~')) return false;
  71. // Custom commands can be executed in an arbitrary room using the syntax
  72. // ".custom [room] command", e.g., to do !data pikachu in the room lobby,
  73. // the command would be ".custom [lobby] !data pikachu". However, using
  74. // "[" and "]" in the custom command to be executed can mess this up, so
  75. // be careful with them.
  76. if (arg.indexOf('[') === 0 && arg.indexOf(']') > -1) {
  77. var tarRoom = arg.slice(1, arg.indexOf(']'));
  78. arg = arg.substr(arg.indexOf(']') + 1).trim();
  79. }
  80. this.say(con, tarRoom || room, arg);
  81. },
  82. js: function(arg, by, room, con) {
  83. if (config.excepts.indexOf(toId(by)) === -1) return false;
  84. try {
  85. var result = eval(arg.trim());
  86. this.say(con, room, JSON.stringify(result));
  87. } catch (e) {
  88. this.say(con, room, e.name + ": " + e.message);
  89. }
  90. },
  91.  
  92. /**
  93. * Room Owner commands
  94. *
  95. * These commands allow room owners to personalise settings for moderation and command use.
  96. */
  97.  
  98. settings: 'set',
  99. set: function(arg, by, room, con) {
  100. if (!this.hasRank(by, '%@&#~') || room.charAt(0) === ',') return false;
  101.  
  102. var settable = {
  103. say: 1,
  104. joke: 1,
  105. choose: 1,
  106. usagestats: 1,
  107. buzz: 1,
  108. helix: 1,
  109. survivor: 1,
  110. games: 1,
  111. wifi: 1,
  112. monotype: 1,
  113. autoban: 1,
  114. happy: 1,
  115. guia: 1,
  116. studio: 1,
  117. 'switch': 1,
  118. banword: 1
  119. };
  120. var modOpts = {
  121. flooding: 1,
  122. caps: 1,
  123. stretching: 1,
  124. bannedwords: 1,
  125. snen: 1
  126. };
  127.  
  128. var opts = arg.split(',');
  129. var cmd = toId(opts[0]);
  130. if (cmd === 'mod' || cmd === 'm' || cmd === 'modding') {
  131. 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, [' +
  132. Object.keys(modOpts).join('/') + '](, [on/off])');
  133.  
  134. if (!this.settings['modding']) this.settings['modding'] = {};
  135. if (!this.settings['modding'][room]) this.settings['modding'][room] = {};
  136. if (opts[2] && toId(opts[2])) {
  137. if (!this.hasRank(by, '#~')) return false;
  138. if (!(toId(opts[2]) in {on: 1, off: 1})) return this.say(con, room, 'Incorrect command: correct syntax is ' + config.commandcharacter + 'set mod, [' +
  139. Object.keys(modOpts).join('/') + '](, [on/off])');
  140. if (toId(opts[2]) === 'off') {
  141. this.settings['modding'][room][toId(opts[1])] = 0;
  142. } else {
  143. delete this.settings['modding'][room][toId(opts[1])];
  144. }
  145. this.writeSettings();
  146. this.say(con, room, 'Moderation for ' + toId(opts[1]) + ' in this room is now ' + toId(opts[2]).toUpperCase() + '.');
  147. return;
  148. } else {
  149. this.say(con, room, 'Moderation for ' + toId(opts[1]) + ' in this room is currently ' +
  150. (this.settings['modding'][room][toId(opts[1])] === 0 ? 'OFF' : 'ON') + '.');
  151. return;
  152. }
  153. } else {
  154. if (!Commands[cmd]) return this.say(con, room, config.commandcharacter + '' + opts[0] + ' is not a valid command.');
  155. var failsafe = 0;
  156. while (!(cmd in settable)) {
  157. if (typeof Commands[cmd] === 'string') {
  158. cmd = Commands[cmd];
  159. } else if (typeof Commands[cmd] === 'function') {
  160. if (cmd in settable) {
  161. break;
  162. } else {
  163. this.say(con, room, 'The settings for ' + config.commandcharacter + '' + opts[0] + ' cannot be changed.');
  164. return;
  165. }
  166. } else {
  167. this.say(con, room, 'Something went wrong. PM TalkTakesTime here or on Smogon with the command you tried.');
  168. return;
  169. }
  170. failsafe++;
  171. if (failsafe > 5) {
  172. this.say(con, room, 'The command "' + config.commandcharacter + '' + opts[0] + '" could not be found.');
  173. return;
  174. }
  175. }
  176.  
  177. var settingsLevels = {
  178. off: false,
  179. disable: false,
  180. '+': '+',
  181. '%': '%',
  182. '@': '@',
  183. '&': '&',
  184. '#': '#',
  185. '~': '~',
  186. on: true,
  187. enable: true
  188. };
  189. if (!opts[1] || !opts[1].trim()) {
  190. var msg = '';
  191. if (!this.settings[cmd] || (!this.settings[cmd][room] && this.settings[cmd][room] !== false)) {
  192. msg = '.' + cmd + ' is available for users of rank ' + ((cmd === 'autoban' || cmd === 'banword') ? '#' : config.defaultrank) + ' and above.';
  193. } else if (this.settings[cmd][room] in settingsLevels) {
  194. msg = '.' + cmd + ' is available for users of rank ' + this.settings[cmd][room] + ' and above.';
  195. } else if (this.settings[cmd][room] === true) {
  196. msg = '.' + cmd + ' is available for all users in this room.';
  197. } else if (this.settings[cmd][room] === false) {
  198. msg = '' + config.commandcharacter+''+ cmd + ' is not available for use in this room.';
  199. }
  200. this.say(con, room, msg);
  201. return;
  202. } else {
  203. if (!this.hasRank(by, '#~')) return false;
  204. var newRank = opts[1].trim();
  205. if (!(newRank in settingsLevels)) return this.say(con, room, 'Unknown option: "' + newRank + '". Valid settings are: off/disable, +, %, @, &, #, ~, on/enable.');
  206. if (!this.settings[cmd]) this.settings[cmd] = {};
  207. this.settings[cmd][room] = settingsLevels[newRank];
  208. this.writeSettings();
  209. this.say(con, room, 'The command ' + config.commandcharacter + '' + cmd + ' is now ' +
  210. (settingsLevels[newRank] === newRank ? ' available for users of rank ' + newRank + ' and above.' :
  211. (this.settings[cmd][room] ? 'available for all users in this room.' : 'unavailable for use in this room.')))
  212. }
  213. }
  214. },
  215. blacklist: 'autoban',
  216. ban: 'autoban',
  217. ab: 'autoban',
  218. autoban: function(arg, by, room, con) {
  219. if (!this.canUse('autoban', room, by) || room.charAt(0) === ',') return false;
  220. if (!this.hasRank(this.ranks[room] || ' ', '@&#~')) return this.say(con, room, config.nick + ' requires rank of @ or higher to (un)blacklist.');
  221.  
  222. arg = arg.split(',');
  223. var added = [];
  224. var illegalNick = [];
  225. var alreadyAdded = [];
  226. if (!arg.length || (arg.length === 1 && !arg[0].trim().length)) return this.say(con, room, 'You must specify at least one user to blacklist.');
  227. for (var i = 0; i < arg.length; i++) {
  228. var tarUser = toId(arg[i]);
  229. if (tarUser.length < 1 || tarUser.length > 18) {
  230. illegalNick.push(tarUser);
  231. continue;
  232. }
  233. if (!this.blacklistUser(tarUser, room)) {
  234. alreadyAdded.push(tarUser);
  235. continue;
  236. }
  237. this.say(con, room, '/roomban ' + tarUser + ', Blacklisted user');
  238. this.say(con,room, '/modnote ' + tarUser + ' This User is now Dead ' + by + '.');
  239. added.push(tarUser);
  240. }
  241.  
  242. var text = '';
  243. if (added.length) {
  244. text += 'User(s) "' + added.join('", "') + '" fuck off. ';
  245. this.writeSettings();
  246. }
  247. if (alreadyAdded.length) text += 'User(s) "' + alreadyAdded.join('", "') + '" is already ded. ';
  248. if (illegalNick.length) text += 'All ' + (text.length ? 'other ' : '') + 'users had illegal nicks and were not blacklisted.';
  249. this.say(con, room, text);
  250. },
  251. unblacklist: 'unautoban',
  252. unban: 'unautoban',
  253. unab: 'unautoban',
  254. unautoban: function(arg, by, room, con) {
  255. if (!this.canUse('autoban', room, by) || room.charAt(0) === ',') return false;
  256. if (!this.hasRank(this.ranks[room] || ' ', '@&#~')) return this.say(con, room, config.nick + ' requires rank of @ or higher to (un)blacklist.');
  257.  
  258. arg = arg.split(',');
  259. var removed = [];
  260. var notRemoved = [];
  261. if (!arg.length || (arg.length === 1 && !arg[0].trim().length)) return this.say(con, room, 'You must specify at least one user to unblacklist.');
  262. for (var i = 0; i < arg.length; i++) {
  263. var tarUser = toId(arg[i]);
  264. if (tarUser.length < 1 || tarUser.length > 18) {
  265. notRemoved.push(tarUser);
  266. continue;
  267. }
  268. if (!this.unblacklistUser(tarUser, room)) {
  269. notRemoved.push(tarUser);
  270. continue;
  271. }
  272. this.say(con, room, '/roomunban ' + tarUser);
  273. removed.push(tarUser);
  274. }
  275.  
  276. var text = '';
  277. if (removed.length) {
  278. text += 'User(s) "' + removed.join('", "') + '" has been given a Revive! ';
  279. this.writeSettings();
  280. }
  281. if (notRemoved.length) text += (text.length ? 'No other ' : 'No ') + 'is not ded.';
  282. this.say(con, room, text);
  283. },
  284. viewbans: 'viewblacklist',
  285. vab: 'viewblacklist',
  286. viewautobans: 'viewblacklist',
  287. viewblacklist: function(arg, by, room, con) {
  288. if (!this.canUse('autoban', room, by) || room.charAt(0) === ',') return false;
  289.  
  290. var text = '';
  291. if (!this.settings.blacklist || !this.settings.blacklist[room]) {
  292. text = 'No users are blacklisted in this room.';
  293. } else {
  294. if (arg.length) {
  295. var nick = toId(arg);
  296. if (nick.length < 1 || nick.length > 18) {
  297. text = 'Invalid nickname: "' + nick + '".';
  298. } else {
  299. text = 'User "' + nick + '" is currently ' + (nick in this.settings.blacklist[room] ? '' : 'not ') + 'blacklisted in ' + room + '.';
  300. }
  301. } else {
  302. var nickList = Object.keys(this.settings.blacklist[room]);
  303. if (!nickList.length) return this.say(con, room, '/pm ' + by + ', No users are blacklisted in this room.');
  304. this.uploadToHastebin(con, room, by, 'The following users are banned in ' + room + ':\n\n' + nickList.join('\n'))
  305. return;
  306. }
  307. }
  308. this.say(con, room, '/pm ' + by + ', ' + text);
  309. },
  310. banphrase: 'banword',
  311. banword: function(arg, by, room, con) {
  312. if (!this.canUse('banword', room, by)) return false;
  313. if (!this.settings.bannedphrases) this.settings.bannedphrases = {};
  314. arg = arg.trim().toLowerCase();
  315. if (!arg) return false;
  316. var tarRoom = room;
  317.  
  318. if (room.charAt(0) === ',') {
  319. if (!this.hasRank(by, '~')) return false;
  320. tarRoom = 'global';
  321. }
  322.  
  323. if (!this.settings.bannedphrases[tarRoom]) this.settings.bannedphrases[tarRoom] = {};
  324. if (arg in this.settings.bannedphrases[tarRoom]) return this.say(con, room, "Phrase \"" + arg + "\" is already banned.");
  325. this.settings.bannedphrases[tarRoom][arg] = 1;
  326. this.writeSettings();
  327. this.say(con, room, "Phrase \"" + arg + "\" is now banned.");
  328. },
  329. unbanphrase: 'unbanword',
  330. unbanword: function(arg, by, room, con) {
  331. if (!this.canUse('banword', room, by)) return false;
  332. arg = arg.trim().toLowerCase();
  333. if (!arg) return false;
  334. var tarRoom = room;
  335.  
  336. if (room.charAt(0) === ',') {
  337. if (!this.hasRank(by, '~')) return false;
  338. tarRoom = 'global';
  339. }
  340.  
  341. if (!this.settings.bannedphrases || !this.settings.bannedphrases[tarRoom] || !(arg in this.settings.bannedphrases[tarRoom]))
  342. return this.say(con, room, "Phrase \"" + arg + "\" is not currently banned.");
  343. delete this.settings.bannedphrases[tarRoom][arg];
  344. if (!Object.size(this.settings.bannedphrases[tarRoom])) delete this.settings.bannedphrases[tarRoom];
  345. if (!Object.size(this.settings.bannedphrases)) delete this.settings.bannedphrases;
  346. this.writeSettings();
  347. this.say(con, room, "Phrase \"" + arg + "\" is no longer banned.");
  348. },
  349. viewbannedphrases: 'viewbannedwords',
  350. vbw: 'viewbannedwords',
  351. viewbannedwords: function(arg, by, room, con) {
  352. if (!this.canUse('banword', room, by)) return false;
  353. arg = arg.trim().toLowerCase();
  354. var tarRoom = room;
  355.  
  356. if (room.charAt(0) === ',') {
  357. if (!this.hasRank(by, '~')) return false;
  358. tarRoom = 'global';
  359. }
  360.  
  361. var text = "";
  362. if (!this.settings.bannedphrases || !this.settings.bannedphrases[tarRoom]) {
  363. text = "No phrases are banned in this room.";
  364. } else {
  365. if (arg.length) {
  366. text = "The phrase \"" + arg + "\" is currently " + (arg in this.settings.bannedphrases[tarRoom] ? "" : "not ") + "banned " +
  367. (room.charAt(0) === ',' ? "globally" : "in " + room) + ".";
  368. } else {
  369. var banList = Object.keys(this.settings.bannedphrases[tarRoom]);
  370. if (!banList.length) return this.say(con, room, "No phrases are banned in this room.");
  371. this.uploadToHastebin(con, room, by, "The following phrases are banned " + (room.charAt(0) === ',' ? "globally" : "in " + room) + ":\n\n" + banList.join('\n'))
  372. return;
  373. }
  374. }
  375. this.say(con, room, text);
  376. },
  377.  
  378. /**
  379. * General commands
  380. *
  381. * Add custom commands here.
  382. */
  383.  
  384. tournament: 'tour',
  385. tour: function(arg, by, room, con) {
  386. if (room.charAt(0) === ',' || !toId(arg)) return false;
  387. if (!this.hasRank(this.ranks[room] || ' ', '#~')) {
  388. if (!this.hasRank(by, '+%@&#~')) return false;
  389. return this.say(con, room, config.nick + " requires # or higher to use the tournament system.");
  390. }
  391. arg = arg.split(',');
  392. if (!this.settings.tourwhitelist) this.settings.tourwhitelist = {};
  393. if (!this.settings.tourwhitelist[room]) this.settings.tourwhitelist[room] = {};
  394. if (toId(arg[0]) === 'whitelist') {
  395. if (!this.hasRank(by, '&#~')) return false;
  396. var action = toId(arg[1] || '');
  397. if (!action || action === 'view') {
  398. var nickList = Object.keys(this.settings.tourwhitelist[room]);
  399. if (!nickList.length) return this.say(con, room, "/pm " + by + ", No users are whitelisted in " + room + ".");
  400. return this.uploadToHastebin(con, room, by, "The following users are allowed to control tournaments in " + room + ":\n\n" + nickList.join("\n"));
  401. }
  402. var target = toId(arg[2] || '');
  403. if (!action || !(action in {'add': 1, 'remove': 1}) || !target) return this.say(con, room, "Incorrect syntax: .tour whitelist, [view/add/remove](, [user])");
  404. if (action === 'add') {
  405. this.settings.tourwhitelist[room][target] = 1;
  406. this.say(con, room, "User " + arg[2] + " is now whitelisted and can control tournaments.");
  407. } else {
  408. if (target in this.settings.tourwhitelist[room]) delete this.settings.tourwhitelist[room][target];
  409. this.say(con, room, "User " + arg[2] + " is no longer whitelisted.");
  410. }
  411. this.writeSettings();
  412. } else {
  413. if (!(this.hasRank(by, (toId(arg[0].split(' ')[0]) in {'dq': 1, 'disqualify': 1} ? '%@' : '') + '&#~') || toId(by) in this.settings.tourwhitelist[room])
  414. || toId(arg[0]) in {'join': 1, 'in': 1, 'j': 1}) return false;
  415. this.say(con, room, "/tour " + arg.join(','));
  416. }
  417. },
  418. tell: 'say',
  419. say: function(arg, by, room, con) {
  420. if (!this.canUse('say', room, by)) return false;
  421. this.say(con, room, stripCommands(arg) + ' (' + by + ' said this)');
  422. },
  423. joke: function(arg, by, room, con) {
  424. if (!this.canUse('joke', room, by) || room.charAt(0) === ',') return false;
  425. var self = this;
  426.  
  427. var reqOpt = {
  428. hostname: 'api.icndb.com',
  429. path: '/jokes/random',
  430. method: 'GET'
  431. };
  432. var req = http.request(reqOpt, function(res) {
  433. res.on('data', function(chunk) {
  434. try {
  435. var data = JSON.parse(chunk);
  436. self.say(con, room, data.value.joke.replace(/&quot;/g, "\""));
  437. } catch (e) {
  438. self.say(con, room, 'Sorry, couldn\'t fetch a random joke... :(');
  439. }
  440. });
  441. });
  442. req.end();
  443. },
  444. choose: function(arg, by, room, con) {
  445. if (arg.indexOf(',') === -1) {
  446. var choices = arg.split(' ');
  447. } else {
  448. var choices = arg.split(',');
  449. }
  450. choices = choices.filter(function(i) {return (toId(i) !== '')});
  451. if (choices.length < 2) return this.say(con, room, (room.charAt(0) === ',' ? '': '/pm ' + by + ', ') + '.choose: You must give at least 2 valid choices.');
  452.  
  453. var choice = choices[Math.floor(Math.random()*choices.length)];
  454. this.say(con, room, ((this.canUse('choose', room, by) || room.charAt(0) === ',') ? '':'/pm ' + by + ', ') + stripCommands(choice));
  455. },
  456. usage: 'usagestats',
  457. usagestats: function(arg, by, room, con) {
  458. if (this.canUse('usagestats', room, by) || room.charAt(0) === ',') {
  459. var text = '';
  460. } else {
  461. var text = '/pm ' + by + ', ';
  462. }
  463. text += 'http://sim.smogon.com:8080/Stats/2014-09/';
  464. this.say(con, room, text);
  465. },
  466. seen: function(arg, by, room, con) { // this command is still a bit buggy
  467. var text = (room.charAt(0) === ',' ? '' : '/pm ' + by + ', ');
  468. arg = toId(arg);
  469. if (!arg || arg.length > 18) return this.say(con, room, text + 'Invalid username.');
  470. if (arg === toId(by)) {
  471. text += 'Have you looked in the mirror lately?';
  472. } else if (arg === toId(config.nick)) {
  473. text += 'You might be either blind or illiterate. Might want to get that checked out.';
  474. } else if (!this.chatData[arg] || !this.chatData[arg].seenAt) {
  475. text += 'The user ' + arg + ' has never been seen.';
  476. } else {
  477. text += arg + ' was last seen ' + this.getTimeAgo(this.chatData[arg].seenAt) + ' ago' + (
  478. this.chatData[arg].lastSeen ? ', ' + this.chatData[arg].lastSeen : '.');
  479. }
  480. this.say(con, room, text);
  481. },
  482. askbot: function(arg, by, room, con) {
  483. if (this.canUse('askbot', room, by) || room.charAt(0) === ',') {
  484. var text = 'Bot says: ';
  485. } else {
  486. var text = '/pm ' + by + ', ';
  487. }
  488.  
  489. var rand = Math.floor(20 * Math.random()) + 1;
  490.  
  491. switch (rand) {
  492. case 1: text += "That won't work you scrub"; break;
  493. case 2: text += "At Least you're not Anri Sonahara."; break;
  494. case 3: text += "Try again, because that failed"; break;
  495. case 4: text += "Nope."; break;
  496. case 5: text += "Yeah, I guess."; break;
  497. case 6: text += "Chime would say it is great."; break;
  498. case 7: text += "You may rely on it."; break;
  499. case 8: text += "Concentrate and ask again."; break;
  500. case 9: text += "Not that good."; break;
  501. case 10: text += "It is decidedly so."; break;
  502. case 11: text += "No comments scrub."; break;
  503. case 12: text += "Very doubtful."; break;
  504. case 13: text += "Yeah."; break;
  505. case 14: text += "That's certain."; break;
  506. case 15: text += "Cannot predict now."; break;
  507. case 16: text += "Ask Someone else scrub."; break;
  508. case 17: text += "Ask again later."; break;
  509. case 18: text += "Shut it scrublord."; break;
  510. case 19: text += "Shut up you scrub."; break;
  511. case 20: text += "Don't count on it."; break;
  512. }
  513. this.say(con, room, text);
  514. },
  515.  
  516. /**
  517. * Room specific commands
  518. *
  519. * These commands are used in specific rooms on the Smogon server.
  520. */
  521. espaol: 'esp',
  522. ayuda: 'esp',
  523. esp: function(arg, by, room, con) {
  524. // links to relevant sites for the Wi-Fi room
  525. if (!(room === 'espaol' && config.serverid === 'showdown')) return false;
  526. var text = '';
  527. if (!this.canUse('guia', room, by)) {
  528. text += '/pm ' + by + ', ';
  529. }
  530. var messages = {
  531. reglas: 'Recuerda seguir las reglas de nuestra sala en todo momento: http://ps-salaespanol.weebly.com/reglas.html',
  532. faq: 'Preguntas frecuentes sobre el funcionamiento del chat: http://ps-salaespanol.weebly.com/faq.html',
  533. faqs: 'Preguntas frecuentes sobre el funcionamiento del chat: http://ps-salaespanol.weebly.com/faq.html',
  534. foro: '¡Visita nuestro foro para participar en multitud de actividades! http://ps-salaespanol.proboards.com/',
  535. 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',
  536. liga: '¿Tienes alguna duda sobre la Liga? ¡Revisa el **índice de la Liga** aquí!: (http://goo.gl/CxH2gi) By: xJoelituh'
  537. };
  538. 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');
  539. this.say(con, room, text);
  540. },
  541. studio: function(arg, by, room, con) {
  542. if (!(room === 'thestudio' && config.serverid === 'showdown')) return false;
  543. var text = '';
  544. if (!this.canUse('studio', room, by)) {
  545. text += '/pm ' + by + ', ';
  546. }
  547. var messages = {
  548. plug: '/announce The Studio\'s plug.dj can be found here: http://plug.dj/the-studio-3/'
  549. };
  550. 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(', '))));
  551. },
  552. 'switch': function(arg, by, room, con) {
  553. if (!(room === 'gamecorner' && config.serverid === 'showdown') ||
  554. !this.canUse('switch', room, by)) return false;
  555. this.say(con, room, 'Taking over the world. Starting with Game Corner. Room deregistered.');
  556. this.say(con, room, '/k ' + (toId(arg) || by) + ', O3O YOU HAVE TOUCHED THE SWITCH');
  557. },
  558. wifi: function(arg, by, room, con) {
  559. // links to relevant sites for the Wi-Fi room
  560. if (!(room === 'wifi' && config.serverid === 'showdown')) return false;
  561. var text = '';
  562. if (!this.canUse('wifi', room, by)) {
  563. text += '/pm ' + by + ', ';
  564. }
  565. var messages = {
  566. intro: 'Here is an introduction to Wi-Fi: http://tinyurl.com/welcome2wifi',
  567. rules: 'The rules for the Wi-Fi room can be found here: http://pstradingroom.weebly.com/rules.html',
  568. faq: 'Wi-Fi room FAQs: http://pstradingroom.weebly.com/faqs.html',
  569. faqs: 'Wi-Fi room FAQs: http://pstradingroom.weebly.com/faqs.html',
  570. scammers: 'List of known scammers: http://tinyurl.com/psscammers',
  571. cloners: 'List of approved cloners: http://goo.gl/WO8Mf4',
  572. tips: 'Scamming prevention tips: http://pstradingroom.weebly.com/scamming-prevention-tips.html',
  573. breeders: 'List of breeders: http://tinyurl.com/WiFIBReedingBrigade',
  574. signup: 'Breeders Sign Up: http://tinyurl.com/GetBreeding',
  575. bans: 'Ban appeals: http://pstradingroom.weebly.com/ban-appeals.html',
  576. banappeals: 'Ban appeals: http://pstradingroom.weebly.com/ban-appeals.html',
  577. lists: 'Major and minor list compilation: http://tinyurl.com/WifiSheets',
  578. trainers: 'List of EV trainers: http://tinyurl.com/WifiEVtrainingCrew',
  579. youtube: 'Wi-Fi room\'s official YouTube channel: http://tinyurl.com/wifiyoutube',
  580. league: 'Wi-Fi Room Pokemon League: http://tinyurl.com/wifiroomleague'
  581. };
  582. text += (toId(arg) ? (messages[toId(arg)] || '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');
  583. this.say(con, room, text);
  584. },
  585. mono: 'monotype',
  586. monotype: function(arg, by, room, con) {
  587. // links and info for the monotype room
  588. if (!(room === 'monotype' && config.serverid === 'showdown')) return false;
  589. var text = '';
  590. if (!this.canUse('monotype', room, by)) {
  591. text += '/pm ' + by + ', ';
  592. }
  593. var messages = {
  594. forums: 'The monotype room\'s forums can be found here: http://psmonotypeforum.createaforum.com/index.php',
  595. plug: 'The monotype room\'s plug can be found here: http://plug.dj/monotype-3-am-club/',
  596. rules: 'The monotype room\'s rules can be found here: http://psmonotype.wix.com/psmono#!rules/cnnz',
  597. site: 'The monotype room\'s site can be found here: http://www.psmonotype.wix.com/psmono',
  598. league: 'Information on the Monotype League can be found here: http://themonotypeleague.weebly.com/'
  599. };
  600. 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');
  601. this.say(con, room, text);
  602. },
  603. survivor: function(arg, by, room, con) {
  604. // contains links and info for survivor in the Survivor room
  605. if (!(room === 'survivor' && config.serverid === 'showdown')) return false;
  606. var text = '';
  607. if (!this.canUse('survivor', room, by)) {
  608. text += '/pm ' + by + ', ';
  609. }
  610. var gameTypes = {
  611. hg: "http://survivor-ps.weebly.com/hunger-games.html",
  612. hungergames: "http://survivor-ps.weebly.com/hunger-games.html",
  613. classic: "http://survivor-ps.weebly.com/classic.html"
  614. };
  615. arg = toId(arg);
  616. if (arg) {
  617. if (!(arg in gameTypes)) return this.say(con, room, "Invalid game type. The game types can be found here: http://survivor-ps.weebly.com/themes.html");
  618. text += "The rules for this game type can be found here: " + gameTypes[arg];
  619. } else {
  620. text += "The list of game types can be found here: http://survivor-ps.weebly.com/themes.html";
  621. }
  622. this.say(con, room, text);
  623. },
  624. games: function(arg, by, room, con) {
  625. // lists the games for the games room
  626. if (!(room === 'gamecorner' && config.serverid === 'showdown')) return false;
  627. var text = '';
  628. if (!this.canUse('games', room, by)) {
  629. text += '/pm ' + by + ', ';
  630. }
  631. 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');
  632. 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');
  633. },
  634. happy: function(arg, by, room, con) {
  635. // info for The Happy Place
  636. if (!(room === 'thehappyplace' && config.serverid === 'showdown')) return false;
  637. var text = "";
  638. if (!this.canUse('happy', room, by)) text += "/pm " + by + ", ";
  639. arg = toId(arg);
  640. if (arg === 'askstaff' || arg === 'ask' || arg === 'askannie') {
  641. text += "http://thepshappyplace.weebly.com/ask-the-staff.html";
  642. } else {
  643. 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!";
  644. }
  645. this.say(con, room, text);
  646. },
  647.  
  648.  
  649. /**
  650. * Jeopardy commands
  651. *
  652. * The following commands are used for Jeopardy in the Academics room
  653. * on the Smogon server.
  654. */
  655.  
  656.  
  657. b: 'buzz',
  658. buzz: function(arg, by, room, con) {
  659. if (this.buzzed || !this.canUse('buzz', room, by) || room.charAt(0) === ',') return false;
  660. this.say(con, room, '**' + by.substr(1) + ' has buzzed in!**');
  661. this.buzzed = by;
  662. var self = this;
  663. this.buzzer = setTimeout(function(con, room, buzzMessage) {
  664. self.say(con, room, buzzMessage);
  665. self.buzzed = '';
  666. }, 7000, con, room, by + ', your time to answer is up!');
  667. },
  668. reset: function(arg, by, room, con) {
  669. if (!this.buzzed || !this.hasRank(by, '%@&#~') || room.charAt(0) === ',') return false;
  670. clearTimeout(this.buzzer);
  671. this.buzzed = '';
  672. this.say(con, room, 'The buzzer has been reset.');
  673. },
  674. //////////////////////////////////////////////////////////////////////Added Commands/////////////////////////////////////
  675. //Trivia Commands
  676. trivia: function(arg, user, room){
  677. if (!this.hasRank(by, '#@+%') || room === user) return false;
  678. var text = '';
  679. if(triviaON){this.say( room, '**ERROR**: A game of trivia is going on another room and hence it cannot be started here'); return false;}
  680. triviaON = true;
  681. triviaRoom = room.id;
  682. triviaA = '';
  683. triviaPoints = [];
  684. this.say( room, 'Hosting a game of **trivia**. Answer the questions using -ta or -triviaanswer. First to get 10 points wins.');
  685. triviaTimer = setInterval( function() {
  686. if(triviaA){this.say(room, '**BEEP** TIMES UP!! ' + triviaA);}
  687. var TQN = 2*(Math.floor(triviaQuestions.length*Math.random()/2))
  688. triviaQ = triviaQuestions[TQN];
  689. triviaA = triviaQuestions[TQN+ 1];
  690. this.say( room, '**Question**: ' + triviaQ);
  691. }.bind(this), 15000);
  692.  
  693. },
  694. triviapoints: function(arg, user, room){
  695. var text = "";
  696. if(!anagramON) return false;
  697. var text = '**Triviapoints so far**: '
  698. for (var i = 0; i < triviaPoints.length; i++){
  699. text += '' + triviaPoints[i] + ': ';
  700. text += triviaPoints[i + 1] + ' Pokepoints, ';
  701. i++
  702. }
  703. this.say(room, text);
  704. },
  705. ta: 'triviaanswer',
  706. triviaanswer: function(arg, user, room){
  707. if(room.id !== triviaRoom) return false;
  708. if (!arg) return false;
  709. arg = (arg);
  710. var theuser = (user.name);
  711. if(arg == triviaA){
  712. if (triviaPoints.indexOf(theuser) > -1){
  713. triviaA = '';
  714. triviaPoints[triviaPoints.indexOf(theuser) + 1] += 1;
  715. if (triviaPoints[triviaPoints.indexOf(theuser) + 1] >= 10) {
  716. clearInterval(triviaTimer);
  717. this.say( room, '**Congrats to ' + user.name + ' for winning Trivia!**');
  718. this.say(room,'/pm '+ user.name + ' ,**Congratulations** on winning the game of trivia.')
  719. this.say(room,'/msg lustrousash,' + user.name + ' have been awarded **2 Points** for winning trivia')
  720. triviaON = false;
  721. return false;
  722. }
  723. this.say(room,'**' + user.name + '** got the right answer, and has **' + triviaPoints[triviaPoints.indexOf(theuser) + 1] + '** Triviapoints!');
  724. } else {
  725. triviaA = '';
  726. triviaPoints[triviaPoints.length] = theuser;
  727. triviaPoints[triviaPoints.length] = 1;
  728. this.say(room,'**' + user.name + '** got the right answer, and has **' + triviaPoints[triviaPoints.indexOf(theuser) + 1] + '** Triviapoint!');
  729. }
  730. }
  731. },
  732. triviaend: function(arg, user, room){
  733. if(room.id !== triviaRoom)return false;
  734. if(!triviaON) return false;
  735. if (!this.hasRank(by, '#@+%') || room === user) return false;
  736. clearInterval(triviaTimer);
  737. this.say(room, 'The game of trivia has been ended.');
  738. triviaON = false;
  739. },
  740. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement