Skip to content

Commit

Permalink
Added an option for absolute position
Browse files Browse the repository at this point in the history
This update allows absolute position (offline position) to be displayed alongside relative position (online position).
  • Loading branch information
ToransuShoujo committed May 24, 2022
1 parent 9d99b3c commit f192340
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ The settings.json file contains several options to make the bot as customizable

`start_open` is the toggle for whether or not the queue will start open. The default value is false.

`enable_absolute_position` is the toggle for whether or not absolute position (offline position) is displayed along relative position (online position). The default value is false.

`max_size` is the maximum amount of levels allowed in the queue at once. The default value is 100.

`level_timeout` is the amount of time in minutes a level can be played before the bot will inform you that time is up. The default value is 9999.
Expand Down Expand Up @@ -95,7 +97,7 @@ It is important to note that all commands that draw a level (with exception to `

`!random`* will select a random level from the queue.

`!weightedrandom`* will select a random level from the queue using the amount of time spent online and waiting in the queue as weight.
`!weightedrandom`* will select a random level from the queue using the amount of time spent online and waiting in the queue as weight.

`!subnext`* will select the next subscriber's level from the queue.

Expand All @@ -120,4 +122,4 @@ It is important to note that all commands that draw a level (with exception to `

## Will you add [insert feature here]?

Possibly! If you have an idea for a change to the queue, feel free to post it to the issues board at https://github.com/ToransuShoujo/quesoqueue_plus/issues and we can look into getting it made. Better yet, if you just can't want and want to take a crack at it yourself, feel free to edit the code and submit a pull request.
Possibly! If you have an idea for a change to the queue, feel free to post it to the issues board at https://github.com/ToransuShoujo/quesoqueue_plus/issues and we can look into getting it made. Better yet, if you just can't want and want to take a crack at it yourself, feel free to edit the code and submit a pull request.
7 changes: 6 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,12 @@ const position_message = async (position, sender) => {
} else if (position === 0) {
return 'Your level is being played right now!';
}
return sender + ', you are currently in the ' + get_ordinal(position) + ' position.';
if (settings.enable_absolute_position) {
let absPosition = await quesoqueue.absoluteposition(sender);
return sender + ', you are currently in the online ' + get_ordinal(position) + ' position and the offline ' + get_ordinal(absPosition) + ' position.';
} else {
return sender + ', you are currently in the ' + get_ordinal(position) + ' position.';
}
};

const weightedchance_message = async (chance, sender) => {
Expand Down
14 changes: 14 additions & 0 deletions queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,20 @@ const queue = {
return -1;
},

absoluteposition: async (username) => {
if (current_level != undefined && current_level.submitter == username) {
return 0;
}
if (levels.length == 0) {
return -1;
}
var index = levels.findIndex(x => x.submitter == username);
if (index != -1) {
return (index + 1) + ((current_level != undefined) ? 1 : 0);
}
return -1;
},

submittedlevel: async (username) => {
if (current_level != undefined && current_level.username == username) {
return 0;
Expand Down
1 change: 1 addition & 0 deletions settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module.exports = {
password: '', // generated at https://twitchapps.com/tmi/
channel: '', // channel where the bot will run
start_open: false, // whether or not the queue will start open
enable_absolute_position: false, // whether or not absolute position (offline position) will be stated alongside relative position (online position)
max_size: 100, // the max amount of levels in the queue
level_timeout: 9999, // The length of time in minutes a level can be played before the timer will go off
// Acceptable values: next, subnext, modnext, random, weightedrandom, subrandom, modrandom
Expand Down

0 comments on commit f192340

Please sign in to comment.