Commit Graph

532 Commits

Author SHA1 Message Date
Bär Halberkamp
901fff708e Fix mistake in getAltUsers 2017-07-28 00:16:12 -04:00
Bär Halberkamp
464768e7d8 Refactor both locks and punishments (#3698)
This both allows staff to lock users that are offline, given they have a previous punishment (globally or in any room)
This also will utilize existing punishment information for handling nameblacklists, making a nameblacklist of a user with a current punishment equivalent to having used /blacklist at the moment of that punishment
2017-07-27 18:36:34 -04:00
panpawn
225e5c6ae4 Users: Add lastCommand to constructor (#3818)
This is used in several parts of the sim where commands carryout potentially dangerous actions.  For this reason, it should be apart of a user's constructor.
2017-07-22 19:16:31 -07:00
HoeenHero
24f4e40e49 Admins are staff too (#3762) 2017-07-11 17:54:28 +09:00
Charlie Kobayashi
f0d1cd96ec Users: isStaff compatibility with custom ranks (#3738)
check via permissions instead of symbols 
- compared to before, this allows bots to enter the staff room
2017-07-07 13:24:56 +09:00
panpawn
2ddd9c0188 Slightly refactor user#getIdentity (#3716) 2017-07-04 23:41:57 +09:00
Guangcong Luo
58a1af0f0f Rename supplementaryBanlist -> customBanlist
It's shorter and clearer.
2017-07-04 09:36:37 +09:00
Guangcong Luo
0143ae28dd Replace fs module (#3686)
The new FS module is an abstraction layer over the built-in fs module.

The main reason it exists is because I need an abstraction layer I can
disable writing from. But that'll be in another commit.

Currently, mine is better because:
 - paths are always relative to PS's base directory
 - Promises (seriously wtf Node Core what are you thinking)
 - PS-style API: FS("foo.txt").write("bar") for easier argument order
 - mkdirp

This also increases the minimum supported Node version from v6.0 to
v7.7, because we now use async/await. Sorry for the inconvenience!

This also drops the mock-fs-require-fix dependency

mock-fs-require-fix was always kind of a huge hack. It's no longer
necessary, with an FS API that does everything it used to.

This removes a lot of other hacks from test/main.js, which is nice.
2017-06-24 13:42:54 -07:00
Charlie Kobayashi
e4fe38126e Rooms: send a |customgroups| message on connect (#3529) 2017-06-19 16:12:52 -07:00
Bär Halberkamp
961ffc3f9b Upgrade eslint to 4.x (#3657) 2017-06-18 22:37:43 -07:00
Bär Halberkamp
38556a5aa4 Further refactor punishments when it comes to checking alts 2017-06-18 13:52:34 -07:00
Bär Halberkamp
02347fde67 Don't punish other users on shared IPs 2017-06-18 13:52:34 -07:00
Guangcong Luo
6dd58b40d3 Refactor simulator into new sim/ directory
This is a surprisingly minor refactor considering how many files it
touches, but most of this is only renames.

In terms of file renames:
- `tools.js` is now `sim/dex.js`
- `battle-engine.js` is now `sim/index.js` and its three classes are
  in `sim/battle.js`, `sim/side.js`, and `sim/pokemon.js`
- `prng.js` is now `sim/prng.js`

In terms of variable renames:
- `Tools` is now `Dex`
- `BattleEngine` is now `Sim`
- `BattleEngine.Battle` is now `Sim.Battle`
- `BattleEngine.BattleSide` is now `Sim.Side`
- `BattleEngine.BattlePokemon` is now `Sim.Pokemon`
2017-05-05 16:48:38 -05:00
Guangcong Luo
cf58d55597 Make sysops skip message throttle
(This is relevant for recovering from message throttle bugs)
2017-04-28 02:50:17 -04:00
Guangcong Luo
1e64937d37 Fix onConnect
Both #3426 and #3433 are wrong; the double-connect is intentional.
2017-04-06 02:09:37 -04:00
Charlie Kobayashi
05d9bd07b7 Users#mergeConnection - run room.game.onUpdateConneciton for battles (#3433)
* Users#mergeConnection - run room.game.onUpdateConneciton for battles

(1) oops, forgot that battles were roomgames as well, so they needed to update for dc's (guest => player) and send the requests accordingly
(2) I'm so bad

* Use PS style conventions
2017-04-05 19:30:35 -04:00
Charlie Kobayashi
246ebde9c9 Room-games: dont rename players to their guest accounts (#3425) 2017-04-04 16:56:23 -04:00
Charlie Kobayashi
83210c9db3 Users: fix RoomGame connection update (#3426)
- prevents onConnect from being called twice in onUpdateConnection AND in joinRoom for autojoin.

```
CRASH: Error: onConnect
    at ScavengerHunt.onConnect (/home/ubuntu/workspace/suppress/chat-plugins/scavengers.js:137:9)
    at ChatRoom.onConnect (/home/ubuntu/workspace/suppress/rooms.js:1369:51)
    at User.joinRoom (/home/ubuntu/workspace/suppress/users.js:1181:9)
    at User.tryJoinRoom (/home/ubuntu/workspace/suppress/users.js:1143:25)
    at CommandContext.autojoin (/home/ubuntu/workspace/suppress/chat-commands.js:1334:13)
    at CommandContext.run (/home/ubuntu/workspace/suppress/chat.js:292:28)
    at CommandContext.parse (/home/ubuntu/workspace/suppress/chat.js:138:19)
    at Object.Chat.parse (/home/ubuntu/workspace/suppress/chat.js:807:17)
    at User.processChatQueue (/home/ubuntu/workspace/suppress/users.js:1433:9)
    at Timeout.chatQueueTimeout.setTimeout [as _onTimeout] (/home/ubuntu/workspace/suppress/users.js:1413:15)

Additional information:
  user = Guest 2
  room = global
  pmTarget = undefined
  message = /autojoin gamecorner,scavengers



CRASH: Error: onConnect
    at ScavengerHunt.onConnect (/home/ubuntu/workspace/suppress/chat-plugins/scavengers.js:137:9)
    at ScavengerHunt.onUpdateConnection (/home/ubuntu/workspace/suppress/room-game.js:174:28)
    at connection.inRooms.forEach.roomid (/home/ubuntu/workspace/suppress/users.js:891:15)
    at Set.forEach (native)
    at User.mergeConnection (/home/ubuntu/workspace/suppress/users.js:878:22)
    at User.merge (/home/ubuntu/workspace/suppress/users.js:833:9)
    at User.handleRename (/home/ubuntu/workspace/suppress/users.js:738:9)
    at User.validateRename (/home/ubuntu/workspace/suppress/users.js:698:8)
    at Verifier.verify.then.success (/home/ubuntu/workspace/suppress/users.js:652:10)
    at process._tickCallback (internal/process/next_tick.js:103:7)
```
2017-04-03 20:34:56 -04:00
Ben Davies
5adac2bc56 Matchmaking: fix crash on user disconnect/merge
Challenges and searches weren't being cleared properly after moving
them out of GlobalRoom#onLeave.
2017-03-20 17:01:42 -05:00
Ben Davies
213b697d7c Rooms: move matchmaking logic to ladders-matchmaker.js (#3364)
This abstracts matchmaking logic from the global room away to its own
module, allowing the two to be decoupled from each other entirely with
some refactoring.

Related to #3361
2017-03-17 02:42:30 -05:00
Ivo Julca
42035aa907 Improve User#authAtLeast
- Always return a boolean. *Sometimes* returning the name under which a user qualifies is not useful enough.
- The default for an invalid group or pseudo-group is now false. Though maybe it should throw instead?
- Users with auth in the relevant room are now treated as trusted.
2017-03-04 19:46:00 -05:00
Ivo Julca
1efd21547e Merge chat queues when renaming to an existing user
Previously, pending chat messages from the destroyed user were lost.
2017-03-04 19:40:10 -05:00
Guangcong Luo
60b788cf96 Fix grammar/style
Credit to #3304
2017-03-01 02:41:38 -05:00
Charlie Kobayashi
9dd4236479 Prevent permalocked users from getting unlocked (#3303) 2017-02-28 00:49:54 -04:00
Guangcong Luo
a8393c40ed Support Config.loglevel
Another undocumented config setting; this one lets you specify what
you want to appear in standard out.
2017-02-25 02:48:16 -05:00
Guangcong Luo
e45b52a57b Fix DeprecationWarnings for lack of callback
Various standard library functions now warn for lack of callback, so
this commit adds those callbacks.
2017-02-10 17:10:15 -05:00
Bär Halberkamp
37205d9b24 Implement /sharedip (#2870)
* Implement /markshared

* Refactor /whois ips to two lines

* Refactor splitTarget
2016-12-25 14:26:17 -08: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
panpawn
f5271bb753 Refactor confirmed status to trusted (#2798)
It should be noted that various user functions have been renamed as well to reflect this change as well.
2016-09-29 13:02:14 -07:00
Quinton Lee
dce63c36d7 Validator: support supplementary banlists (#2794) 2016-09-29 00:41:06 -07:00
Guangcong Luo
b459771619 Refactor CommandParser
CommandParser.parse has been refactored so most of its logic now
resides in CommandContext#parse.

CommandParser recursion is now a lot lighter. Instead of make a new
copy of the CommandContext, the existing one is reused.

messages.js no longer needs to exist; its functionality is now in
CommandContext#parse and CommandContext#canTalk. Its duplicate code
is gone now! :D

The inNamespace option of CommandContext#parse appears unused and has
been removed.

Users#matchesRank has been renamed Users#authAtLeast.
2016-09-28 22:13:07 -07:00
Guangcong Luo
e87c072fe8 Suppress crash in roomgame 2016-09-27 04:23:40 -04:00
Guangcong Luo
53dd09fba0 Refactor modjoin
This unifies modjoin checks (both Room#modjoin and Room#staffRoom join
restrictions) under one function, Room#checkModjoin.

This makes it easier for commands to check whether a user should know
about a room's existence, which, previously, had been duplicated
unreliably in each command's implementation.

Fixes #2426
2016-09-24 23:14:16 -07:00
Guangcong Luo
6d3a3bf7f0 Suppress crash in Users
Closes #2775
2016-09-24 13:50:59 -07:00
Bär Halberkamp
baad5271a4 Add /blacklistname 2016-09-24 22:49:51 +02:00
Ivo Julca
5bacd55a91
Drop messages sent to non-existent rooms 2016-09-19 20:09:08 -05:00
Ivo Julca
8713026c8b
Fix several crashes due to missing room properties 2016-09-18 01:05:26 -05:00
Ivo Julca
ce9cdecafd Drop commands sent to rooms from outside 2016-09-17 19:42:15 -05:00
Guangcong Luo
816dd3380d Suppress crashes with roomgame handling
In theory, this code shouldn't crash, but I don't really have the
time to track down exactly what the problem is right now.
2016-09-17 04:31:11 -04:00
Guangcong Luo
05ae323fcd Refactor roombans/blacklists
Roombans/blacklists have been mostly rewritten from scratch.

The new code mostly uses the same patterns as global punishments.

In addition:
- /ban has been renamed /globalban
- globalbans and blacklists now require a reason
- bans and blacklists in public rooms now show up in global modlog
- blacklist syntax is different: /blacklist and /unblacklist
- ban/blacklist display in /whoare is now more detailed
2016-09-16 10:27:26 -07:00
Guangcong Luo
7a7b46bc1e High priority blacklists fixes
This isn't all the work that needs to be done on blacklists, but it's
the highest-priority changes.

- blacklists.tsv has been renamed room-punishments.tsv
- The format everywhere has changed to roomid:userid, rather than
  roomid|userid
- roompunishments.tsv's format is now `Room ID:User ID, IPs and alts`
  rather than `User ID, Room ID|IPs and alts`, which is more sane and
  also cuts down on repetition of room IDs

Those are the changes that affect storage format, which are highest
priority because I don't want to support the previous format.

Other changes include:
- Punishments.roombannedIps renamed to Punishments.roomIps
- Punishments.roombannedUserids renamed to Punishments.roomUserids
- Some refactoring for ES6 destructuring
- Various bugfixes
2016-09-15 06:10:54 -07:00
Bär Halberkamp
28c0a2a22c Rewrite roombans to be timed as well (#2545)
Also implement blacklists
2016-09-15 04:35:00 -07:00
Guangcong Luo
310fdaa898 Refactor out Room#chat
Room#chat has now been folded into CommandParser.parse.

User#chat now directly calls CommandParser.parse, saving a line of
stack, and eliminating a function that never did much, really.
2016-09-12 19:01:35 -07:00
Guangcong Luo
c030c84245 Move "too many battles" messages to monitor.js 2016-09-10 15:52:16 -04:00
Guangcong Luo
6f53fcff3a Remove User#broadcasting
This flag seems like it's no longer used for anything, and leads to
weird bugs.
2016-09-04 00:02:22 -05:00
Guangcong Luo
98071aca1a Make the 'root' permission global
The 'root' permission used to be applied globally, but a refactor made
it apply per-room, so admins wouldn't have the permission while in
private rooms and rooms they have other roomauth in.

This once again makes 'root' a global permission.
2016-09-04 00:02:22 -05:00
Guangcong Luo
54b672fe4e Start refactoring for template strings
This commit introduces Tools.html and Tools.plural, helper functions
for string construction.

Tools.html is a template tag function that escapes HTML inside the
template string.

Tools.plural is a helper function that takes a passed Number, Array,
Set, or Map and returns a string representing whether or not it's
plural.

It also starts doing some refactors of some files to make it clear how
I expect code style for template strings to look.

Previously, we used ' for IDs, " for English text, and ' for code.

We should now be using ' for IDs, ` for English text, and ` for code.
2016-08-28 04:35:43 -05:00
Guangcong Luo
4523078519 Refactor User#games from Map to Set
User#games no longer retains games; it instead gets them from
Rooms(roomid).game.

The Trivia tests needed to be fixed for fidelity to continue passing.
2016-08-27 02:16:58 -05:00
Guangcong Luo
7017029dc1 Track connection.protocol
This should make it easier to hunt down that bug that's causing SockJS
not to disconnect.

(I have suspicions that it's related to websocket-raw but it's always
nice to get more data...)
2016-08-27 01:01:09 -05:00
Guangcong Luo
7a623b150b Fix bug in user count
be75115e4 accidentally messed up how user merging works.
2016-08-22 16:18:54 -05:00