Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/DXsmiley/mathbot
Discord bot for mathematics
https://github.com/DXsmiley/mathbot
bot discord discord-bot discord-py
Last synced: 4 months ago
JSON representation
Discord bot for mathematics
- Host: GitHub
- URL: https://github.com/DXsmiley/mathbot
- Owner: DXsmiley
- License: gpl-3.0
- Created: 2016-10-27T06:39:11.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-08-03T02:57:18.000Z (6 months ago)
- Last Synced: 2024-08-03T04:07:51.178Z (6 months ago)
- Topics: bot, discord, discord-bot, discord-py
- Language: Python
- Homepage: https://dxsmiley.github.io/mathbot/
- Size: 3.78 MB
- Stars: 278
- Watchers: 9
- Forks: 53
- Open Issues: 36
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome - DXsmiley/mathbot - Discord bot for mathematics (Python)
README
# MathBot
MathBot is a discord bot that contains a number of features to help with mathematics.
It's primary features are:
- LaTeX rendering
- Querying Wolfram|Alpha
- A Turing complete calculatorThe bot is currently developed on python `3.8.10`, but should work on later versions of Python.
## Links
- [Add the bot to your own server](https://dxsmiley.github.io/mathbot/add.html)
- [Official Discord Server](https://discord.gg/JbJbRZS)## Setup for use
```bash
git clone https://github.com/DXsmiley/mathbot.git
cd mathbot
cp mathbot/parameters_default.json ./parameters.json
python3.8 -m venv .venv # or later version
source .venv/bin/activate
pip install -r requirements.txt
```Then open parameters.json and change `tokens` to the token of the bot used for development. Optionally change the other parameters.
It is *strongly* recommend that you setup an instance of Redis if you want to use the bot on even a moderate scale. The disk-based keystore is easy to setup but runs very slowly, and as such is only useful of a development tool.
Run the bot with `python -m mathbot parameters.json`.
## Setup for development
Follow above instructions, but additionally run `pip install -r dev_requirements.txt`
## Contributing guide
Relevent discussion takes place on [the MathBot Discord server](https://discord.gg/JbJbRZS).
## Setting up Wolfram|Alpha
1. [Grab yourself an API key](https://products.wolframalpha.com/api/)
2. Open parameters.json and change `wolfram > key`.This should really only be used for development and personal use.
## Test Suite
Invoke `pytest` to run the test suite.
~~Some of the tests require that a bot is running and connected to Discord. To enable them, use the `--run-automata` command line argument. In addition a file with the necessary tokens filled out needs to be provided to the `--parameter-file` argument. To get all tests running, the *token*, *automata* and *wolfram* parameters need to be filled out.~~
~~For the sake of example, I run my tests with the command `./test --run-automata --parameter-file=dev.json`. You should replace `dev.json` with a path to your own parameter file.~~
~~There are some additional tests that require a human to verify the bot's output. These can be enabled with `--run-automata-human`.~~
## Guide to `parameters.json`
- *release* : Release mode for the bot, one of `"development"`, `"beta"` or `"production"`
- *token* : Token to use for running the bot
- *wolfram*
- *key* : API key for making Wolfram|Alpha queries
- *keystore*
- *disk*
- *filename* : The file to write read and write data to when in disk mode
- *redis*
- *url* : url used to access the redis server
- *number* : the number of the database, should be a non-negative integer
- *mode* : Either `"disk"` or `"redis"`, depending on which store you want to use. Disk mode is not recommended for deployment.
- *patrons* : list of patrons
- Each *key* should be a Discord user ID.
- Each *value* should be a string starting with one one of `"linear"`, `"quadratic"`, `"exponential"` or `"special"`. The string may contains additional information after this for human use, such as usernames or other notes.
- *analytics* : Keys used to post information to various bot listings.
- *carbon*: Details for [carbonitex](http://carbonitex.net/)
- *discord-bots*: API Key for [bots.discord.pw](https://bots.discord.pw/#g=1)
- *bots-org*: API Key for [discordbots.org](https://discordbots.org/)
- *automata*
- *token* : token to use for the automata bot
- *target* : the username of the bot that the automata should target
- *channel*: the ID of the channel that the tests should be run in
- *advertising*
- *enable* : should be `true` or `false`. When `true`, the bot will occasionally mention the Patreon page when running queries.
- *interval* : the number of queries between mentions of the Patreon page. This is measured on a per-channel basis.
- *starting-amount* : Can be increased to lower the number of commands until the Patreon page is first mention.
- *error-reporting*
- *channel*: ID of channel to send error reports to.
- *webhook*: Webhook to send error reports to.
- *shards*
- *total*: The total number of shards that the bot is running on.
- *mine*: A list of integers (starting at `0`) specifying which shards should be run in this process.## Additional Installation Issues (Ubuntu only)
If you don't have python 3.8
```
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.8
```If you have installation troubles with cffi or psutil
```
sudo apt-get install python3.8-dev
```