Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subscriber wait time multiplier and !weightednext #39

Merged
merged 36 commits into from
Oct 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
8db68a9
Change tests to write settings.json intead of mock
liquidnya Jun 16, 2022
9c3236c
Add TODO comment
liquidnya Jun 16, 2022
3d689b7
Make settings example clearer
liquidnya Jun 16, 2022
eea71ea
Add validation for channel
liquidnya Jun 16, 2022
38c8bbd
Merge remote-tracking branch 'plus/master' into improve-settings
liquidnya Jun 16, 2022
db89cbf
Change example to contain useful default values
liquidnya Jun 18, 2022
45279f2
Format json example
liquidnya Jun 18, 2022
e169c89
Update settings example and README.md
liquidnya Jun 19, 2022
3675a26
Distinguish between volume and mocked fs
liquidnya Jun 19, 2022
ca80667
Clean up test cases source code
liquidnya Jun 19, 2022
1400ac3
Change implementation to use waiting objects
liquidnya Jul 3, 2022
6096ba1
Add waitTimeMs to the save file
liquidnya Jul 3, 2022
817857f
Add test that waitTimeMs stays the same
liquidnya Jul 3, 2022
8786461
Add wait time multiplier for subscribers
liquidnya Jul 3, 2022
809f924
Update readme with subWaitMultiplier setting
liquidnya Jul 3, 2022
7a9afc9
Update example settings
liquidnya Jul 3, 2022
b9c409b
Keep real waitTime by introducing weightMin/Msec
liquidnya Sep 23, 2022
bf11225
Add !weightednext
liquidnya Sep 24, 2022
f162926
Rename factor to multiplier
liquidnya Sep 24, 2022
f0dc0f2
Rename subWaitMultiplier to subscriberWeightMultiplier
liquidnya Sep 24, 2022
e25b8d6
Add weighted list and weighted position.
liquidnya Oct 4, 2022
0289794
Add the subscriber weight multiplier to the !odds command
liquidnya Oct 4, 2022
5c59e14
Merge branch 'fix-tests' into feature-sub-wait-time-multiplier
liquidnya Oct 4, 2022
5f48ceb
Fix test conversion-test-v2.0-to-v2.1
liquidnya Oct 4, 2022
59eec17
Merge branch 'improve-settings' into feature-sub-wait-time-multiplier
liquidnya Oct 4, 2022
761419e
Change twitch username to be at least 2 characters long
liquidnya Oct 4, 2022
a0ff6d1
Merge branch 'fix-examples' into feature-sub-wait-time-multiplier
liquidnya Oct 4, 2022
00854be
Add weight test
liquidnya Oct 11, 2022
3d442a8
Set jest version to 28 for node 12 compatibility
liquidnya Oct 11, 2022
ae85184
Switch `npm start run` with `npm run start`
liquidnya Oct 11, 2022
2bae6b5
display 0% and 100% differently if rounded
liquidnya Oct 11, 2022
83b616c
Add !weightedsubrandom and !weightedsubnext
liquidnya Oct 11, 2022
3a724de
Add weightedsubrandom and weightedsubnext as config
liquidnya Oct 11, 2022
0cd6804
Add JSHint config file to .gitignore
liquidnya Oct 11, 2022
23fbb30
Add documentation of list and position settings
liquidnya Oct 11, 2022
19a674e
Add documentation of !weightedsubrandom and !weightedsubnext
liquidnya Oct 11, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@
/userOnlineTime.txt
/data/

# JSHint config file
.jshintrc

# Secrets
settings.json
47 changes: 37 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,22 @@ Next, install the dependencies for the project using the following command:
npm install
```

After that, copy and configure the settings.json file (detailed below). Finally, run the following command to start the bot:
After that, copy (detailed below) and configure the `settings.json` file with your favorite text editor.
```bash
cp settings.example.json settings.json

# now edit settings.json with your favorite text editor
```

Finally, run the following command to start the bot:

```bash
npm start run
npm run start
```

To close the queue press `CTRL + C` inside the terminal.

The command `npm run start` is the only command you will need to the next time you want to start the bot.

## What does the settings.json contain?

Expand All @@ -39,32 +46,46 @@ The settings.json file contains several options to make the bot as customizable

`password` is the oauth token of the bot, including the portion that says 'oauth'. This can be generated at https://twitchapps.com/tmi/.

`channel` is the channel that the bot will run in. This should be your Twitch account username.
`channel` is the channel that the bot will run in. This should be your Twitch account username, only containing underscores and lowercase alphanumeric characters.

`start_open` is the toggle for whether or not the queue will start open. The default value is false.
`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.
`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`.

`custom_codes_enabled` is the toggle for whether or not custom codes are allowed to be added to the queue. When enabled, users are able to add an alias to the queue as opposed to the real ID. An example of this is `!add Kamek`. Before usage, the broadcaster must add custom codes to be used. This is detailed in the commands section.

`romhacks_enabled` is a toggle for whether or not romhacks are allowed to be added to the queue. When enabled, users may type `!add ROMhack` to add a ROMhack to the queue. This does not send the patch, but rather gives the user a convienent way to enter the queue without a real level code. It is required for `custom_codes_enabled` to be toggled on to use this feature, and the ROMhack code is added/removed automatically from the custom codes list depending on this toggle.

`max_size` is the maximum amount of levels allowed in the queue at once. The default value is 100.
`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 is to not
`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 of `null` means that the timer is deactivated.

`level_selection` is an array that defines the order that levels will be selected in upon using `!level`. Once the order is completed, it will loop.
Possible values are: `"next"`, `"subnext"`, `"modnext"`, `"random"`, `"weightedrandom"`, `"weightednext"`, `"subrandom"`, `"modrandom"`, `"weightedsubrandom"`, and `"weightedsubnext"`

`message_cooldown` is the amount of time in seconds that a user must wait before !list will display the levels in the queue after a previous use.

`dataIdCourseThreshold` is the highest allowed data ID for course IDs. This is used to stop levels that do not exist from entering the queue, however it is very difficult to know and/or dynamically change this amount accordingly. As such, the default value is undefined, which ignores the restriction.

`dataIdMakerThreshold` is the highest allowed data ID for maker IDs. This is used to stop maker IDs that do not exist from entering the queue, however it is very difficult to know and/or dynamically change this amount accordingly. As such, the default value is undefined, which ignores the restriction.
`dataIdCourseThreshold` is the highest allowed data ID for course IDs. This is used to stop levels that do not exist from entering the queue, however it is very difficult to know and/or dynamically change this amount accordingly. As such, the default value is `null`, which ignores the restriction.

`dataIdMakerThreshold` is the highest allowed data ID for maker IDs. This is used to stop maker IDs that do not exist from entering the queue, however it is very difficult to know and/or dynamically change this amount accordingly. As such, the default value is `null`, which ignores the restriction.

`prettySaveFiles` if set to true the files in the `./data/` directory are going to be formatted with spaces and new lines. The default value is `false` to reduce file size.

`subscriberWeightMultiplier` is the number added as a wait time for subscribers. The default value is `1.0`. Setting this to `1.2` for example will give subscribers an advantage for weighted random, because they would get 6 minutes of wait time per 5 minutes of waiting. This can be set to anything greater than or equal to `1.0`.

`list` is the order of the `!list`/`!queue` command. The following values are possible:
- `"position"` - the list will be sorted by time added. (`!next`)
- `"weight"` - the list will be sorted by weighted chance (watch time, `!weightednext`).
- `"both"` - the list will be sent twice, once sorted by time added and once sorted by weighted chance (watch time).
- `"none"` - the `!list`/`!queue` commands will be disabled.
- `null` - the setting is automatically determined by what is configured in `level_selection`.

`position` is which position the `!position` command shows. The following values are possible:
- `"position"` - the position of `!next`.
- `"weight"` - the position of `!weightednext`.
- `"both"` - both the position of `!next` and `!weightednext`.
- `"none"` - the `!position` command will be disabled.
- `null` - the setting is automatically determined by what is configured in `level_selection`.

## What commands are there?

Expand Down Expand Up @@ -108,10 +129,16 @@ It is important to note that all commands that draw a level (with exception to `

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

`!weightednext`* will select the level from the queue with the most amount of time spent online and waiting in the queue. If multiple users have the same maximum time spent then the level nearer to the top will be chosen.

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

`!subrandom`* will select a random subscriber's level from the queue.

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

`!weightedsubnext`* will select the level from the queue with the most amount of time spent online and waiting in the queue and being subscribed. If multiple users have the same maximum time spent then the level nearer to the top will be chosen.

`!modnext`* will select the next moderator's level from the queue.

`!modrandom`* will select a random moderator's level from the queue.
Expand Down
Loading