1
Fork 0
mirror of https://github.com/RGBCube/minearchy-bot synced 2025-05-14 06:54:58 +00:00

feat: package with nix and docker

This commit is contained in:
RGBCube 2025-04-11 21:20:48 +03:00
parent fb63e83312
commit b0b82aa689
No known key found for this signature in database
8 changed files with 118 additions and 99 deletions

9
.gitignore vendored
View file

@ -5,9 +5,8 @@
!minearchy_bot/
!minearchy_bot/**/
!*.py
!*.example.json
!*.sh
!*.md
!*.toml
!*.lock
!*.md
!*.nix
!*.py
!*.toml

View file

@ -1,14 +1,7 @@
# Minearchy Bot
This is a simple bot made for the [Minearchy Discord server](https://discord.gg/2n6T78JS9k).
## Running
1: Clone this repo and `cd` into it.
2: Edit the `./minearchy_bot/config.example.json` to your liking and rename it to `config.json`.
4: Run `./start.sh`, requires `uv`.
This is a simple bot made for the
[Minearchy Discord server](https://discord.gg/2n6T78JS9k).
## License

43
flake.lock generated Normal file
View file

@ -0,0 +1,43 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1744316434,
"narHash": "sha256-lzFCg/1C39pyY2hMB2gcuHV79ozpOz/Vu15hdjiFOfI=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "d19cf9dfc633816a437204555afeb9e722386b76",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs",
"systems": "systems"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

55
flake.nix Normal file
View file

@ -0,0 +1,55 @@
{
description = "A simple bot made for the Minearchy Discord server";
inputs = {
systems.url = "github:nix-systems/default";
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
};
outputs = { systems, nixpkgs, ... }: let
eachSystem = nixpkgs.lib.genAttrs (import systems);
in {
packages = eachSystem (system: let
pkgs = import nixpkgs { inherit system; };
pypkgs = pkgs.python313Packages;
in rec {
default = minearchy-bot;
minearchy-bot = pypkgs.buildPythonApplication {
pname = "minearchy-bot";
version = "0.0.1";
src = ./.;
format = "pyproject";
build-system = [ pypkgs.setuptools ];
dependencies = [
pypkgs.discordpy
# TODO: pypkgs.jishaku
pypkgs.mcstatus
];
};
minearchy-bot-container = pkgs.dockerTools.buildImage {
name = "minearchy-bot";
tag = "latest";
copyToRoot = pkgs.buildEnv {
name = "image-root";
pathsToLink = [ "/bin" ];
paths = [
pkgs.uutils-coreutils-noprefix
minearchy-bot
];
};
config.Env = [ "PATH=/bin" ];
config.WorkingDir = "/minearcy-bot";
config.Cmd = "${minearchy-bot}/bin/minearchy-bot";
};
});
};
}

View file

@ -1,32 +1,27 @@
from __future__ import annotations
import asyncio
import json
from os import environ as env
from pathlib import Path
from . import MinearchyBot
async def main() -> None:
config = json.loads(
(
Path(__file__).parent / "config.json"
).read_text()
)
async def async_main() -> None:
env[f"JISHAKU_HIDE"] = "True"
env[f"JISHAKU_NO_UNDERSCORE"] = "True"
bot = MinearchyBot(
token = config["BOT_TOKEN"],
webhook_url = config["WEBHOOK_URL"]
token = env["MINEARCHY_BOT_TOKEN"],
webhook_url = env["MINEARCHY_BOT_WEBHOOK_URL"]
)
await bot.run()
if __name__ == "__main__":
def main() -> None:
try:
asyncio.run(main())
asyncio.run(async_main())
except KeyboardInterrupt:
pass
if __name__ == "__main__":
main()

View file

@ -6,6 +6,10 @@ requires-python = ">=3.10"
authors = [ { name = "RGBCube", email = "git@rgbcu.be" } ]
urls.repository = "https://github.com/RGBCube/minearchy-bot"
readme = "README.md"
license = "GPL-3.0-or-later"
license.text = "GPL-3.0-or-later"
dependencies = [ "discord-py>=2.5.2", "jishaku>=2.6.0", "mcstatus>=11.1.1" ]
# TODO: jishaku
dependencies = [ "discord-py>=2.5.2", "mcstatus>=11.1.1" ]
[project.scripts]
minearchy-bot = "minearchy_bot.__main__:main"

View file

@ -1,3 +0,0 @@
#!/bin/bash
uv run --module minearchy_bot -- $@

67
uv.lock generated
View file

@ -179,36 +179,6 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/5d/35/be73b6015511aa0173ec595fc579133b797ad532996f2998fd6b8d1bbe6b/audioop_lts-0.2.1-cp313-cp313t-win_arm64.whl", hash = "sha256:78bfb3703388c780edf900be66e07de5a3d4105ca8e8720c5c4d67927e0b15d0", size = 23918 },
]
[[package]]
name = "braceexpand"
version = "0.1.7"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/54/93/badd4f5ccf25209f3fef2573073da9fe4a45a3da99fca2f800f942130c0f/braceexpand-0.1.7.tar.gz", hash = "sha256:e6e539bd20eaea53547472ff94f4fb5c3d3bf9d0a89388c4b56663aba765f705", size = 7777 }
wheels = [
{ url = "https://files.pythonhosted.org/packages/fa/93/e8c04e80e82391a6e51f218ca49720f64236bc824e92152a2633b74cf7ab/braceexpand-0.1.7-py2.py3-none-any.whl", hash = "sha256:91332d53de7828103dcae5773fb43bc34950b0c8160e35e0f44c4427a3b85014", size = 5923 },
]
[[package]]
name = "click"
version = "8.1.8"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "colorama", marker = "sys_platform == 'win32'" },
]
sdist = { url = "https://files.pythonhosted.org/packages/b9/2e/0090cbf739cee7d23781ad4b89a9894a41538e4fcf4c31dcdd705b78eb8b/click-8.1.8.tar.gz", hash = "sha256:ed53c9d8990d83c2a27deae68e4ee337473f6330c040a31d4225c9574d16096a", size = 226593 }
wheels = [
{ url = "https://files.pythonhosted.org/packages/7e/d4/7ebdbd03970677812aac39c869717059dbb71a4cfc033ca6e5221787892c/click-8.1.8-py3-none-any.whl", hash = "sha256:63c132bbbed01578a06712a2d1f497bb62d9c1c0d329b7903a866228027263b2", size = 98188 },
]
[[package]]
name = "colorama"
version = "0.4.6"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/d8/53/6f443c9a4a8358a93a6792e2acffb9d9d5cb0a5cfd8802644b7b1c9a02e4/colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44", size = 27697 }
wheels = [
{ url = "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", size = 25335 },
]
[[package]]
name = "discord-py"
version = "2.5.2"
@ -309,32 +279,6 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/76/c6/c88e154df9c4e1a2a66ccf0005a88dfb2650c1dffb6f5ce603dfbd452ce3/idna-3.10-py3-none-any.whl", hash = "sha256:946d195a0d259cbba61165e88e65941f16e9b36ea6ddb97f00452bae8b1287d3", size = 70442 },
]
[[package]]
name = "import-expression"
version = "2.2.1.post1"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/95/dd/4c561ce20064985b2a7d3eadb4002c981c8906a4efd309a0b595acb2727a/import_expression-2.2.1.post1.tar.gz", hash = "sha256:1c831bf26bef7edf36a97b34c687b962e7abe06116c66f00e14f9a3218623d4f", size = 16044 }
wheels = [
{ url = "https://files.pythonhosted.org/packages/38/92/437a1dbc58241770198dc4d966a2e6363bd684f961070623aec975cfe03f/import_expression-2.2.1.post1-py3-none-any.whl", hash = "sha256:7b3677e889816e0dbdcc7f42f4534071c54c667f32c71097522ea602f6497902", size = 23919 },
]
[[package]]
name = "jishaku"
version = "2.6.0"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "braceexpand" },
{ name = "click" },
{ name = "discord-py" },
{ name = "import-expression" },
{ name = "tabulate" },
{ name = "typing-extensions" },
]
sdist = { url = "https://files.pythonhosted.org/packages/cc/59/72e38c9a0314274a524ec28ef49630734b326e31784c47d0e3b7fe305522/jishaku-2.6.0.tar.gz", hash = "sha256:b9b4d053b8cbdb6a8fd7a8d549d0928c2e5294044cbb145cbb26df36f97ce289", size = 74679 }
wheels = [
{ url = "https://files.pythonhosted.org/packages/ad/9a/ea48e6f0bef605618c32feaab2fcd6a02ac74113d67f9ae20586af602e70/jishaku-2.6.0-py3-none-any.whl", hash = "sha256:a39366e5b2bd51c0d21ef8783c3e00c927c59792a2b0f5467c156b1f69eb912b", size = 80658 },
]
[[package]]
name = "mcstatus"
version = "11.1.1"
@ -354,14 +298,12 @@ version = "0.0.1"
source = { virtual = "." }
dependencies = [
{ name = "discord-py" },
{ name = "jishaku" },
{ name = "mcstatus" },
]
[package.metadata]
requires-dist = [
{ name = "discord-py", specifier = ">=2.5.2" },
{ name = "jishaku", specifier = ">=2.6.0" },
{ name = "mcstatus", specifier = ">=11.1.1" },
]
@ -550,15 +492,6 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/54/21/f43f0a1fa8b06b32812e0975981f4677d28e0f3271601dc88ac5a5b83220/setuptools-78.1.0-py3-none-any.whl", hash = "sha256:3e386e96793c8702ae83d17b853fb93d3e09ef82ec62722e61da5cd22376dcd8", size = 1256108 },
]
[[package]]
name = "tabulate"
version = "0.9.0"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/ec/fe/802052aecb21e3797b8f7902564ab6ea0d60ff8ca23952079064155d1ae1/tabulate-0.9.0.tar.gz", hash = "sha256:0095b12bf5966de529c0feb1fa08671671b3368eec77d7ef7ab114be2c068b3c", size = 81090 }
wheels = [
{ url = "https://files.pythonhosted.org/packages/40/44/4a5f08c96eb108af5cb50b41f76142f0afa346dfa99d5296fe7202a11854/tabulate-0.9.0-py3-none-any.whl", hash = "sha256:024ca478df22e9340661486f85298cff5f6dcdba14f3813e8830015b9ed1948f", size = 35252 },
]
[[package]]
name = "typing-extensions"
version = "4.13.1"