Commit Graph

76 Commits

Author SHA1 Message Date
panpawn
76285471a0 Fix double errorReply while muted in some cases (#2830)
Due to the recent refactor that changed how `this.canTalk` works, if a user was muted in a room, and then tried to do a command that wasn't allowed to be used if they can't talk, it would send two replies: "You are muted and cannot talk in this room." AND "You cannot do this while unable to talk."

This makes it so that if you're using a command while muted that isn't allowed to be used if you can't talk, it will just use the "You are muted and cannot talk in this room." errorReply.
2016-10-08 20:58:16 -07:00
Ben Davies
1446ec6deb Trivia: implement /trivia search command (#2820)
Now users can search for questions/submissions without having to rummage
through the entire list of questions. Trivia data and its writer are exported
once more so edits can be made to it with /eval if necessary.
2016-10-04 20:53:39 -07:00
Guangcong Luo
d6f5404e7e Rename CommandParser to Chat
We had a lot of discussion in Dev and a somewhat-close poll, but in
the end "Chat" was a better name than "Messages", and also has the
advantage of being shorter (which is nice for Chat.html and
Chat.plural which should be short).
2016-09-30 18:31:15 -07:00
Guangcong Luo
da1b318707 Move text processing from Tools to CommandParser
The following functions have been renamed:

- Tools.html to CommandParser.html
- Tools.plural to CommandParser.plural
- Tools.escapeHTML to CommandParser.escapeHTML
- Tools.toDurationString to CommandParser.toDurationString
- Tools.toTimeStamp to CommandParser.toTimestamp
  (notice the lowercase 's')

This is in preparation for a rename of Tools to Dex (by removing the
non-dex-related functions) and a rename of CommandParser to either
Messages or Chat.
2016-09-30 18:04:13 -07:00
Ben Davies
4e9577a7e5 Trivia: modlog kicks and wins, clean up unit tests (#2740)
Unit tests were still not destroying a few users.
2016-09-08 02:37:21 -05:00
Ben Davies
237388e6f8 Trivia: adjust question database command permissions (#2717)
Drivers can no longer accept/reject questions, that now being the
responsibility of mods.
2016-08-27 01:34:32 -05:00
Ben Davies
12fee1fda9 Rooms: fix memory leak in safe file writer functions (#2698)
The writer functions held circular references to themselves due to their
finishWriting closure. Because the bug that required making an exception
for how files are written on Windows was fixed 4 years ago now
(nodejs/node-v0.x-archive@41f2725), it's perfectly safe to remove the closure
and break the reference.
2016-08-17 13:35:25 -05:00
Ben Davies
ee1659260c Commands: guard against constructor being the target in those that don't (#2685) 2016-08-09 21:51:42 -05:00
Ben Davies
343c67b15f Trivia: lazy loading for modules in unit tests (#2677)
This makes it possible to refer to globals normally defined in production in the
outermost scope of the trivia module without making unit tests throw.
2016-08-08 14:43:01 -05:00
Ben Davies
febba6b362 Trivia: add /trivia leave, lower answering period to 10 seconds (#2674) 2016-08-06 14:20:58 -05:00
Ben Davies
4d34ac3996 Trivia: fix crash in /trivia status, fix other trivial bugs (#2660)
- /trivia status no longer crashes if a username is provided as a target
- Timer mode no longer gives users scores of NaN
- /trivia start no longer displays that the game is starting in 30000 seconds,
- 	rather than 30 seconds
- Questions no longer appear as escaped html during games
- Corrected misleading documentation on why the noop methods of trivia exist.
2016-07-31 23:59:38 -05:00
Ben Davies
d00ba49b1c Trivia: game management code rewrite (#2626)
Part 1 of the rewrite for the entire plugin
This is the rewrite of the classes and commands that handle running
trivia games. Several bugs that happened when running trivia games were
fixed, and unit tests were added to help keep them gone.
2016-07-31 18:29:51 -05:00
Guangcong Luo
8325f470b9 Remove Trivia plugin 2016-07-16 15:15:07 -06:00
Ivo Julca
c190b006b7 Replace explicit iterable protocol usage by for-of loops 2016-04-25 21:41:35 -05:00
Ivo Julca
10bb83bf3c Improvements to command broadcast API
- Method `this.runBroadcast()` has been split from `this.canBroadcast()`.
It's now the only method handling command-usage and intended as the main API
for synchronous commands. Async commands will execute both separately.
Note that the `suppressMessage` parameter is now passed to `runBroadcast`.

- The semantics of `broadcasting` have been similarly split.
`this,broadcastMessage` will be set to a truthy value when `this.canBroadcast` is run.
`this,broadcasting` will only be set to `true` once `this.runBroadcast` is executed.
2016-04-02 15:46:13 -05:00
Ivo Julca
0281176fd1 Remove usage of Array|Object methods implemented by Sugar.js
Adds a dependency to shim Object.values until it's natively available.
2016-03-09 16:55:34 -05:00
Guangcong Luo
b665660608 Refactor for more ES6 features
Now that nodejs/node#3072 is mostly fixed, we can finally start using
Node 4+ features.

This refactor:

- uses arrow functions where appropriate

  Note that arrow functions still aren't used in Mocha, where `this`
  is sometimes meaningful.

  This also removes the need for .bind() nearly everywhere, as well
  as the `self = this` trick.

- refactors Validator and Connection into ES6 classes

- no longer uses Array#forEach for iterating arrays

  We strongly prefer for (let i = 0; i < arr.length; i++) because of
  performance reasons. Most forEaches have been replaced with for..of,
  though, which is 5x slower than the long-form loop but 2x faster
  than forEach, which is good enough outside of most inner loops.

  The only exception is tournaments, which is due for a more invasive
  refactor soon anyway.
2016-02-10 17:40:21 -06:00
panpawn
ab6a88731e Standardize "User [user] not found." in commands
This replaces old instances like <code>"User [user] does not exist."</code> with instances like <code>"User [user] not found."</code>.
2016-02-05 02:28:10 +00:00
Konrad Borowski
81f602b8d8 Always use trailing comma for multiline objects 2016-01-01 00:20:07 +01:00
=
8ca902a0be Fix /trivia kick and /trivia qs
- /trivia kick did not update responder indices if a player that
  answered correctly was kicked, which timer mode depends on
- /trivia qs no longer lists random and undefined as categories
2015-12-19 05:13:19 -04:00
panpawn
6727d87808 Standardize canTalk() permission in chat-plugins 2015-11-23 16:06:12 +00:00
Ivo Julca
9a52fe337f Parse all numerical user input as base 10
Also took the chance to commit some style fixes missed in 90973d5 and 04c64c1.
2015-11-07 20:08:01 -05:00
Juanma Serrano
c4ac8d6e2f Use strict mode and let and const instead of var
This commit also fixes some duplicated variable declarations.
2015-11-06 21:56:52 -05:00
Bryan AA
45ab344144 Replace 'this.sendReply' with 'this.errorReply' in some cases 2015-09-27 19:16:39 -06:00
Bryan AA
1a737218e5 Improve trivia plugin
- Add a reply if a "Trivia" or "Question Workshop"  command is used in other room.
2015-09-10 12:40:29 -06:00
Ivo Julca
a2d2a52301 Chain Room#update to Room#[add|addRaw] everywhere 2015-07-03 20:45:57 -05:00
CJ
94030f58dc Mutes when kicks, updated categories 2015-06-29 18:38:24 -06:00
Kevin Lau
7c3e0824c4 Fix Travis Build Error 2015-06-28 17:12:12 -07:00
CJ
6f05306df7 trivia games joinable midgame + show who submits qs
change 'to join' to 'to start'

muted users cannot join games

added way to grab user name
2015-06-23 17:27:19 -06:00
sirDonovan
3bb410f0d1 Fix crashes in chat plugins
The old mute system was still in place, updated to reflect changes from
09be77d0b8
2015-06-16 17:56:07 -05:00
Guangcong Luo
cf112d1d3c Merge pull request #1945 from Slayer95/jscs-rules
Implement custom JSCS rules to enforce code style
2015-06-13 06:18:24 +00:00
Bryan AA
966da4d7ab Escape é in some chat-plugins commands. 2015-06-12 15:03:20 -06:00
Ivo Julca
f18eef39ca Fix Travis build 2015-06-12 03:41:22 -05:00
SolarisFox
29b961ff69 Style fix: indexOf() comparisons 2015-05-18 15:55:57 -07:00
Morfent
882e9369f2 Chat plugins: AotD and Trivia bug fixes
- Remove question sorting on loading the Trivia plugin, since it is no
  longer required
- Trivia game winners are chosen based on who answers first, not who
  signs up first
- The Artist of the Day is no longer always the first artist to be
  submitted
- Replace instances of foo > -1 with foo >= 0
2015-05-18 18:38:29 -03:00
Morfent
062f56ddd2 Chat plugins: mute/lock checks, add remaining help docs...
Letting users that can't talk use the more important commands is fine
and all, until they find a way to spam with them.

- Remove redundant this.canBroadcast call in /aotd
- The response after changing the Quote of the Day uses the proper
  broadcast style
- /aotd viewnoms sorts the prenomination list
- /trivia qs acknowledges that Video Games is a category
- Change suggestions to use the deprecated /trivia help command to /help
  trivia
- Add style fixes used in the Trivia to the The Happy Place and The Studio
  plugins
2015-05-05 22:43:33 -03:00
Morfent
69be1d638b Trivia plugin: add /help docs, more style fixes
- Fix style on multiline strings
- Use double quotes for HTML
- Fix remaining bugs in trivia submission from bee3a73
2015-04-28 19:41:05 -03:00
sirDonovan
c80d541dcc Trivia plugin: fix /trivia help
Fix typos and line breaks
2015-04-22 04:31:41 -05:00
Morfent
bee3a73559 Trivia plugin: optimize question handling...
Binary searches are now used instead of linear ones when splicing
questions in and slicing all the questions in a category from the
questions arrays. Stalemates are now handled after scoring answers
instead of just before asking a question.
2015-04-17 07:23:01 -03:00
Morfent
3aada3608b Trivia plugin: fix crashes from question submission 2015-04-16 22:35:18 -03:00
Joimer
b480deb2d2 Fix typo in Trivia ladder function 2015-04-15 00:49:55 +02:00
Morfent
41b4c3cbc1 Trivia plugin: optimize ladder updates, bug fixes
- the ladder is now saved in triviadata.json, and gets updated at the
  same time ranks do instead of needing to loop through the leaderboard
  once more
- Trivia.inactivityCounter clears properly on answer
- number and timer modes accept multiple answers again
- added question and intermission timeout consts
- Trivia property names are more specific
2015-04-12 17:40:12 -03:00
Morfent
89ccdd5203 Trivia plugin: fix rank sorting, levenshtein answers 2015-04-07 07:47:59 -03:00
Morfent
9c7cae1aea Trivia plugin: score ladder and ranking, bug fixes
- /trivia rank now shows the user's rank for each of the three score
  types
- Add /trivia ladder
- Fix crash in timer mode scoring
- Fix /trivia submit excluding all but the first answer in certain cases
- Fix /trivia accept and reject
- Consistent object notation
2015-04-02 10:10:25 -03:00
Morfent
36817bedf9 Trivia plugin: fix crash in timer mode scoring
Theoretically it's possible to get over 5 points from answering if the
answer was sent before the current question's askedAt was reassigned.
2015-03-30 23:04:14 -03:00
Morfent
b5455d1bf5 Trivia plugin: fix crash in /trivia kick 2015-03-30 04:43:01 -03:00
Quinton Lee
8e0a50dc97 Trivia plugin: fix crash in /trivia kick 2015-03-30 01:25:45 -05:00
Morfent
d166d06fb2 Trivia plugin: fix crash in /trivia accept and /trivia reject 2015-03-24 05:44:06 -03:00
Juanma Serrano
b525928731 Fix crash in Trivia plugin
Target is being splitted and saved on var indices, but target itself is still a string.
2015-03-23 17:33:47 +01:00
Morfent
cf25f0afa9 Trivia plugin: scoring bug fixes 2015-03-20 03:04:14 -03:00