The guide to creating a custom BackSeatGamer Reverse Proxy plugin
Note that calls to print are automatically routed to the ReverseProxy's console, and not STDOUT
Plugins can either be a directory or .zip file. The proxy has a built-in system to package a plugin to .zip format. Directories are recommended for development whereas .zip is recommended for distribution.
You can take a look at our list of Premade Plugins to try out, or view the code and modify for any use (free or commercial). No attribution necessary. All plugins are licensed under MIT license. Enjoy!
Define any of these functions in your plugin to take advantage of their functionality
on_start()- Called whenever the plugin starts or is reloadedon_close()- Called when the plugin is unloaded or the session endson_command(command, name, guest)- Called when a guest redeems a rewardon_console_clear()- Called when the console is clearedon_rewards_pull(rewards)- Called when the user updates the rewards list. See the Rewards section for the structure of a reward.
Note that if you are using an IDE such as PyCharm, it will not recognize function calls and will flag them as errors. We are working on a solution.
speak(text: str)- Addstextto the text to speech queueget_rewards()- Returns a list of rewards availbile. See the Rewards section for the structure of a reward.clear_tts_queue()- Clears the text to speech queueset_tts_state(state: bool)- IfstateisTrue, then text to speech will be enabled.Falsewill disable it.disable_tts()- Disables text to speechenable_tts()- Enables text to speechget_tts_state()- ReturnsTrueif text to speech is enabled. Otherwise it will returnFalse.toggle_tts_state()- Toggles if text to speech is enabled or disabledclear_console()- Clears the consolestop_session()- Ends the proxy session and returns the user to the main menuupdate_rewards()- Pulls the latest version of the rewards from the serverbackground_task(target: callable, *args, **kwargs)- Runs the function passed intotarget(withargsandkwargs) as a background process (thread)play_sound(path: str)- Plays the sound file at the given path. The path MUST be relative to the plugin folder! Supported formats: .wavv, .flv, .ogg, .mp3 (.ogg is recomended)read(path: str)- Returns the contents of the specified file as a string. The path MUST be relative to the plugin folder!read_raw(path: str)- Returns the contents of the specified file as bytes (recomended for binary files). The path MUST be relative to the plugin folder!write(path: str, content: str, encoding: str = "utf-8")- Writescontentto the specified path. The path MUST be relative to the plugin folder!write_raw(path: str, content: bytes)- Writescontentto the specified path (recomended for binary files). The path MUST be relative to the plugin folder!remove_file(path: str)- Removes the file at the specified path. The path MUST be relative to the plugin folder!
keyboard- Provides an interface to the keyboard for simulating keystrokes. Use the funcitonskeyboard.press_key(key: str)andkeyboard.release_key(key: str)to simulate the keys. The key names are based on the DIK codes.info- contains all of the information provided ininfo.jsonas an object. For example, to reference the version of the mod, simply runinfo.version
A reward is a dictionary with the following format. Note that dict values are used to describe the real value which could be found.
{
"available_in": "the datetime when the reward will become available again (or None if it has not been used)",
"command": "the command to execute",
"cooldown": "the cool down between uses of the command",
"enabled": "1 if it is enabled, or 0 if it is disabled",
"id": "the reward ID",
"last_guest": "The ID of the guest who last used the reward, or None if it has never been used",
"last_used": "The datetime the reward was last used, or 0001-01-01T01:01:01 if it has never been used",
"min_cooldown": "the smallest cool down allowed to be set for the reward",
"name": "the display name of the reward",
"price": "the cost of using the reward",
"single_use": "if the reward can only be used once per user"
}