Commit Graph

29 Commits

Author SHA1 Message Date
Zorchenhimer 7ac34c7d05 Fix name highlighting breaking emotes
Fix name highlighting when emotes are involved.  When the emotes were
moved to subfolders the channel name was put into the URL of the emote
image.  If a user with that name joined the chat, all of the emotes in
that folder highlighted the name in the URL, breaking the <img> tag.

This change removes the regex used to identify and replace the user's
name and instead works on whole words delimited by spaces.
2019-09-22 15:42:48 -04:00
Zorchenhimer d513fe872d Remove temp connections
Temp connections were removed to reduce some complexity.  Now a
connection is a full client, even before joining chat.  A name is
required to be set to join chat and receive messages.

This change also removes the need for UUIDs on connections and clients.
2019-04-13 15:56:49 -04:00
Zorchenhimer 81e647c1c8 Handle command errors differently than responses
Make them red.
2019-04-11 22:01:10 -04:00
Zorchenhimer 5508dc3f1c Return errors from commands
Change the function signature for commands to return a string as well as
an error.  Currently, errors are handled no differently than normal
response messages.

Also removed the redundant `/setpin` command.
2019-04-11 21:10:04 -04:00
Zorchenhimer 67b3143893 Add rate limiting
This should fix #65, although it may be expanded in the future.

Default settings for limits can be changed or disabled in the settings.
Default values:
- Chat: 1 second
- Duplicate chat: 30 seconds
- /nick: 5 minutes
- /auth: 5 seconds
- /color: 1 minute

Creation of the chat Client object has been moved from ChatRoom.Join()
to NewClient().  This function also handles setting the initial name.
2019-03-30 15:40:37 -04:00
joeyak 8e4ac4d600 Add color cookies
closes #6
2019-03-28 20:01:48 -04:00
Zorchenhimer a8ee9db3b8 Fix #63, case-sensitive highlight
Make the name highlight code case-insensitive, and only match whole
words.

This fixes an unreported issue with emotes.  If a user's name was in
an emote, the emote image was broken by placing the highlight span in
the image's url attribute.
2019-03-28 15:38:00 -04:00
joeyak 86207ecd48 Added spoilers in chat
If a user clicks the spoiler, it will change color and the background will revert.
closes #62
2019-03-24 23:43:30 -04:00
Zorchenhimer 5d10fdfea4 Forgot to remove a DevLogLn(), and two fixes
Good news, it breaks Travis like it's supposed to! I also forgot to add
the `common` namespace during a rebase.  Whoops.

Resolves #46
2019-03-24 19:03:19 -04:00
Zorchenhimer fdbf39f00c Add some logging
Functions added:
- LogErrorf()
- LogErrorln()
- LogChatf()
- LogChatln()
- LogInfof()
- LogInfoln()
- LogDebugf()
- LogDebugln()
- LogDevf()
- LogDevln()

New settings configure the logging: LogLevel and LogFile.  LogLevel can
be set to one of: error, chat, info, or debug and will default to
error.  LogFile is an optional file to write to.  Providing a file will
not prevent output in the console.

LogDevf() and LogDevln() only compile when the "dev" flag passed to
build.  This will cause Travis-CI to fail the build if it finds any
calls to either function.
2019-03-24 18:58:59 -04:00
joeyak cd34480bba Change auth level checking to be on command level
The server sends new auth level to user when modded
closes #60
2019-03-24 17:27:04 -04:00
joeyak 0de457d28f Change highlighting to be a box instead of the user color
This allows users with hard to read colors to still see mentions
issue #48
2019-03-21 09:27:14 -04:00
joeyak b2d62ad42b Add name highlighting
The server adds name highlighting to the message to be the same color as the user's tag.
resolves #48
2019-03-21 09:04:57 -04:00
joeyak 355f09bd48 Refactoring of ChatData
The processing of ChatData was changed so ChatData has a DataInterface object, which will be converted to a
ChatDataJSON that will have the DataInterface field converted to a json.RawMessage field. This change allows
greater customizability in the chat messages, since the Data field can still be read and modified.
2019-03-21 08:47:40 -04:00
Zorchenhimer f7b362519d Parse X-Forwarded-For header if provided
Parse the X-Forwarded-For header if it exists in the connection.  This
will allow bans to work if the server is sitting behind an Nginx
reverse proxy (that has been configured to add the header).

Also added a safe-guard to disallow bans for localhost so you cannot
accidentally ban everybody from connecting if the server is behind a
reverse proxy.

This should resolve #49
2019-03-20 16:57:29 -04:00
Zorchenhimer 1c6c23da3e Add /nick command
Using this command will change the current user's nickname in chat.
It has an alias of /name.

An admin can force a name change by supplying the current name and a new
name.  If a name has been changed by an admin, that user can no longer
change their name (similar to forced color change).

Resolves #42
2019-03-19 17:13:20 -04:00
Zorchenhimer 7dff29b152 Add user badges
Add badges for admins and mods.  Admins get a red badge, and mods get a
green one.

Normal users do not get a badge.
2019-03-16 18:11:27 -04:00
Zorchenhimer e94ceda655 Fix the command response
Respond to commands with the output of the command, not the command
received.  Also, don't use the server message formatting.
2019-03-16 14:37:34 -04:00
Zorchenhimer f18b790c4d Wrap connection reads and writes with a mutex
Wrapping the connection with a mutex prevents the "concurrent write to
websocket connection" panic.  The new functions are ReadData() and
WriteData so as to not collide with ReadJSON() and WriteJSON().
2019-03-16 13:44:18 -04:00
joeyak a717c6ef38 Converting from conn.WriteMessage to conn.WriteJson
This takes away some of the work on the developers side to worry about parsing the object as a json string.
Backend work for issue #7
2019-03-15 17:28:29 -04:00
joeyak 678ccab95c Add some backend infrastructure
The server can now send the client objects with data for the client to process.
issue #7
2019-03-15 02:19:16 -04:00
joeyak 60dd98a1e7 Add infrastructure for the client to send formatted data to the server 2019-03-14 15:21:53 -04:00
joeyak 2ef3684c14 Some linting fixes for the common package 2019-03-13 21:24:14 -04:00
joeyak 5516313c79 Allow chat to be sent before the name is sent to the server
closes #17
2019-03-13 16:47:19 -04:00
Zorchenhimer bdd4e71261 Flesh out the JSON stuff a bit more
Implement some commands in the wasm client code:
  - /playing (setting and clearing)
  - /refreshplayer
Commands not yet implemented:
  - /purge (command doesn't exist yet on server)
  - /help (doesn't open window)
2019-03-13 13:42:38 -04:00
Zorchenhimer 9c80269943 Start convert to JSON data b/t client and server
Chat and events should work.  Commands do not work yet.  Everything
also needs to be tested and cleaned up a bunch more.
2019-03-13 01:09:24 -04:00
Zorchenhimer b62b89c13e Fix formatLinks() not working
This broke when moving to the standard library for escaping and
unescaping HTML.  The original escaping code replaced "//" with
"&x2F;&x2F;" while the standard library doesn't.
2019-03-11 15:41:41 -04:00
joeyak df6b6da044 Some minor fixes in readme and linting errors 2019-03-10 13:41:06 -04:00
Zorchenhimer 3276295421 Initial commit
So far things work.  Needs lots of improvements.
2019-03-10 11:42:12 -04:00