Skip to content

Commit

Permalink
Merge branch 'master' into feat/monitoring
Browse files Browse the repository at this point in the history
  • Loading branch information
AiroPi committed Dec 15, 2023
2 parents f40cdf3 + 2db7d8a commit 8e3ddec
Show file tree
Hide file tree
Showing 59 changed files with 620 additions and 1,240 deletions.
24 changes: 6 additions & 18 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,25 @@
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''
labels: unconfirmed bug
assignees: AiroPi

---

<!-- Les rapports de bugs peuvent être rempli en Français ou en Anglais -->
<!-- You can fill in the report in English or French -->

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
The command you used (with arguments), the buttons you clicked, whatever you think is causing the bug.

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
21 changes: 13 additions & 8 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,24 @@
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''
labels: feature request
assignees: AiroPi

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
<!-- Feature requests can be filled in French or in English -->
<!-- Les suggestions de fonctionnalités peuvent être faites en Français ou en Anglais -->

**Describe the solution you'd like**
A clear and concise description of what you want to happen.
[ ] My idea is a whole new feature.
[ ] My suggestion is an enhancement of an existing feature.
[ ] My idea isn't related to the bot.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Describe your idea.**
A clear and concise description of what the problem is. Describe all the details you have in mind.

**Alternatives**
Tell if you know alternatives / other bots that already do this. Explain why you don't use them, what is not great.
You can omit this question if you didn't find any other solution.

**Additional context**
Add any other context or screenshots about the feature request here.
45 changes: 45 additions & 0 deletions .github/workflows/crowdin-download.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Download from crowdin

on:
workflow_dispatch:
schedule:
- cron: 0 * * * *

jobs:
download:
runs-on: ubuntu-latest
# secrets cannot be accessed inside an `if` so this needs to be checked in separate job
name: dowload
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: master

- name: Install crowdin cli
run: |
wget -qO - https://artifacts.crowdin.com/repo/GPG-KEY-crowdin | sudo apt-key add -
echo "deb https://artifacts.crowdin.com/repo/deb/ /" | sudo tee -a /etc/apt/sources.list.d/crowdin.list
sudo apt-get update && sudo apt-get install crowdin3
- name: Download translations
shell: bash
run: |
crowdin download --all
env:
CROWDIN_API_KEY: ${{ secrets.CROWDIN_API_KEY }}

- uses: tibdex/github-app-token@v1
id: generate-token
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}

- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
token: ${{ steps.generate-token.outputs.token }}
commit-message: "PO files added."
branch: auto/crowdin
title: "Update translations"
add-paths: "**.po"
40 changes: 40 additions & 0 deletions .github/workflows/crowdin-upload.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Upload to crowdin

on:
workflow_dispatch:
push:
branches: [master]
paths:
- "**.py"

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
ref: master

- name: Install crowdin cli
run: |
wget -qO - https://artifacts.crowdin.com/repo/GPG-KEY-crowdin | sudo apt-key add -
echo "deb https://artifacts.crowdin.com/repo/deb/ /" | sudo tee -a /etc/apt/sources.list.d/crowdin.list
sudo apt-get update && sudo apt-get install crowdin3
- uses: actions/setup-python@v4
with:
python-version: "3.11"
cache: pip

- name: babel extract (pot file generation)
run: |
pip install babel
sh ./bin/pot-generation.sh
- name: Upload sources
shell: bash
run: |
crowdin upload
env:
CROWDIN_API_KEY: ${{ secrets.CROWDIN_API_KEY }}
27 changes: 0 additions & 27 deletions .github/workflows/generate-mo-files.yml

This file was deleted.

48 changes: 0 additions & 48 deletions .github/workflows/generate-pot-file.yml

This file was deleted.

26 changes: 20 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
FROM python:3.11.2 as base
FROM python:3.12.0-alpine as build
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
RUN --mount=type=cache,target=/var/cache/apk/ \
--mount=type=cache,target=/root/.cache/pip \
--mount=type=bind,source=requirements.txt,target=requirements.txt \
: \
&& apk add gcc musl-dev linux-headers \
&& pip install -U -r requirements.txt


FROM python:3.12.0-alpine as base
WORKDIR /app
COPY --from=build /opt/venv /opt/venv
COPY ./alembic.ini ./src ./
COPY ./alembic ./alembic
ENV PATH="/opt/venv/bin:$PATH"
ENV PYTHONUNBUFFERED=0
COPY requirements.txt alembic.ini ./
RUN pip install -U -r requirements.txt


FROM base as prod
COPY ./src ./
CMD ["/bin/bash", "-c", "alembic upgrade head && python ./main.py bot --sync -c ./config.toml"]
CMD ["/bin/sh", "-c", "alembic upgrade head && python ./main.py bot --sync -c ./config.toml"]


FROM base as debug
ENV DEBUG=1
ENV LOG_LEVEL=DEBUG
RUN pip install debugpy
CMD ["/bin/bash", "-c", "alembic upgrade head && python -m debugpy --wait-for-client --listen 0.0.0.0:5678 ./src/main.py bot -c ./config.toml"]
CMD ["/bin/sh", "-c", "alembic upgrade head && python -m debugpy --wait-for-client --listen 0.0.0.0:5678 ./main.py bot -c ./config.toml"]
51 changes: 34 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,40 @@
# mybot
<img src="https://bannermd.airopi.dev/banner?title=MyBot&desc=An%20original%20Discord%20bot!&repo=mybot-organization/mybot" width="100%" alt="banner"/>
<p align="center">
<a href="https://www.buymeacoffee.com/airopi" target="_blank">
<img alt="Static Badge" src="https://img.shields.io/badge/Buy_me_a_coffee!-grey?style=for-the-badge&logo=buymeacoffee">
</a>
</p>

The official repository of Mybot project!
<h1 align="center">MyBot</h1>

In order to generate auto-migration scripts using alembic, stop the bot (docker-compose down), run the database (docker-compose up -d database) and enter in shell :
`docker-compose run --rm -it --entrypoint=/bin/bash mybot -i`
MyBot is an original Discord bot. It was created to offer useful and little-seen features.

Then, apply eventual migrations :
`alembic upgrade head`
This project is motivated by a desire to do things to the maximum possible extent, offering the richest possible functionality!

And finally, create a migration script :
`alembic revision --autogenerate -m "your message"`
## Links

- [Support](https://support.mybot.airopi.dev/)
- [Invite](https://invite.mybot.airopi.dev/)

Commands :
```bash
docker-compose down
docker-compose build
docker-compose up -d database
docker-compose run --rm -it --entrypoint=/bin/bash mybot -i
alembic upgrade head
alembic revision --autogenerate -m "your message"
```
## Using

- [Python 3.12](https://www.python.org/)
- [discord.py](https://discordpy.readthedocs.io/en/latest/)
- [PostgreSQL 14](https://www.postgresql.org/)
- [TimeScale](https://www.timescale.com/)

## Deploy

_Soon_

## Support, Feedback and Community

You can reach me over Discord at `@airo.pi`. Feel free to open an issue if you encounter any problem!

## How to contribute

I would ❤️ to see your contribution! Refer to [CONTRIBUTING.md](/CONTRIBUTING.md)

## License

MyBot is under the [MIT Licence](/LICENSE).
2 changes: 2 additions & 0 deletions bin/alembic.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
docker compose --progress quiet up database -d --quiet-pull
docker compose --progress quiet run --rm -t -v "${PWD}/alembic:/app/alembic" mybot alembic "$@"
2 changes: 1 addition & 1 deletion bin/po-to-mo.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env bash
python3 ./bin/msgfmt.py ./data/locale/**/LC_MESSAGES/*.po
python3 ./bin/msgfmt.py ./resources/locale/**/LC_MESSAGES/*.po
2 changes: 1 addition & 1 deletion bin/pot-generation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ pybabel extract \
--project="MyBot" \
--version="1.0" \
-k "_ __" \
-o ./data/locale/mybot.pot \
-o ./resources/locale/mybot.pot \
./src/
7 changes: 5 additions & 2 deletions crowdin.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
project_id: "532668"
api_token_env: CROWDIN_API_KEY

files:
- source: /data/locale/*.pot
translation: /data/locale/%locale%/LC_MESSAGES/%file_name%.po
- source: /resources/locale/*.pot
translation: /resources/locale/%locale%/LC_MESSAGES/%file_name%.po
Binary file removed data/locale/fr/LC_MESSAGES/mybot.mo
Binary file not shown.
Loading

0 comments on commit 8e3ddec

Please sign in to comment.