Skip to content

Bots: Setup, Configuration, and Running

toddrob edited this page Feb 26, 2020 · 4 revisions

Note: Available actions on the Bots page depend on the logged-in user's privileges. See Platform: Managing Users for additional information about privileges.

Adding Your Bot

Add a bot on the Bots page by entering a name, selecting the bot type, selecting whether or not to enable auto run, selecting a Reddit Auth if applicable, and clicking Create.

Running Your Bot

If you enable auto run for your bot, it will start automatically when redball starts up.

If you manually stop a bot, it will remain stopped until you start it or redball is restarted (if auto run is enabled).

If your bot stops unexpectedly due to an error, redball includes an overwatch process that will start it again within seconds.

Configuring Your Bot

Each bot has its own flexible configuration. You can view and manage a bot's configuration by clicking the bot's Edit button on the Bots page. From here you can edit values of existing keys, and add new keys.

Important: Be sure to save changes in one category before making changes in another category, because the page will reload when saving a category. Improving the UI to save without reloading the page, or to save the whole page at once, is planned for the future.

If you delete the last setting in a given category, the category will also be deleted.

If you want to add new keys with options or parent key relationships, or if you want to import settings in bulk, redball has support for uploading a file in json format containing the bot's settings. Use the _config.json files in the bots directory (e.g. game_threads_config.json) for example format, and refer to the API page for descriptions of the fields.

The redball platform will pass two parameters to the run() function of the bot module.

  • A bot object, so the bot can monitor for the bot.STOP flag and end its process when instructed to do so.
  • A multi-level dict of categories > settings, including the following as well as any settings defined for the bot:
    • Database
      • dbPath - path where the bot should access the sqlite database
      • dbFile - filename of the sqlite database the bot should use
      • dbTablePrefix - prefix the bot should use for all tables it creates/uses
    • Reddit Auth
      • reddit_clientId - client id from the Reddit app associated with the bot's configured Reddit Auth
      • reddit_clientSecret - secret from the Reddit app associated with the bot's configured Reddit Auth
      • reddit_refreshToken - refresh token associated with the bot's configured Reddit Auth
    • Category
      • Key - Any additional settings defined for the bot will be included in the settings dict with the category as the key and that category's settings as a nested dict.