Commit Graph

197 Commits

Author SHA1 Message Date
Guangcong Luo
847878038c Autorewrite /me's to /mee 's
You can think of this as now supporting any punctuation after /me, not
just a space.
2016-02-29 02:08:37 -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
2d7b449a2c Emergency fix for /constructor 2016-02-21 17:35:04 -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
8a8838552d Improve crashlogger
Crashlogger now supports passing in a dictionary of additional
information to report, so we no longer need to resort to making fake
errors.

The hadException parameter has now been removed entirely. I don't know
of a use case for it to be false.
2016-02-04 03:04:05 -06:00
Marty-D
a088853208 Filter more zalgo-like characters 2016-01-02 17:25:54 -05:00
Konrad Borowski
81f602b8d8 Always use trailing comma for multiline objects 2016-01-01 00:20:07 +01:00
Guangcong Luo
b56ddc7d78 Allow style tags on buttons in private roomintros 2015-12-30 15:49:32 -05:00
Guangcong Luo
aa5b659cac Ban certain zalgo-like characters 2015-12-19 04:12:31 -05:00
Guangcong Luo
381d66a01b Nicer error message for <button> permission 2015-12-17 06:28:52 -05:00
Guangcong Luo
13b2ba1622 Fix image src validation in canHTML 2015-12-14 16:25:14 -05:00
Guangcong Luo
4fa910a932 Add Droplr to list of valid HTTPS domains 2015-12-14 16:25:14 -05:00
Guangcong Luo
a659f6733f Don't require HTTPS for images
Most images are hosted in places that already support HTTPS, so all
we need to do is transparently rewrite them to be protocol-local.

For the rest, I don't care enough to enforce HTTPS on them. At
least wait for browsers to complain more about it...
2015-12-12 20:52:56 -06:00
Ivo Julca
303155bdf3 Require HTTPS for images 2015-12-11 21:55:41 -05:00
Guangcong Luo
c40daad1cf Fix modchat permissions
It's no longer possible to set a modchat level you can't clear.
2015-11-24 10:07:06 -05:00
Guangcong Luo
a64875c2ed Refactor command permissions to use canTalk
Previously, we were manually checking muting and locking to see
whether or not a user was allowed to mute, modnote, etc.
2015-11-23 09:13:12 -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
Guangcong Luo
378fc2eb25 Ban buttons in private rooms 2015-10-10 02:22:45 -04:00
Guangcong Luo
dd562ce1fd Drop support for passing username to getLastIdOf
This is unreliable and crash-prone and not actually used anywhere.
2015-10-10 02:22:45 -04:00
Guangcong Luo
1c9a971820 Buttons are now banned in personal rooms 2015-10-09 04:46:38 -04:00
Guangcong Luo
87023373a2 Document why image width/height is required 2015-10-07 02:13:23 -04:00
Ivo Julca
c94fe4a4e0 Fix errorReply for broadcast commands 2015-10-03 22:49:29 -05:00
Guangcong Luo
94cfd2b492 Disallow images in personal rooms 2015-10-01 18:10:06 -04:00
Guangcong Luo
810b74b2d1 Unify group chat modlogs
Group chat modlogs now work like battle modlogs, they're unified
instead of being spread out over every file.
2015-09-23 17:53:06 -04:00
Guangcong Luo
d34138f81e /invite will try to roomvoice if necessary
If a room is under modjoin, /invite will try to roomvoice a user who
doesn't already have permission to join the room.

This feature is pretty rudimentary and only works if the modjoin
setting is `+`, but I'm 80% sure it's better than nothing.
2015-09-23 03:36:32 -04:00
Guangcong Luo
f0ce808f4d Drop support for modchat crash
Modchat crash is no longer used for any crashes at all, so we might
as well simplify some code complexity and remove support for it.
2015-09-01 02:45:10 -05:00
Guangcong Luo
d287a4150d Load chat-plugins/info.js first so it can be shadowed 2015-08-09 04:20:29 -04:00
Ivo Julca
cd36fbfde2 Gulpfile: add more JSCS rules
- Disallow spaces between function names and round brackets.
- Disallow spaces inside array/object literal brackets.
- Disallow spaces before semicolons.
- Disallow yoda conditions for equality.
2015-07-28 19:38:53 -05:00
Guangcong Luo
800983f8f7 Fix this.inputUsername with no comma
This fixes the this.inputUsername API for .splitTarget for commands.
Mainly relevant to using /lock and /ban on a user who's renamed
themself.
2015-07-26 04:51:51 -04:00
Guangcong Luo
77dfc68445 Unlink/hide spammer usernames through renames
This also adds a new variable from .splitTarget, .inputUsername,
which represents the username before following the user through
renames.
2015-07-18 14:31:41 -04:00
Guangcong Luo
d206d3cc28 Allow admins to talk in private modchat rooms 2015-07-18 14:31:41 -04:00
Ivo Julca
cea3a13c11 Fix API to parse broadcast commands
Fixes the long-standing issue of bad interaction between `this.parse('!command')` and `this.canBroadcast()`: each time the latter was called, it would announce the command usage.
2015-07-14 04:40:32 -05:00
Guangcong Luo
57de9bacc9 Fix // becoming /// in command parser 2015-07-13 04:03:02 -04:00
Guangcong Luo
c5818939c8 Fix leading space getting around command permissions 2015-07-12 05:03:35 -04:00
Guangcong Luo
cdf0c2573d Use .id instead of .filename in uncacheTree 2015-07-02 03:42:07 -04:00
Guangcong Luo
bed5a46ff3 Improved command identification
! followed by a non-alphanumeric character is no longer recognized
as a command.
2015-06-30 22:35:31 -04:00
Guangcong Luo
c77f1b2ef7 Refactor namespace support 2015-06-30 21:12:12 -04:00
Guangcong Luo
806f003863 Use errorReply for command parser errors 2015-06-30 21:12:12 -04:00
Guangcong Luo
4c852e713f Drop support for returning /text from a command
Previously, this was used as a way to recurse from Config.chatfilter,
but Config.chatfilter is passed a Context now, which makes this
unnecessary.
2015-06-30 21:12:12 -04:00
Guangcong Luo
222bc48aa9 Drop support for Context#originalMessage
The old `.message` is dropped, and the new `.message` is the old
`.originalMessage`.

Having a fake `.message` pretending a namespace command is a
top-level command seems entirely unnecessary, so I still don't
really understand what it's for in the first place.
2015-06-30 21:12:12 -04:00
Guangcong Luo
2c7ad95635 New command API this.errorReply
this.errorReply sends a red error message inline. The main special
thing is that it takes advantage of our new /error support in PMs to
send inline errors in PMs as well.
2015-06-30 03:09:02 -04:00
Guangcong Luo
0aff3445a5 Pass command context to Config.chatfilter 2015-06-30 03:05:29 -04:00
Guangcong Luo
89535e95b9 Fix crash when shadowing commands.js commands
This was done by applying chat plugins to the cloned commands
object rather than the original, which should probably have been
done in the first place.
2015-06-30 03:01:55 -04:00
Guangcong Luo
9529644e0b Fix crash in globalModlog 2015-06-29 01:56:02 -04:00
Guangcong Luo
7419a03626 Modlog refactor
The modlog API is now accessible from outside of CommandParser
through CommandParser.writeModlog.

We now also have a concept of a global modlog, and some new
command APIs for writing to it.
2015-06-27 22:35:31 -04:00
Guangcong Luo
53516692ec Export CommandParser.baseCommands
These are commands from commands.js, before they're possibly
overwritten by other chat commands. It's a shallow copy so memory
impact will probably be minimal.
2015-06-27 22:32:51 -04:00
Guangcong Luo
e6d952b035 Clarify command-not-found message
The previous text implied that it was possible to send !command
without broadcasting. This isn't actually possible.
2015-06-25 17:53:40 -04:00
Ivo Julca
2db4b6bf44 Misc command parser fixes
- Return proper error message for forbidden commands.
- Fix a recursive crash in lobby-less servers.
- Fix a stack overflow in some (very stupidly) modded servers.
2015-06-24 20:49:39 -05:00
Ivo Julca
9b1b078534 Command API: this.run executes a command with current parameters
- Provides a straightforward way to add command aliases with own help entries.
- Encapsulates try-catch blocks.
2015-06-24 18:35:58 -05:00
Ivo Julca
00640a5218 Command API: this.cmdToken is either '/' or '!' depending on input
Also adds feature parity for !commands to be escaped with double !,
and to be returned from `canTalk`.
2015-06-24 18:35:33 -05:00
Ivo Julca
214fd79fdf Refactor command context creation to use a prototype
Also support custom extensions to command API from plugins.
2015-06-24 18:34:16 -05:00
Guangcong Luo
b792fa64e9 Merge pull request #1867 from SolarisFox/patch-7
Mute refactor
2015-06-16 07:40:57 +00:00
SolarisFox
09be77d0b8 Mute refactor 2015-06-14 00:16:44 -07:00
Guangcong Luo
0450e7d9c9 Support writing to other rooms' modlog
Apparently modlog is in CommandParser, which doesn't make it very
straightforward to access outside of the this. functions in
commands. This change at least makes it possible to write to
other rooms' modlogs in commands, but in the long term we might
want to move modlog from CommandParser to Rooms, or at least
expose an API accessible outside of commands.
2015-06-12 03:28:46 -04:00
Guangcong Luo
665ef46145 Improve PM support in Config.chatfilter
The user the PM is being sent to is now passed to .chatfilter
(and canTalk et al).
2015-06-05 13:22:53 -04:00
Guangcong Luo
621328c18d Optimize canTalk a bit 2015-05-27 14:37:17 -04:00
Ivo Julca
4222ffb5df Dependant support: make sure that relative paths are resolved properly 2015-05-11 15:38:18 -05:00
Guangcong Luo
c333cb8aad Add basic tag-matching validator to canHTML
This gives commands like !htmlbox and /roomintro a basic validator,
to warn about typoes related to mismatched HTML tags. This is NOT
intended to be secure (we have a separate sanitizer client-side for
that), but is intended to guard against user error only.
2015-04-29 00:07:25 -04:00
SolarisFox
336cbc462a Move config/commands.js to chat-plugins 2015-04-25 00:44:07 -07:00
Ivo Julca
b9b4196314 Command crash logs now report full message sent
Accounting for namespaces
2015-04-17 00:46:23 -05:00
Guangcong Luo
461303e466 Disallow 'click here' in roomintros
'Click here' as link text is heavily recommended against, but it's
easy to forget, which makes it a good thing to ban programmatically.
2015-04-17 00:36:17 -04:00
Morfent
ce1724e179 Replace all s.substr(x, 1) with s.charAt(x) 2015-04-06 21:20:43 -03:00
SolarisFox
b3a942aa71 Fix broadcast cooldown message checking.
Include characters that are important to the function of commands.
2015-03-25 22:59:53 -07:00
codelegend
916814de24 remove unused argument in Room#add calls 2015-03-18 22:11:19 +05:30
Guangcong Luo
c10498bcab Merge pull request #1312 from ascriptmaster/modbattle
Private Room refactor - Distinguish hidden and secret rooms
2014-12-23 16:40:52 -06:00
Guangcong Luo
0f2e92ede8 this.parse is global by default
this.parse in chat commands was changed to default to parsing
in-namespace, when namespaces were introduced. This commit changes
it back to parsing globally, with in-namespace parsing being
optional and defaulting to off.
2014-12-23 16:37:57 -05:00
ascriptmaster
fa79202649 Private Room refactor - Distinguish hidden and secret rooms
Seperated /privateroom command into /privateroom and /hiddenroom. In
hidden rooms, mostly set by battle players, global staff maintain their
ranks within the room, but the rank is not kept in secret/private rooms
(only set by users who can create chat rooms).

Created command /whoare to allow global staff to see the hidden rooms a
user is in.
2014-12-22 02:39:50 -08:00
小太
05b3327b91 Add namespace-like functionality to commands
where object command handlers represent a new namespace
2014-12-15 00:33:55 +11:00
Guangcong Luo
1cf90b54ae Update Config.chatfilter API 2014-12-01 16:52:00 -05:00
Guangcong Luo
db09d66039 Update zalgo filter 2014-12-01 16:49:29 -05:00
Guangcong Luo
4c32621593 Reintroduce command crashguard
If a crash happens during a command (which is around 99% of all
crashes), a bug in either Node or SockJS causes the user who issued
the command to be unable to do say or do anything (although they'll
still receive messages).

We used to have a crashguard to prevent this from happening, but
it was removed due to suspicions of being a significant lag source.
Later lag investigation has shown that it's not the biggest source
of lag, so we're reintroducing that crashguard for now.
2014-10-21 16:49:22 -04:00
小太
ae6da14ca0 Misc cleanup
The important fixes from pull request #865
2014-10-12 21:34:59 -05:00
Guangcong Luo
2fbb1d52a3 Optional 'global' for global promotion/demotion
Adds support for adding the word 'global' in front of global
promotion/demotion commands, for instance /globalmod username
to promote a user to global mod.

Also adds /roomdeauth.
2014-10-12 22:13:22 -04:00
小太
5027be79fb Add jscs as a style checker, and add some extra jshint options 2014-09-29 18:38:01 +10:00
Guangcong Luo
4a761b470d Update zalgo filter
Some users were using some zalgo not caught by the current filter.
The new filter fixes that.
2014-09-05 23:16:14 -04:00
Guangcong Luo
34f9137d69 Fix crash when sending '/ ' 2014-09-04 16:19:20 -04:00
Guangcong Luo
0570c0dbcb canTalk now supports returning /command
returning /command will parse the command returned. This is mainly
useful for Config.chatfilter.
2014-08-30 02:12:09 -04:00
Guangcong Luo
7bf6269813 Remove lobby spoiler filter
It belongs in the config chatfilter
2014-08-22 00:35:04 -04:00
Guangcong Luo
b1cd4e81dc New command API sendModCommand
Does the same thing as privateModCommand, but without logging it
2014-08-12 20:42:35 -04:00
Guangcong Luo
af2026436a More style fixes and Gulpfile updates
JSHint is now a fair bit stricter, and is now correctly checking
files in `mods/`.

The code has been fixed to match the new stricter standards.

JSHint has now caught its second actual bug: Gen 5 Pinap Berry
was Ice instead of Grass.
2014-08-10 20:43:53 -04:00
Guangcong Luo
12b673bb49 Fix style errors; update gulpfile
I used a hack to make the multiple declaration errors go away,
so all that remained in jsHint were actual errors, which I've
now mostly fixed.

All this linting ended up uncovering one actual bug: Uproar's
message not showing. It's a very minor bug in a move no one uses,
so I'm going to fold it into this commit.
2014-08-10 18:06:44 -04:00
Morfent
57482eb7f9 Only merge .js files from ./chat-plugins/ 2014-08-07 07:19:26 -03:00
小太
a2bfb57bfe Move chat plugins to their own directory 2014-08-04 18:33:52 +10:00
Guangcong Luo
21ec515844 nimp no longer needs to be hardcoded 2014-07-27 02:25:46 -04:00
Relados
965ec31d27 Add missing '/' in unrecognized command message
Using '//' would begin a message with '/' and the message should reflect that accurately.
2014-06-30 09:39:30 -05:00
Guangcong Luo
7474c79330 Fix bug in HTML validator 2014-06-28 09:12:00 -04:00
Guangcong Luo
73e3ffaf9a Roomintro feature 2014-06-26 22:53:37 -04:00
Guangcong Luo
3f862c4049 Roomauth can see private commands 2014-06-18 01:23:50 -04:00
TalkTakesTime
4d5f32fd4c Refactor unlinking code 2014-05-06 00:08:54 +12:00
小太
31d784cfd0 Fix previous fix... 2014-04-22 02:51:32 +10:00
小太
031127085d Fix missed quote in command-parser.js 2014-04-22 02:46:33 +10:00
小太
5c8fc7b982 Space after function for anonymous functions 2014-04-22 01:58:16 +10:00
小太
6fb3bc332a Spaces around operators and === instead of == 2014-04-22 01:56:11 +10:00
小太
071863d9f8 Use proper quotes for all the command related files and other minor cleanup
Proper quotes are " for strings that will eventually be read by a human and ' for everything else
2014-04-21 18:55:08 +10:00
Guangcong Luo
de3b4c4432 Introduce !htmlbox
Displays an HTML box. Can only be used by leaders+, or by
roomowners who are also globally drivers+.
2014-04-20 02:54:42 -04:00
Slayer95
05e7060474 Deprecate 'toUserid' global
Replaced by 'toId'.
2014-04-18 16:49:16 -05:00
Slayer95
4c18aa60f1 Remove global 'fs' 2014-04-17 14:37:32 -05:00
Slayer95
75559362b4 Rename global config to Config 2014-04-17 01:12:28 -04:00
Guangcong Luo
2bf7416bcc Refactor targetUserOrSelf
It now always fills out targetUsername, and passes the exactName
flag through to splitTarget. /whois will no longer follow through
name changes unless the /whois user has auth (voice counts).

This is not a secure way to hide from unvoiced users; other
commands such as PMing will still follow through.
2014-04-15 16:46:12 -04:00
Guangcong Luo
f3b698581a Drop support for server version hashing 2014-04-10 19:04:24 -04:00