Skip to main content

A simple Matrix bot that fetches Bible verses

Project description

Matrix BibleBot

A simple Matrix bot that fetches Bible verses using APIs from bible-api.com & esv.org

PyPI version Python Tests

Supported Translations

  • King James Version (KJV)
  • English Standard Version (ESV) - requires an API key
  • Easily extensible to support additional translations

Installation

Install from PyPI (Recommended)

pip install matrix-biblebot

For an isolated installation, you can use pipx:

pipx install matrix-biblebot

Install from Source

Clone the repository:

git clone https://github.com/jeremiah-k/matrix-biblebot.git
cd matrix-biblebot
pip install .

For development:

pip install -e .

Configuration

1. Create a .env file

Create a .env file in the same directory as your config file (e.g., ~/.config/matrix-biblebot/.env) with your Matrix access token and any API keys:

MATRIX_ACCESS_TOKEN="your_bots_matrix_access_token_here"
ESV_API_KEY="your_esv_api_key_here"  # Optional

The bot will first look for a .env file in the same directory as your config file. If not found, it will fall back to looking in the current working directory.

2. Create a config.yaml file

The bot looks for a configuration file at ~/.config/matrix-biblebot/config.yaml by default. You can generate a template configuration file with:

biblebot --generate-config

This will create both a sample config file and a sample .env file in the ~/.config/matrix-biblebot/ directory. The config file has the following structure:

matrix_homeserver: "https://your_homeserver_url_here"
matrix_user: "@your_bot_username:your_homeserver_domain"
matrix_room_ids:
  - "!your_room_id:your_homeserver_domain"
  - "#room_alias:your_homeserver_domain" # Room aliases are supported

Edit this file with your Matrix credentials and room IDs or aliases. The bot will automatically resolve room aliases to room IDs at startup.

You can also specify a custom config location:

biblebot --config /path/to/your/config.yaml

Or generate a config at a custom location:

biblebot --generate-config --config /path/to/your/config.yaml

Usage

Running the Bot

After installation and configuration, you can run the bot with:

biblebot

Or with custom options:

biblebot --config /path/to/config.yaml --log-level debug

Command-line Options

usage: biblebot [-h] [--config CONFIG] [--log-level {error,warning,info,debug}] [--generate-config] [--install-service] [--version]

BibleBot for Matrix

options:
  -h, --help            show this help message and exit
  --config CONFIG       Path to config file (default: ~/.config/matrix-biblebot/config.yaml)
  --log-level {error,warning,info,debug}
                        Set logging level (default: info)
  --generate-config     Generate a sample config file at the specified path
  --install-service     Install or update the systemd user service
  --version             show program's version number and exit

Running as a Service

You can install BibleBot as a systemd user service to run automatically at startup:

biblebot --install-service

This will create a systemd user service file and guide you through enabling and starting the service. Once installed, you can manage the service with standard systemd commands:

systemctl --user start biblebot.service    # Start the service
systemctl --user stop biblebot.service     # Stop the service
systemctl --user restart biblebot.service  # Restart the service
systemctl --user status biblebot.service   # Check service status

Interacting with the Bot

Invite the bot to rooms that are listed in the config.yaml file. The bot will respond to messages that match Bible verse references:

  • Simple reference: John 3:16
  • Range reference: 1 Cor 15:1-4
  • With translation: John 3:16 esv

Development

Contributions are welcome! Feel free to open issues or submit pull requests.

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

matrix_biblebot-0.1.3.tar.gz (14.7 kB view details)

Uploaded Source

Built Distribution

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

matrix_biblebot-0.1.3-py3-none-any.whl (15.4 kB view details)

Uploaded Python 3

File details

Details for the file matrix_biblebot-0.1.3.tar.gz.

File metadata

  • Download URL: matrix_biblebot-0.1.3.tar.gz
  • Upload date:
  • Size: 14.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for matrix_biblebot-0.1.3.tar.gz
Algorithm Hash digest
SHA256 108e006bcee9c45026ba50260ff5f367e94c061588c9b86b7d545005fc67d29e
MD5 4be3aca31e70db1aa1146378fc98e038
BLAKE2b-256 9d89d8a69928cb64b59622fc509a910570b5c03e867b24322eb3944ed870c52f

See more details on using hashes here.

Provenance

The following attestation bundles were made for matrix_biblebot-0.1.3.tar.gz:

Publisher: pypi-publish.yml on jeremiah-k/matrix-biblebot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file matrix_biblebot-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for matrix_biblebot-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 df50183668bb000761585617dd7924c59875304d147e736e49f5ab6a90c083b8
MD5 3675dad7d118f29172e166c624f3be88
BLAKE2b-256 af1b0d63e8c9a11b898659b3ac5cbe8bac5fad984e36f777b32c272bf344ffda

See more details on using hashes here.

Provenance

The following attestation bundles were made for matrix_biblebot-0.1.3-py3-none-any.whl:

Publisher: pypi-publish.yml on jeremiah-k/matrix-biblebot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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