Skip to main content

The core framework for cool Martian bots.

Project description

Mars College Discord Bots Framework

This repository contains code for creating chatbots/utility bots for Mars College, or otherwise.

There are several useful utilities for chat programs, including support for numerous language model API providers, as well as methods for completing text, searching topics, and getting message similarity.

Setup (for development)

python -m virtualenv venv
pip install flit
flit install --deps=all --pth-file

Creating a bot

All bots must be placed in a directory equal to or higher in the file system than the run script (bot.py). It is recommended that you create a folder called bots in the marsbots-core directory, then create additional folders and files in there as needed.

All bots expect three things:

  • A JSON settings file
  • A Python script containing the bot's code as a Discord.py Cog class
  • A .env file to load API keys/settings from

Settings File

The bot's JSON settings file should contain the following:

"name": The name of the bot "token_env": The name of the environment variable which contains the discord bot token used to run the bot (Optional) "command_prefix": This will be the prefix used for the bot to respond to commands. (Optional) "intents": A list of special intents needed. Takes a list, with accepted values "presence" and "members"

Cog File

The bot's main logic should be created as a Discord.py Cog class, and should have a setup function which adds the Cog to the bot.

Env File

This should contain any API keys or sensitive variables you need to use to run the bot. Expected default names for environment variables can be found in the config.py file of Marsbots core.

Running Your Bot

Locally

Bots can be run locally using a command such as the following:

python bot.py ./examples/examplebot/examplebot.json --cog-path=examples.examplebot.examplebot --dotenv-path=.env

Note that the --cog-path flag should be provided using python module syntax, using dots.

Managing several bots with PM2

Several bots can be managed at once using PM2 and a PM2 config file. An example config file is provided in the examples folder for running the example bot using PM2.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

marsbots-0.1.1.tar.gz (1.3 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

marsbots-0.1.1-py2.py3-none-any.whl (12.0 kB view details)

Uploaded Python 2Python 3

File details

Details for the file marsbots-0.1.1.tar.gz.

File metadata

  • Download URL: marsbots-0.1.1.tar.gz
  • Upload date:
  • Size: 1.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.27.1

File hashes

Hashes for marsbots-0.1.1.tar.gz
Algorithm Hash digest
SHA256 9dd760a3cc0ea12c38d6fd75a4acbe95778c5dda16485a27fd4ba3afbeca96b9
MD5 b6f7af9c101186686addbda56f7237dd
BLAKE2b-256 93a5b9eb79a6493a0ca45c4114dd3e09ae4ca92d2a8e4c55faec51d3e8174f68

See more details on using hashes here.

File details

Details for the file marsbots-0.1.1-py2.py3-none-any.whl.

File metadata

  • Download URL: marsbots-0.1.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 12.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.27.1

File hashes

Hashes for marsbots-0.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 423a011682d7cba159d6b06007a76515b69e110a781d1c9c9ab58514f5c2e529
MD5 708ee074b2e28a5dfca1d498a506f95e
BLAKE2b-256 4c5f23d44e0265daec5819d9459b771d9b6a39ed321923870551d004863463f8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page