A basic queue system for Nightbot. The usage is pretty straight forward, !join
and !leave
for users to enter or leave the queue, the user can check their position in the queue with !position
. Moderators can !q open
or !q close
the queue and pick a user from the queue with !q next
.
The command supports multiple queues, but there can only be one active. Only the active channel is joinable. Moderators can manage queues by using !q add $queueName
or !q del $queueName
, to switch to a different queue use !q set $queueName
. To empty the queue a moderator can use !q clear
, or remove one user by using !q remove $position
, where $position is the position of the user in that specific queue (this position can be found by using !list
).
- join $message - Joines the current queue with optional message "$message", this message is displayed when the user will be picked from the queue
- leave - Leaves the current queue
- position - Displays the position from the user in the current active queue
- list - Displays a link to a webpage with the full list of users in the queue
- info - Displays the current queue information, if the queue is open and how many people are in it
- who $x - Displays the next $x people that are in the queue
- open - Opens the current queue
- close - Closes the current queue
- next $number $userlevel - Picks and removes the first $number users from the queue, with userlevel $userlevel. The $number is optional (default 1), the $userlevel is optional (default everyone)
- random $number $userlevel - Picks and removes $number random users from the queue, with userlevel $userlevel. The $number is optional (default 1), the $userlevel is optional (default everyone)
- clear - Clears the current queue
- add $name - Creates a new queue with the name $name
- del $name - Deletes the queue with name $name (the default queue can't be deleted)
- set $name - Will set the queue with name $name as active queue
- remove $position - WWill remove the user with position $position from the queue
- ul $userlevel - Will set the required userlevel for the active queue (available userlevels: everyone, subscriber, regular, twitch_vip, moderator, owner)
- promote $position - Will promote the user with position $position to first position of the queue (next person)
- setlimit $number - Will set a limit of users that can join the current active queue
- adduser $name - Will add user $username to the current active queue (Twitch only)
Sign in with Nightbot here, the installer will add the selected commands to Nightbot: https://nbq.gerhard.dev/install/auto
- In the current system the user can only join the active queue. Since the system supports multiple queues, maybe add a parameter to join another queue (if they are open). However there will need to be a good syntax for it first, since everything after !join is currently saved as message, for example to store their gamertag. Maybe something like
!join "$queue" $message
-!join "fortnite" xgerhard
. - When a user is picked, the user will be removed from the database. If the user is not there, the user will lose the spot. Maybe add an option to skip a user, not sure how to handle this yet database wise.
- Nightbot has a minimum of 5 sec cooldown on commands, if a big chat will spam !join - some messages will be ignored, the only way a user knows if he/she joined succesfull is if they get a response from Nightbot with a success message. This might be spammy if alot of users want to enter, however if I dont send the confirmation people wouldn't know if they entered.
- People will be able to join a queue through Discord and Twitch at the same time, maybe add a setting to set a main platform and ignore all others?
- Get the repository:
git clone https://github.com/xgerhard/nbqueue
- From the nbqueue folder run
composer install
- Rename
.env.example
to.env
and set your database details - Run
php artisan migrate
to install the required tables - Normally the app only accepts requests made by Nightbot. If your
APP_DEBUG
value is set totrue
in your.env
file the app will manually add the Nightbot headers, you can set the virtual user and channel here - Start a local webserver from the public folder:
php -S localhost:8080
Now you'll be able to run chat commands directly through the browser by setting the q
parameter in the url, for example:
http://localhost:8080/?q=join%20test%20message
will run!q join test message
http://localhost:8080/?q=next%202
will run!q next 2
http://localhost:8080/?q=list
will run!q list