Skip to content

Commit 27e63d4

Browse files
committed
merge: Merge branch 'dev' into feat/highlight
2 parents 109a920 + 7784781 commit 27e63d4

25 files changed

+257
-264
lines changed

.github/CHANGELOG.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
# v3.6 (Structure Refactor)
22

3-
> **Info**
3+
> **Note**
44
>
55
> Version 3.6.x is mostly about refactoring the project structure since
66
> previously functions and constants are all over the place that it's starting
77
> to get harder to find what I'm looking for.
88
9-
## 3.6.0 (Project Structure Refactor)
9+
## 3.6.1 (Project Structure Refactor - Part 1.5 A.K.A Hotfix)
10+
11+
- [**Fixed**] Fixed issues related to `import tse`
12+
- [**Fixed**] Aerich caused the bot to crash in production environment
13+
14+
## 3.6.0 (Project Structure Refactor - Part 1)
1015

1116
### Bugfixes
1217
- [**Fixed**] Fixed potential error related to user without avatar
@@ -36,6 +41,8 @@
3641
- [**Improved**] Moved JSON (and Blacklist) and Cache (and its properties) into `core.data`
3742
- [**Changed**] Removed `CMDName`
3843
- [**Added**] Initial ZeroMQ support for Dashboard
44+
- [**Improved**] `ccModeCheck` is now an actual check (`hasCCPriviledge`)
45+
- [**Improved**] CustomCommand is now a converter
3946

4047
# v3.5 (Overhaul an Overhaul?)
4148

.github/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919

2020
## About
2121

22+
> **Note**
23+
>
24+
> `dev` branch is used mostly for development and generally considered as unstable, to host the bot it's recommended to use `overhaul` branch or release tags instead!
25+
2226
**`Z3R0`** (codename **`ziBot`**) is a **free** and **open-source** multi-purpose discord bot, created for fun in the middle of quarantine. Used to be fork of [Steve-Bot](https://github.com/MCBE-Speedrunning/Steve-Bot) by MCBE Speedrunning Moderators.
2327

2428
### Features
@@ -104,7 +108,7 @@ More feature coming soon!
104108
> Python 3.10+ (3.10.9 is recommended) is required to host this bot!
105109

106110
- Download this repository by executing `git clone https://github.com/ZiRO-Bot/Z3R0.git`
107-
or click "Code" -> "Download ZIP"
111+
or click "Code" -> "Download ZIP" (be sure to choose `overhaul` branch first!)
108112
- Install poetry by executing this command,
109113

110114
```zsh

.github/workflows/build.yml

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
name: Nightly Build
1+
name: Build
22

33
on:
44
push:
55
branches:
66
- dev
7+
- overhaul
8+
tags:
9+
- 3.*
710

811
permissions:
912
contents: read
@@ -31,10 +34,37 @@ jobs:
3134
username: ${{ github.repository_owner }}
3235
password: ${{ secrets.GITHUB_TOKEN }}
3336

34-
- name: Build and push
37+
- name: Get tag name
38+
if: startsWith(github.ref, 'refs/tags/') && github.repository == 'ziro-bot/z3r0'
39+
run: |
40+
set -x
41+
echo "VERSION_TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
42+
43+
- name: Build and push (Nightly)
3544
uses: docker/build-push-action@v4
45+
if: ${{ !startsWith(github.ref, 'refs/tags/') && github.ref_name == 'dev' && github.repository == 'ziro-bot/z3r0' }}
3646
with:
3747
context: .
3848
file: ./docker/Dockerfile
3949
push: true
4050
tags: ghcr.io/ziro-bot/z3r0:nightly
51+
52+
- name: Build and push (Canary)
53+
uses: docker/build-push-action@v4
54+
if: ${{ !startsWith(github.ref, 'refs/tags/') && github.ref_name == 'overhaul' && github.repository == 'ziro-bot/z3r0' }}
55+
with:
56+
context: .
57+
file: ./docker/Dockerfile
58+
push: true
59+
tags: ghcr.io/ziro-bot/z3r0:canary
60+
61+
- name: Build and push (Release)
62+
uses: docker/build-push-action@v4
63+
if: startsWith(github.ref, 'refs/tags/') && github.repository == 'ziro-bot/z3r0'
64+
with:
65+
context: .
66+
file: ./docker/Dockerfile
67+
push: true
68+
tags: |
69+
ghcr.io/ziro-bot/z3r0:latest
70+
ghcr.io/ziro-bot/z3r0:${{ env.VERSION_TAG }}

aerich.ini

Lines changed: 0 additions & 4 deletions
This file was deleted.

aerichConfig.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@
1010
except ImportError:
1111
dbUrl = os.environ["ZIBOT_DB_URL"]
1212

13-
cfg = Config("", dbUrl)
13+
cfg = Config("", dbUrl, useAerich=True)
14+
t = cfg.tortoiseConfig

docker/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ ENV PATH="/venv/bin:${PATH}" \
4141
VIRTUAL_ENV="/venv"
4242

4343
COPY --from=builder /venv /venv
44+
COPY --from=builder /app/pyproject.toml /app/
4445
COPY --from=builder /app/src/ /app/src
4546
COPY assets/ /app/assets
4647
COPY docker/__main__.py ./

poetry.lock

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "Z3R0"
3-
version = "3.6.0"
3+
version = "3.6.1"
44
description = "A multi-purpose open source discord bot"
55
authors = ["null2264"]
66
license = "MPL-2.0"
@@ -43,7 +43,7 @@ black = "^22.10.0"
4343
isort = "^5.10.1"
4444
pre-commit = "^2.13.0"
4545
pyproject-flake8 = "^0.0.1-alpha.2"
46-
aerich = "^0.6.2"
46+
aerich = "0.7.1"
4747

4848
[tool.poetry.group.test]
4949

@@ -84,9 +84,9 @@ multi_line_output = 3
8484
lines_after_imports = 2
8585

8686
[tool.aerich]
87-
tortoise_orm = "config.TORTOISE_ORM"
88-
location = "./migrations"
87+
tortoise_orm = "aerichConfig.t"
88+
location = "./src/main/migrations"
8989
src_folder = "./."
9090

9191
[tool.pytest.ini_options]
92-
pythonpath = ["src"]
92+
pythonpath = ["."]

src/main/core/bot.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,20 +232,25 @@ async def on_ready(self) -> None:
232232
self.logger.warning("Ready: {0} (ID: {0.id})".format(self.user))
233233

234234
async def zmqBind(self):
235-
context = zmq.asyncio.Context.instance()
236235
pubPort = self.config.zmqPorts.get("PUB")
236+
subPort = self.config.zmqPorts.get("SUB")
237+
repPort = self.config.zmqPorts.get("REP")
238+
239+
if not pubPort and not subPort and not repPort:
240+
return
241+
242+
context = zmq.asyncio.Context.instance()
243+
237244
if pubPort:
238245
self.pubSocket = context.socket(zmq.PUB)
239246
self.pubSocket.bind(f"tcp://*:{pubPort}")
240247

241-
subPort = self.config.zmqPorts.get("SUB")
242248
if subPort:
243249
self.subSocket = context.socket(zmq.SUB)
244250
self.subSocket.setsockopt(zmq.SUBSCRIBE, b"")
245251
self.subSocket.bind(f"tcp://*:{subPort}")
246252
self.socketTasks.append(asyncio.create_task(self.onZMQReceivePUBMessage()))
247253

248-
repPort = self.config.zmqPorts.get("REP")
249254
if repPort:
250255
self.repSocket = context.socket(zmq.REP)
251256
self.repSocket.bind(f"tcp://*:{repPort}")

src/main/core/config.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class Config:
2525
"internalApiHost",
2626
"test",
2727
"zmqPorts",
28+
"useAerich",
2829
)
2930

3031
def __init__(
@@ -41,6 +42,7 @@ def __init__(
4142
internalApiHost: str | None = None,
4243
test: bool = False,
4344
zmqPorts: dict[str, int] | None = None,
45+
useAerich: bool = False,
4446
):
4547
self.token = token
4648
self.defaultPrefix = defaultPrefix or ">"
@@ -54,18 +56,23 @@ def __init__(
5456
self.internalApiHost = internalApiHost or "127.0.0.1:2264"
5557
self.test = test
5658
self.zmqPorts = zmqPorts or {}
59+
self.useAerich = useAerich
5760

5861
@property
5962
def tortoiseConfig(self):
6063
mainModel = "main.core.db"
6164
if not self.test:
6265
mainModel = "src." + mainModel
6366

67+
models = [mainModel]
68+
if self.useAerich:
69+
models.append("aerich.models")
70+
6471
return self._tortoiseConfig or {
6572
"connections": {"default": self.databaseUrl},
6673
"apps": {
6774
"models": {
68-
"models": [mainModel, "aerich.models"],
75+
"models": models,
6976
"default_connection": "default",
7077
},
7178
},

0 commit comments

Comments
 (0)