JoyBot is a mafia game management service, intended to be used on the BlankMediaGames forums. It can be used to help automate votecounts and store game data, with a bit of help from the hosts.
JoyBot is essentially a NoSQL DB combined with a series of cron jobs. It:
- Scrapes the games topic for active games (i.e. stickied, unlocked games)
- Scrapes each active game for votecounts
- Maintains "last read" posts and legacy votecounts in a NoSQL DB
- Resets vote counts if commanded by a host
- Host command parsing
- Player command parsing
- Automatic playerlist generation
- Checking if host actions cause player death
- Parsing posts from active games
- Vote inference
- Host color inference
- Basic cron job management
- Monitoring active games
- Automatic job generation
- Database
- Post Support
- PM Support
- API Implementation
- Middleware for axios for saving cookies
- Automated deploy with docker
- Fix ERRCONNECT issue w/docker
- Automated deploy on AWS EC2/GCP
- Node logging library
JoyBot looks for bolded /***
commands from players. Currently, only votes are supported.
/vote <playername>
votes a player./vote
with no playername will randomly vote one of the hosts. Oops./unvote
will remove all of your votes./unvote {playername}
will remove your vote on a player, if you have one.
If you are only able to vote one player, joybot will automatically change your vote upon a /vote
command. If you may vote multiple players, JoyBot will only register a vote if you have a vote that you have not placed on a player.
JoyBot will try to parse nicknames/shortened versions of player names, but if there are multiple players with similar names or mispellings, JoyBot might not correctly count your vote.
To start JoyBot, include the line
!joybot {options}
in the OP of your post. JoyBot parses all options sequentially.
--print {boolean}
: If true, JoyBot will dump the entire contents of the game into its next post.- JoyBot will use the last call of this command when posting.
- The printed game is not censored. Calling this in thread may leak game information.
--every {number}
: Creates a votecount every x minutes. One hour by default.--autolock {true | false}
: Autolocks the thread if majority is reached. False by default. If true, will PM all hosts that the game has reached majority. Autolocking will not trigger if JoyBot has reached majority.--majority {number}
: Overrides the number of votes needed to reach majority.--reset
: Resets the votecount.--add-host {name} {color}
: Adds a host to the host list. Host color is optional, but must be in the form of#xxx
or#xxxxxx
to register. joybot will always be considered a host.--remove-hosts {name} {name}
: Removes host(s) from the hosts list.--set-host-color {name} {color}
: Sets the mod color of the give host.--create-playerlist
: Tries to parse the post with the config for a "Playerlist" as shown in the OP of VFM68.- The list header (i.e. "Playerlist", "Players") must be bolded/underlined
- The playerlist must be a bbcode
[list]
or[list=]
element - Expects that playernames are one word and that the playerlist is inside an ordered list, i.e. numbered.
- If successfully called twice, it will wipe the old playerlist and replace it with a new one.
--add-players {player 1} {player 2}
: Adds a player(s) to the live playerlist.--kill-players {player 1} {player 2}
: Removes a player(s) from the live playerlist and sets their vote weight to 0. Note that you can give dead players votes!--replace-player {player 1} {player 2}
: Replaces player 1 with player 2.--change-weight {player name} {weight} {split?}
: Updates the weight of a player's vote. Default vote weight is one. Ifsplit
is true, then this allows the player to vote multiple players if their vote weight is greater than1
. Each of their votes will have a weight of1
.- Toggling on or off split will cause the player to remote all of their votes.
--change-votes-needed {player name} {+/-}{weight}
: Updates the number of votes needed to lynch a player by+/-
from maj. -e.g. Maj is4
and a host has run!joybot james +2
. James will need to have6
votes to be lynched. If maj changes to3
, James will need5
votes to be lynched.
After the initial command, JoyBot will only listen to in-thread commands from the person who created the configuration and any listed hosts. A host can add another host at any time.
JoyBot tries to store host color codes. If a host does not have a color code, JoyBot will try to infer it from any post they make with the !joybot
command. Internally, JoyBot represents 'no color code' with #000
. It's reccomended to explicitly set the host's hext color to #000000
if the host really does use black as a host color.
Adding and removing a player will reset majority to its default. Include a --majority
tag after to force set majority afterwards if needbe.
For now, JoyBot does not parse EOD posts or automatically remove players at maj. Include a joybot command in these posts to update the live playerlist/reset the vote count.
Joybot will include a spoiler with all the isos of the hosts and players in each post.
Some commands are best suited for PMs. However, please note that JoyBot will not register PMs from hosts until they are on the host list.
JoyBot expects PMS with:
- A topic with the game's thread number, which can be found by looking at the
t=000000
part of the game's url. - A body with a valid JoyBot command.
- Fill out the
.env
file. docker-compose run joybot
.- Provide a captcha.
During setup, you will be prompted for a captcha token. To obtain:
- Navigate to the signin page
- Complete the captcha. Do not log in.
- Press f12 to open devtools and open the console tab.
- Type 'grecaptcha.getResponse()'
- Paste the result into your terminal
Lots of spaghetti code with this one--everything from mutating state to swapping between regex and javascript string parsing to weird naming conventions. Mostly wrote this 'for fun' to kill some time during quarentine, work with Jest, and reminsce about BLFM.