Commit Graph

464 Commits

Author SHA1 Message Date
Guangcong Luo
c1d8f185b4 Slightly refactor pruneInactive
Mostly inconsequential, but this new code better reflects the code
style I'd like to have in PS.
2016-07-06 09:21:11 -05:00
Guangcong Luo
5354e18629 Refactor chatQueue to use roomid
The chatQueue previously put a reference to the room directly in the
chatQueue array. This refactors it to use a room ID.

This mostly doesn't matter much, but it's nice not to have references
to rooms outside of the room, and makes for slightly cleaner code by
not needing the weird workaround to see if the room has expired.
2016-07-06 09:21:11 -05:00
Ivo Julca
976610df75 Forfeit games on inactive user pruning
Fixes #1826
2016-07-01 10:22:31 -05:00
Ivo Julca
ce6a5d308a Tournaments now disallow name changes 2016-07-01 09:49:13 -05:00
Guangcong Luo
748c621007 Refactor in room.getAuth
Removes some code duplication.
2016-06-26 17:11:09 -07:00
Guangcong Luo
e1d3210415 Very minor readability refactor in Users 2016-06-23 19:50:58 -04:00
Guangcong Luo
0171fb1488 Deprecate namelock symbol
Namelock used to get its own symbol, but it's been rolled in with
the regular lock symbol. It's easy enough for people who need to to
tell namelocked and regularly locked users apart, anyway, and this
should be less confusing to users who aren't familiar with the
distinction.
2016-06-23 19:50:58 -04:00
Guangcong Luo
db85587fb0 Full support for lock/ban reasons
Lock/ban reasons are now fully supported by the Punishments system.
2016-06-17 04:39:55 -04:00
Guangcong Luo
55857f0b1b Fix namefilter long name handling 2016-06-11 20:14:52 -04:00
Ivo Julca
6b46a15098 Fix state after name filter 2016-06-10 22:52:30 -05:00
Guangcong Luo
d7d00010dd Fix name length restriction
PS now properly restricts name lengths to 18 characters.

The new system is mainly notable for not applying namefilter (and
therefore monitors) to names that are over the limit.
2016-06-09 03:19:33 -04:00
Ivo Julca
694b70f19e Support edition of multiline commands whitelist on runtime 2016-05-29 18:32:13 -05:00
Guangcong Luo
9feaaeb07e Fix various bugs in punishments 2016-05-20 22:12:48 -04:00
Ivo Julca
956405d141 Fix permabans 2016-05-13 21:53:12 -05:00
Guangcong Luo
bb5d5066be Timed persistent locks/bans
Locks, bans, and namelocks are now stored in `config/punishments.tsv`
and last through restarts. They expire after a set amount of time.

By default, locks and namelocks last 37 hours, and bans last 7 days.

Namelocks now imply regular locks, so namelocked users can't talk.

Locks, bans, and namelocks can no longer be stacked. Now only one
can be active at a time. Since locks < namelocks < bans, this
shouldn't be a big deal in practice.

This all involves a huge refactor. Basically every function in
punishments.js has been changed, and most of them have been renamed,
too. In terms of public API, `lockName` has been renamed `namelock`.

Lock/namelock/ban reasons tracking is supported but currently
unused. It'll probably be fully supported in a later commit.

More punishment-related functionality has been moved from users.js
to punishments.js as well.

Closes #1471
2016-05-11 01:54:54 -07:00
Guangcong Luo
07d319832c Allow more characters in names
`< > ^ * %` are now allowed.
2016-05-10 03:30:47 -04:00
Bär Halberkamp
361fa030ea Standardize 'rangeLockedUsers'
Previously, both 'rangelockedUsers' and 'rangeLockedUsers' were used, which caused rangelocks to not work properly
2016-05-07 17:19:04 +02:00
Guangcong Luo
4a995350bb Shim Array#includes
This also refactors everything to use Array#includes except data
and mods, which are large enough that I'll refactor them later
probably.
2016-05-04 02:55:18 -07:00
Bär Halberkamp
b450b0617f Move things relating to punishments to punishments.js (#2540) 2016-05-02 12:16:25 -07:00
Juanma Serrano
f9eea15658 Improve namelock command
Fix typos on sentences.
Make it write on modlog and global modlog.
Let namelocked names be reusable after unnamelock in case of an accident.
Set named to true on User object construction if it is found as namelocked.
Give proper reasoning on namelocked message.
2016-05-01 20:07:39 +02:00
Quinton Lee
b0cef1f17f Follow all player renames in roomgames (#2538)
Fixes various crashes caused by roomgame players changing names outside
of the room
2016-04-30 02:03:05 -07:00
Juanma Serrano
f7964b4038 Implement namelock (#2502)
Namelock locks a user into the unreachable name 'Guest #nnnnnn', the ns being a number.
This user cannot change name.
2016-04-27 09:28:59 -07:00
Ivo Julca
22779102cc Lint: Add miscellaneous extra rules
Among the newly added rules, there are quite a few intended to enforce
compliance of CONTRIBUTING.md-blessed idioms, as well as ensure
safe usage of classes and constant bindings.

We are also now enforcing usage of early return in commands.js,
which has 100% compliance as of fd2c45c.
2016-04-25 21:52:21 -05:00
小太
3b59ea37c0 Remove Config.tokenhosts
The actual checking of Config.tokenhosts seems to have been removed
a while ago, but the config itself wasn't removed.
2016-04-17 02:30:39 -07:00
Guangcong Luo
69bfce57dd Unify offline user promotion permissions
Requirements for promoting an offline user have now been unified for
room promotions, global promotions, and the special roomowner
appointment.

Now, in all these situations, an offline promotion is possible as
long as the user has a global rank or room rank in a registered
chat room (including private and hidden chat rooms, but excluding
unregistered rooms like battles and groupchats).
2016-04-08 02:45:37 -04: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
kotarou3
115e865358 Merge pull request #2475 from kotarou3/revert-d21ac1b76849bcd27410555774eb585b8eb156ea
Revert "Workaround for unavailable IPs"
2016-04-02 10:56:32 -05:00
Guangcong Luo
1acdee2e0f Limit users to 4 games at a time
This is mostly targeted at the AG bot that's everywhere. Playing a
huge number of battles at once makes it way too common to be matched
with it over and over again, which is undesirable.
2016-03-29 19:44:15 -04:00
The Immortal
0d5d3a8cd5 Merge pull request #2455 from xfix/no-confirmed-in-groupchat
Disallow getting confirmed status from groupchats.
2016-03-25 01:00:27 +04:00
Konrad Borowski
372b403a3c Disallow getting confirmed status from groupchats. 2016-03-24 21:23:53 +01:00
Guangcong Luo
e87fd32550 Refactor TeamValidator
The callback code in TeamValidator and the functions that use it have
been refactored to use Promises.

Pretty much all signatures have been changed, for instance:

    TeamValidator.validateTeamSync(format, team)
    -> TeamValidator(format).validateTeam(team)

    TeamValidator.validateTeam(format, team, callback)
    -> TeamValidator(format).prepTeam(team) // returns a Promise

Validators are no longer cached since they're really lightweight. They
contain a format and a Tools instance, and Tools instances are already
cached in Tools anyway. This saves a tiny bit of RAM in exchange for a
tiny bit of CPU time, but more importantly makes the code more
readable.

I'm introducing a new pattern/API for managing the parts of code with
child processes - their process managers are now at .PM and are now
opt-in, so you can use them synchronously without needing to spawn
any processes.

Fixes #2448
2016-03-16 09:43:59 -05:00
Guangcong Luo
7c6113def8 Refactor verifier.js for Promises 2016-03-13 19:30:30 -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
e54fe99e37 Refactor Context#getLastIdOf to User#getLastId
Also add a User#getLastName

These functions allow punishment commands to show a user's userid
even if they try to avoid that by logging out.
2016-02-28 03:25:35 -06:00
Guangcong Luo
18eb2e9610 Refactor User to ES6 classes 2016-02-27 21:38:34 -06:00
Guangcong Luo
6aa0f3badc Only report slow commands beyond 1000ms 2016-02-27 05:52:13 -05:00
Guangcong Luo
87b145d1dd Fix crash when deleted room in chatQueue 2016-02-24 23:06:25 -05:00
Guangcong Luo
bc8d75c127 Fix an obscure ac lock bug
Users could previously log out to avoid having their ac account
locked.
2016-02-24 23:06:25 -05:00
sirDonovan
871f535ae6 Simplify remaining instances of battle.tour 2016-02-19 13:46:50 -06:00
Guangcong Luo
c74aee6bb8 Simplify battle.rated and battle.tour
`battle.tour` is now just a reference to the tour.

`battle.rated` is now just the minimum Elo rating of the two players
in the battle.

With the new RoomGame battles, neither of their old values are
necessary anymore.
2016-02-19 05:18:40 -06:00
Guangcong Luo
75da4645c0 Add basic name filter
This filters out characters commonly used for impersonation. It's
based on the one used in Main, but now the rest of you can enjoy it
too!

This also filters zalgo and other annoying characters out of pokemon
names as well as usernames.
2016-02-16 03:46:57 -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
Guangcong Luo
5696a1d103 Make chat throttling smoother 2016-01-28 05:42:39 -08:00
Guangcong Luo
af80bb3138 Allow staff to say more things faster
Specifically, the chat throttle is now less restrictive for staff.
2016-01-25 18:05:32 -05:00
Guangcong Luo
e273984c21 Implement /confirmuser 2016-01-15 04:48:11 -05:00
Guangcong Luo
9ca5f1a383 Send client information on games allowing renames 2016-01-15 00:24:50 -08:00
Guangcong Luo
de5cf4e5d1 Send roomgame list in updateSearch
updateSearch now sends active roomgames in addition to formats being
searched.
2016-01-08 00:44:00 -06:00
Guangcong Luo
9d245a1652 Revert "Revert "Remove explicit decimal radix from parseInt""
This reverts commit 55df20be60.
2016-01-07 18:45:50 -06:00
Slayer95
55df20be60 Revert "Remove explicit decimal radix from parseInt" 2016-01-05 12:56:32 -05:00
Bär Halberkamp
c254c663d3 Remove explicit decimal radix from parseInt 2016-01-05 17:35:12 +01:00