Skip to content

Commit acf3897

Browse files
committed
Merge branch 'v0.1.0'
Release v0.1.0 of Pi
2 parents 53f1dff + e907424 commit acf3897

36 files changed

+2887
-1415
lines changed

.dockerignore

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
env/
12+
build/
13+
develop-eggs/
14+
dist/
15+
downloads/
16+
eggs/
17+
.eggs/
18+
lib/
19+
lib64/
20+
parts/
21+
sdist/
22+
var/
23+
*.egg-info/
24+
.installed.cfg
25+
*.egg
26+
27+
# PyInstaller
28+
# Usually these files are written by a python script from a template
29+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
30+
*.manifest
31+
*.spec
32+
33+
# Installer logs
34+
pip-log.txt
35+
pip-delete-this-directory.txt
36+
37+
# Unit test / coverage reports
38+
htmlcov/
39+
.tox/
40+
.coverage
41+
.coverage.*
42+
.cache
43+
nosetests.xml
44+
coverage.xml
45+
*,cover
46+
.hypothesis/
47+
48+
# Translations
49+
*.mo
50+
*.pot
51+
52+
# Django stuff:
53+
*.log
54+
local_settings.py
55+
56+
# Flask instance folder
57+
instance/
58+
59+
# Scrapy stuff:
60+
.scrapy
61+
62+
# Sphinx documentation
63+
docs/_build/
64+
65+
# PyBuilder
66+
target/
67+
68+
# IPython Notebook
69+
.ipynb_checkpoints
70+
71+
# pyenv
72+
.python-version
73+
74+
# celery beat schedule file
75+
celerybeat-schedule
76+
77+
# dotenv
78+
.env
79+
80+
# virtualenv
81+
venv/
82+
ENV/
83+
84+
# Spyder project settings
85+
.spyderproject
86+
87+
# Rope project settings
88+
.ropeproject
89+
90+
*.log
91+
*.log.*
92+
config.py
93+
temp*
94+
tmp*
95+
tempBot.txt
96+
tempAva.*
97+
*.db
98+
debug.html
99+
.vscode/

.flake8

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[flake8]
2+
ignore = W503, E501
3+
max-line-length = 180

.github/workflows/build.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- dev
10+
types: [closed]
11+
12+
jobs:
13+
build-docker:
14+
timeout-minutes: 8
15+
runs-on: ubuntu-20.04
16+
steps:
17+
- uses: actions/checkout@v2
18+
19+
- name: Setup python
20+
uses: actions/setup-python@v1
21+
with:
22+
python-version: 3.8
23+
- name: Install dependencies
24+
run: |
25+
python -m pip install --upgrade pip
26+
pip install flake8 black
27+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
28+
- name: Start containers using docker compose
29+
run: |
30+
echo ${{ secrets.bot_token }} > .env
31+
docker-compose up --build -d
32+
- name: Stop containers
33+
if: always()
34+
run: docker-compose down --rmi all

.github/workflows/lint.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Lint
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
lint:
7+
runs-on: ubuntu-20.04
8+
steps:
9+
- uses: actions/checkout@v2
10+
11+
- name: Setup python
12+
uses: actions/setup-python@v1
13+
with:
14+
python-version: 3.8
15+
- name: Install dependencies
16+
run: |
17+
python -m pip install --upgrade pip
18+
pip install flake8 black
19+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
20+
- name: Lint with flake8
21+
run: |
22+
flake8 . --statistics --show-source
23+
black .

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@ pip-log.txt
44
local_settings.py
55
db.sqlite3
66
.env
7+
.env.dev
8+
.env.prod
9+
.env.ci
710
.venv
811
env/
912
venv/
1013
ENV/
1114
env.bak/
1215
venv.bak/
1316
.mypy_cache/
17+
firebase_config.json

Pi.png

2.31 KB
Loading

Procfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
worker: python bot/src/main.py

README.md

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
<div align="center">
2+
<img src="./Pi.png" alt="" width="256">
3+
<br>
4+
<img alt="GitHub Workflow Status" src="https://img.shields.io/github/workflow/status/yak-fumblepack/pi/Build?style=plastic">
5+
<img src="https://img.shields.io/github/license/yak-fumblepack/pi?style=plastic" alt="">
6+
<img src="https://img.shields.io/badge/code%20style-black-000000.svg?style=plastic" alt="">
7+
<a href="https://discord.com/api/oauth2/authorize?client_id=842500814625832990&permissions=0&scope=bot"><img src="https://img.shields.io/badge/Invite-7289DA?style=plastic&logo=discord&logoColor=white" alt="Invite the bot to your discord server"></a>
8+
</div>
9+
10+
## Overview
11+
12+
Pi is a discord bot for those interested in contest math to practice their skills while engaging in a casual conversation with their fellow mathematicians or friends.
13+
14+
Some features include:
15+
16+
- Ability to fetch problems from USAMO, USAJMO, AIME, AMC 10 & 12
17+
- Fully rendered problems (using LaTeX) with solution links
18+
- Robust points system to promote healthy competition
19+
- Extensible core module, simply make a pull request with your cog and we can add it in without a problem!
20+
21+
Note: It would be preferred if you do not host your own instance of this bot
22+
23+
### Table of contents
24+
- [Getting Started](#getting-started)
25+
- [Commands](#commands)
26+
- [Contributing](#contributing)
27+
- [License](#license)
28+
29+
## Getting Started
30+
31+
### Python venv
32+
33+
Make a virtual environment
34+
35+
```shell
36+
$ mkdir bot && cd bot
37+
$ python -m venv venv
38+
$ source venv/bin/activate
39+
```
40+
41+
Clone the repo
42+
43+
```shell
44+
$ git clone https://github.com/yak-fumblepack/pi.git
45+
$ cd pi
46+
$ pip install -U -r requirements.txt
47+
```
48+
49+
Add your token to the environmental variable file (`.env`). Make sure you are in the project's root directory.
50+
51+
```shell
52+
$ echo "token=<your token without spaces and without the arrow brackets>" > .env
53+
```
54+
55+
Change directory and run the bot.
56+
57+
```shell
58+
$ cd bot/src/
59+
$ python main.py
60+
```
61+
62+
### Docker
63+
64+
Prerequisites:
65+
- Docker
66+
- Docker Compose
67+
68+
To run the bot:
69+
70+
```shell
71+
$ git clone https://github.com/yak-fumblepack/pi.git
72+
$ sudo docker-compose up --build
73+
```
74+
75+
Or if you don't have docker compose, build the image and run it. For more info, refer to their respective readmes:
76+
- [The bot](https://github.com/yak-fumblepack/pi/tree/rewrite/bot)
77+
78+
79+
### Setup
80+
81+
This bot uses firebase as the database service.
82+
83+
Set up the `.env` like so (if you would like to run it using firebase):
84+
85+
```
86+
token=<your token>
87+
bug_channel=<channel id>
88+
feature_channel=<channel id>
89+
firebase_type=
90+
firebase_project_id=
91+
firebase_private_key_id=
92+
firebase_private_key=
93+
firebase_client_email=
94+
firebase_client_id=
95+
firebase_auth_uri=
96+
firebase_token_uri=
97+
firebase_auth_provider_x509_cert_url=
98+
firebase_client_x509_cert_url=
99+
```
100+
101+
Rememeber to omit the < >. There is no space as well.
102+
103+
## Commands
104+
105+
Prefix: `=`
106+
107+
<u>Basic Commands</u>
108+
<br>
109+
| Command | Has Arguments | Arguments | Expected Output |
110+
| --- | --- | --- | --- |
111+
| `=hello` | No | | `Hello, World!` |
112+
| `=help` | Yes | `bot`, `math`, `misc` | An embed showing the arguments you can pass to it to learn more about the other commands |
113+
114+
<u>Bot</u>
115+
<br>
116+
| Command | Has Arguments | Arguments | Expected Output |
117+
| --- | --- | --- | --- |
118+
| `=invite` | No | | Gives invite links to the support server and for the bot |
119+
| `=info` | No | | Gives info about this bot and other other techinical information |
120+
121+
<u>Math</u>
122+
<br>
123+
| Command | Has Arguments | Arguments | Expected Output |
124+
| --- | --- | --- | --- |
125+
| `=statistics` | Yes | `@user`, `user_id` | Gives an embed showing your statistics (if you leave the arguments blank) or someone else's statistics |
126+
| `=tex` | Yes | `tex statement` | Returns a rendered LaTeX statement |
127+
| `=amc10` | Yes | `easy`, `medium`, `hard` | Gives an AMC10 problem of the selected difficulty |
128+
| `=amc12` | Yes | `easy`, `medium`, `hard` | Gives an AMC12 problem of the selected difficulty |
129+
| `=fetch` | Yes | `contest_name year [contest id, optional] problem_number` | Fetches a problem from the specified path |
130+
| `=last5` | Yes | `contest_name` | Returns the last 5 questions from a specified contest |
131+
| `=random` | No | | Returns a random problem |
132+
133+
<u>Miscellaneous</u>
134+
<br>
135+
| Command | Has Arguments | Arguments | Expected Output |
136+
| --- | --- | --- | --- |
137+
| `=suggest` | Yes | `your message` | Allows you to make a feature suggestion or any suggestion. Needs you to complete a captcha |
138+
| `=report` | Yes | `your message` | Allows you to make a bug report or any report on an issue. Needs you to complete a captcha |
139+
140+
## Contributing
141+
142+
Features, bugfixes, issues are all greatly appreciated. Please, if you do encounter a bug, report it to us by opening an issue or even better, fix it yourself and make a pull request!
143+
144+
Please open a pull request or an issue on the `dev` branch.
145+
146+
## License
147+
This project is licensed under the [GNU AGPL-3.0](https://www.gnu.org/licenses/agpl-3.0.txt) license.

0 commit comments

Comments
 (0)