A Discord bot that generates a video from a World of Warships replay file.
Clone this repo.
git clone https://github.com/imkindaprogrammermyself/renderer-bot-rq.git
Create a virtual environment via Python's venv module and activate it. (This assumes you have Python 3.9 installed and on Linux)
$cd renderer-bot-rq
$python3.9 -m venv venv $ . venv/bin/activate $pip install -r requirements.txt
Install redis-server.
You can install redis by following the instruction here or via apt.
If you're planning to run the bot, worker and redis-server separately, modify the following values inside /etc/redis/redis.conf
Comment out the line with bind 127.0.0.1 ::1.
Uncomment the line with # requirepass foobared and change foobared to something secure to set the password.
Restart the redis-server.
First, you need to create a .env file. Start by,
$cp .env-template .env
Modify the values.
-
ENVIRONMENTset's which redis url to use. -
SETTINGS_PREFIXredis key prefix to use.FOOBAR.FPS, FOOBAR.QUALITY -
REDIS_TESTING_URLlocal redis server url for testing. -
REDIS_PRODUCTION_URLremote or local redis server url depending on your setup.Ex. `redis://:yourredispassword@ip-172-0-0-1.us-east-2.compute.internal:6379` -
BOT_COMMAND_PREFIXThe bot's command prefix ie.$,!or any character you want. It's completely up to you but check for prefixes other bot uses in your server to avoid collision with the other bots. -
BOT_TOKENYour bot's token. Get one from discord.com/developers/applications -
BOT_LOGS_CHANNELDiscord channel ID where the bot will write its logs. -
BOT_OWNERSBot's owner(s) ID(s). Your Discord ID or and someone's. Valid value (JSON array):[623183509066088450, 623183509066088423] -
BOT_REQUIRED_PERMBot's required permission to function properly. A JSON array. -
BOT_SERVER_WHITELISTBot's initial whitelist value. A JSON array[INSERT_YOUR_DISCORD_SERVER_ID_HERE] -
FPSthe render's fps. -
QUALITYthe render's quality. -
QUEUE_MAX_WAIT_TIMEQueue wait time before the job is deleted. -
TASK_COOLDOWNSeconds before a user can use the bot's render commands again. -
TASK_QUEUE_SIZESets the size of the queue. Once the queue size is reached the bot wont take another render request. -
RENDER_PBAR_FProgress bar foreground character. -
RENDER_PBAR_BProgress bar background character. -
URL_PAYPALDonation URL. Can be Patreon, GoFundMe, etc. Omitting the values will remove theBuy me a coffeefrom the bot's embed messages. -
BACKUP_KEYBackup encrypt key. Strictly must be a 32 characters long.
This assumes you activated the Python environment you just created.
Running the bot.
python main.py -r bot
Running a worker
python main.py -r worker -q single dual chat
main.py arguments:
-
-r: specifies if you want to run the bot or the worker. -
-q: specifies which queue(s) your worker to get its job from.Possible
-qvalues:single- A queue forrendercommand.dual- A queue forrenderzipcommand.chat- A queue forchatcommand.
Extract the following files from the client using the World of Warships Unpack Tool
The extracted files will be in World_of_Warships/res_unpack folder.
Move the following files:
World_of_Warships/res_unpack/content/GameParams.data and World_of_Warships/res_unpack/gui/achievements
to generation/resources.
- Run the scripts with
generated_at their filenames fromgenerationfolder. This will create the update files. - Copy the renderer version module and paste it into a newest version.
cp -r renderer/versions/0_10_10/ renderer/versions/0_10_11. - Paste the contents of
generation/generatedtorenderer/versions/0_10_11/resourcesfolder.
Most of the time this works just fine unless Wargaming change something at the replay file. If they did change something, and the unpacker fails, wait for the updated version from https://github.com/Monstrofil/replays_unpack.
This bot uses a modified version of the Monstrofil's replays_unpack so copy-pasting Monstrofil's to this replays_unpack will not work.
Files that probably get updated if WG changed or added something:
replay_unpack/core/entity_defreplay_unpack/core/networkclients/wows/versions/*/constants.py
Adding a new version to the modified unpacker:
- Copy the last version
clients/wows/versions/0_10_10and paste it toclients/wows/versions/0_10_11using the commandcp -r clients/wows/versions/0_10_10/ clients/wows/versions/0_10_11. - Copy the
World_of_Warships/res_unpack/scripts/and paste it toclients/wows/versions/0_10_11and overwrite everything.
renderrenders the replay file.render logssame asrenderbut with counters, ribbons, achievements and death log.doomandbennysubcommands. Fordoom, the starting music will be a elevator meme music and if the player gets a killThe Only Thing They Fear Is YoufromDoomwill play.chatextracts the chat messages from the replay file.enablechatanddisablechatenables/disables chat extraction from the server it was invoked from. Can only be used by users withManage channelpermission.whitelistandunwhitelistArgument: Discord server id. Adds/Removes the Discord server id to the bot's whitelist. If the bot joins to a server which is not in the whitelist, the bot will leave that server immediately.settings getandsettings setArguments: setting name, setting value. Gets and sets the settings. Valid settingsfpsandquality.guild chatGets the guild(s) that can extract the chat messages.guild listGets the list of guilds where the bot currently resides in.guild leaveArgument: Discord server id. Makes the bot leave the specified server.guild banArgument: Discord server id. Makes the bot leave the specified server and adds it to the blacklist.guild unbanArgument: Discord server id. Removes the id from the blacklist.backupBackups the extract channels, whitelist, banned guilds and .env file.restoreRestores the file generated from thebackupcommand.
This will probably the dirtiest program you will see, not tests, no straightforward way of updating it, but it works. Please don't contribute, just fork it and develop it as your own. Continually developing it wouldn't be possible for me since I'm gonna be busy for a long time (work).
