Commit Graph

55 Commits

Author SHA1 Message Date
Clif Gordon
de117eb5a9 Prepend @ symbol to names shown in user list, so they highlight
(cherry picked from commit abfeb0c1cf270e90496f42e3545eafd2dc518782)
2020-05-28 16:41:28 -04:00
Zorchenhimer
c32838def6 Rework settings mutex and saving settings
- Move mutex into Settings struct
- Replace sync.Mutex with a sync.RWMutex
- Move adding approved emotes into a Settings method
- Save settings after adding emotes
- Wrap saving in a lock
2020-01-30 14:32:46 -05:00
Zorchenhimer
8fc3f86135 Add an emote list
It's ugly, but it get's the job done.  This list will need to be
improved a lot (ie, make it searchable and maybe even clickable
emotes?).  This is for #99, but should not be considered fixed yet.
2019-11-29 12:48:17 -05:00
Zorchenhimer
47c837733d Fix /nick for mods and admins
- Gave mods permission to /nick somebody else
- Don't check for timeout when a mod or admin attempts to change a name.
2019-11-09 19:24:27 -05:00
Zorchenhimer
32d58f6f3f Make /pin a user level command
The /pin command is now accessable by non-modded users.
2019-09-22 17:02:09 -04:00
Zorchenhimer
6347065dd4 Fix duplicating emotes with /reloademotes
Don't reload emotes directly into the global common.Emotes variable.
Instead, load them into a new variable and write that to common.Emotes
after the search for new emotes completes.  Emotes should no longer
duplicate for each run of `/reloademotes`.

Also tweaked `/addemotes` to automatically reload emotes if nothing went
wrong downloading a new set.
2019-09-22 16:51:13 -04:00
Zorchenhimer
a73375f152 Fix emotes
This reworks how emotes are cached in relation to their physical
location on disk.  Functionally, they should be the same from the user
perspective but it sets up some stuff that will make it easier to add
emotes from various sources.
2019-06-18 22:13:53 -04:00
joeyak
7962fad02e commiting so zorch can do my work 2019-06-01 19:41:28 -04:00
Zorchenhimer
0a4ff49cbb Trim PIN of spaces
Fixes #88
2019-04-22 11:50:42 -04:00
Zorchenhimer
607e61234c Add some more stats
Added a few more stats to keep track of:
- Max users in chat
- Stream start

Also added a `/stats` command to list the user count (current and max),
as well as uptime (sever and stream, separately).

Resolves #85
2019-04-14 00:25:49 -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
27ef839725 Fix regression with the /me command
Don't return an error if it works.
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
d102d0c5ed Merge remote-tracking branch 'origin/room-access-restrictions'
Merge in the room access restrictions changes into master.  Currently,
only the PIN/Password method is implemented, and it's not all that
secure.  Some more work needs to be done in planning before really
moving forward, but this should be fine for now.

Issue #28 should not be considered finished with this merge.
2019-04-04 10:29:37 -04:00
joeyak
791df37030 Update client emotes list on reload emotes
closes #75
2019-03-31 17:33:03 -04:00
Zorchenhimer
6b48322626 Use the logger
Replace fmt.Print[f|ln]() with the logger equivalent.
2019-03-30 16:15:22 -04:00
Zorchenhimer
4e35418a79 Merge branch 'master' into room-access-restrictions
# Conflicts:
#	common/chatcommands.go
#	main.go
#	settings.go
2019-03-30 16:04:06 -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
joeyak
7a294ea00f Move color and whoami commands into the commands declaration 2019-03-28 18:40:49 -04:00
Zorchenhimer
fb2c25dc99 Add the /addemotes command
This command launches a goroutine that does the actual downloading of
the emotes so the client doesn't hang until the process is finished.

subscribers.json needs to be manually downloaded and added next to the
main executable for now.  Eventually, it will download and cache this
file (for 24 hours, at a minimum).

Issue #10 should not be considered finished yet.  This needs to be
tested a bit more with multiple channels.  Ideally, some that exist and
some that don't to verify that it fails gracefully (ie, adds the emotes
it was able to download).
2019-03-28 16:50:24 -04:00
Zorchenhimer
857974aef3 Merge branch 'master' into room-access-restrictions
# Conflicts:
#	main.go
#	settings.go
2019-03-26 12:06:25 -04:00
Zorchenhimer
8e27ce9332 Add /iplist to admin commands
Lists all clients' UUID's, names, and IPs to console.

# Conflicts:
#	chatcommands.go
#	common/chatcommands.go
2019-03-26 11:58:46 -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
Zorchenhimer
2f252d5ae8 Strip @ prefix on names in commands
Names can be passed to commands with @ prefixed to them.

When forcing a color change on another user the @ explicitly defines
the name, instead of simply being stripped off.  This will allow the
a user named "red" to have their color changed: `/color @red blue`

A bunch of the color command code has changed with this to make things
less ambiguous and to add some other checks.  `/color red #FF0000` and
`/color @red red` will change the color of the user "red" to the color
red while `/color red red`will return with an error.  Note that the
color an name arguments can be in any order.

Resolves #64
2019-03-24 15:16:01 -04:00
Zorchenhimer
44e8947329 Print the new modes and pins to the console
- When the access mode changes, print the new mode (and pin, if
  applicable) to the server console.
- Don't return an HTTP error when getting a session fails, just make a
  new session.
- Save pins to the settings
2019-03-23 18:08:22 -04:00
Zorchenhimer
7448876299 Merge branch 'master' into room-access-restrictions
# Conflicts:
#	chatcommands.go
#	common/chatcommands.go
#	connection.go
#	static/css/site.css
#	static/main.html
2019-03-23 17:03:28 -04:00
Zorchenhimer
88365b6df5 Add /iplist to admin commands
Lists all clients' UUID's, names, and IPs to console.
2019-03-23 16:53:36 -04:00
Zorchenhimer
8e39585968 Prevent some zero length stuff
Don't send zero length messages to the server, and ignore the /me
command without any arguments.
2019-03-23 15:16:02 -04:00
Zorchenhimer
f36a51bf2b Fix clearing the title
If no title is given with the /playing command, clear the title.
2019-03-23 14:53:29 -04:00
Zorchenhimer
82149cda0c Start adding room access restrictions
So far only PIN and Open modes are implemented.  It uses a session
cookie to store the validity of the pin/password.

The "Enter pin" page has some unreadable messages on it right now, but
it kinda works.
2019-03-22 21:39:55 -04:00
joeyak
1cfa040f7b Added color names as possible arguements for /color
Did some linting fixing too.
Closes #45
2019-03-19 22:56:01 -04:00
Zorchenhimer
49e997c5ff Move some stuff to MovieNight.common
Moved to common/utils.go:
- IsValidName() (function replaces direct calls to regexp.MatchString())
- RandomColor()

Moved to common/emotes.go:
- LoadEmotes()
2019-03-19 17:25:49 -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
0b05a7aea6 Add the /purge command
This is a moderator command that clears chat for everybody.

Resolves #5
2019-03-17 22:30:00 -04:00
Zorchenhimer
b30202441a Add a limit to the title length
Added a limit to how long the title can be when set from the /playing
command.  The default value is 50 if it is not in the settings file or
if the value in the settings is below zero.

Resolves #43
2019-03-16 21:06:16 -04:00
Zorchenhimer
d984269407 Add mod notice to /modpass command 2019-03-16 16:59:12 -04:00
Zorchenhimer
7de20f6145 Allow unmodding yourself if you give your name
Don't deny unmodding yourself if you also provide your name to the
/unmod command.
2019-03-16 16:49:02 -04:00
Zorchenhimer
d0cd90e7af Properly implement the help popup
Move the help html to a template and populate the lists dynamically.
This also splits out the base HTML stuff (eg, the <html> and <body>
tags) to a base template file.
2019-03-16 16:15:55 -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
Zorchenhimer
28d43a726a Add Mod notice messages
These messages are only sent to mods and admins for certain events:
- User gains mod/admin privileges
- User attempts to gain mod/admin privileges unsuccessfully
- Mod/Admin uses the /sv command
- Mod/Admin uses the /playing command
- Mod unmods themselves
- Mod/Admin mods/unmods a user
- Mod/Admin uses the /reloademotes command
- Mod/Admin uses the /reloadplayer command

A separate message queue is used for these messages, and they are only
sent to clients that are either a mod or an admin.  They are sent
with the same call to ChatRoom.Broadcast(), but after all the normal
messages are sent.

Resolves #3
2019-03-15 16:03:31 -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
bb0c3ea736 Fixed printing the combined commands 2019-03-14 15:09:55 -04:00
joeyak
fc126d599e Fix broken multi alias commands
fixes #25
2019-03-14 00:21:41 -04:00
joeyak
2ef3684c14 Some linting fixes for the common package 2019-03-13 21:24:14 -04:00
Zorchenhimer
1cd490b04a Add single-use mod passwords
Single-use moderator passwords can only be generated by an admin with
the /modpass command.  To redeem the password and gain moderator
privileges, a user just needs to call /auth with the password.

The passwords are generated using the same function as the admin
password.  Additionally, generating passwords now uses crypto/rand
instead of math/rand.

Resolves #15
2019-03-13 16:51:07 -04:00
Zorchenhimer
568344a794 Fix /playing when one argument (title) is provided
If /playing was called with a single word (one-word title), it would
clear the title instead of setting the title.
2019-03-13 13:34:26 -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