mirror of
https://github.com/natsukagami/youmubot.git
synced 2025-04-20 09:18:54 +00:00
Compare commits
3 commits
a146883620
...
e07949378c
Author | SHA1 | Date | |
---|---|---|---|
|
e07949378c | ||
|
c148dca438 | ||
|
7399008414 |
6 changed files with 39 additions and 40 deletions
10
.github/workflows/build_test.yml
vendored
10
.github/workflows/build_test.yml
vendored
|
@ -64,6 +64,16 @@ jobs:
|
|||
run: cargo test
|
||||
env:
|
||||
SQLX_OFFLINE: "true"
|
||||
checkDeps:
|
||||
name: Check dependency hash
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: cachix/install-nix-action@v27
|
||||
with:
|
||||
github_access_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Build dependencies
|
||||
run: nix build .#youmubot.cargoDeps --option substituters "https://cache.nixos.org" --option extra-substituters ""
|
||||
build:
|
||||
name: Build
|
||||
runs-on: ubuntu-latest
|
||||
|
|
16
flake.lock
generated
16
flake.lock
generated
|
@ -1,20 +1,5 @@
|
|||
{
|
||||
"nodes": {
|
||||
"crane": {
|
||||
"locked": {
|
||||
"lastModified": 1734744351,
|
||||
"narHash": "sha256-fN9npuZHHHzDVr1wuKoh/TheHkerDaLB9l4vj/48Exg=",
|
||||
"owner": "ipetkov",
|
||||
"repo": "crane",
|
||||
"rev": "a83a48a62640517588c3d137c948ed034706363c",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "ipetkov",
|
||||
"repo": "crane",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
|
@ -51,7 +36,6 @@
|
|||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"crane": "crane",
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"rust-overlay": "rust-overlay"
|
||||
|
|
12
flake.nix
12
flake.nix
|
@ -2,7 +2,6 @@
|
|||
description = "A discord bot for Dự Tuyển Tổng Hợp server";
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
crane.url = "github:ipetkov/crane";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
rust-overlay = {
|
||||
url = "github:oxalica/rust-overlay";
|
||||
|
@ -14,9 +13,6 @@
|
|||
extra-trusted-public-keys = [ "natsukagami.cachix.org-1:3U6GV8i8gWEaXRUuXd2S4ASfYgdl2QFPWg4BKPbmYiQ=" ];
|
||||
};
|
||||
outputs = { self, nixpkgs, flake-utils, ... }@inputs:
|
||||
let
|
||||
rustVersion = "1.83.0";
|
||||
in
|
||||
flake-utils.lib.eachDefaultSystem
|
||||
(system:
|
||||
let
|
||||
|
@ -24,11 +20,9 @@
|
|||
{
|
||||
inherit system; overlays = [ (import inputs.rust-overlay) ];
|
||||
};
|
||||
craneLib = (inputs.crane.mkLib pkgs).overrideToolchain (p: p.rust-bin.stable.${rustVersion}.default);
|
||||
# craneLib = inputs.crane.mkLib pkgs;
|
||||
in
|
||||
rec {
|
||||
packages.youmubot = pkgs.callPackage ./package.nix { inherit craneLib; };
|
||||
packages.youmubot = pkgs.callPackage ./package.nix { };
|
||||
|
||||
defaultPackage = packages.youmubot;
|
||||
|
||||
|
@ -54,9 +48,7 @@
|
|||
};
|
||||
}) // {
|
||||
overlays.default = final: prev: {
|
||||
youmubot = final.callPackage ./package.nix {
|
||||
craneLib = (inputs.crane.mkLib final).overrideToolchain (p: p.rust-bin.stable.${rustVersion}.default);
|
||||
};
|
||||
youmubot = final.callPackage ./package.nix { };
|
||||
};
|
||||
# module
|
||||
nixosModules.default = import ./module.nix;
|
||||
|
|
33
package.nix
33
package.nix
|
@ -1,27 +1,41 @@
|
|||
{ craneLib
|
||||
{ rustPlatform
|
||||
, lib
|
||||
, stdenv
|
||||
, pkg-config
|
||||
, openssl
|
||||
|
||||
, enableCodeforces ? true
|
||||
, enableCodeforces ? false
|
||||
, enableOsu ? true
|
||||
, ...
|
||||
}:
|
||||
let
|
||||
customizeFeatures = !(enableCodeforces && enableOsu);
|
||||
featureFlags = lib.optionals customizeFeatures (
|
||||
[ "--no-default-features" "--features=core" ]
|
||||
++ lib.optional enableCodeforces "--features=codeforces"
|
||||
++ lib.optional enableOsu "--features=osu"
|
||||
);
|
||||
in
|
||||
craneLib.buildPackage {
|
||||
rustPlatform.buildRustPackage {
|
||||
pname = "youmubot";
|
||||
version = "0.1.0";
|
||||
|
||||
src = ./.;
|
||||
cargoExtraArgs = builtins.concatStringsSep " " ([ "--locked" "--package youmubot" ] ++ featureFlags);
|
||||
cargoLock = {
|
||||
lockFile = ./Cargo.lock;
|
||||
outputHashes = {
|
||||
"poise-0.6.1" = "sha256-44pPe02JJ97GEpzAXdQmDq/9bb4KS9G7ZFVlBRC6EYs=";
|
||||
"rosu-v2-0.9.0" = "sha256-dx0EwqqgkLaHwCPHyn5vMkhZ2NZcahH5SACFcsJKP1E=";
|
||||
};
|
||||
};
|
||||
|
||||
buildNoDefaultFeatures = customizeFeatures;
|
||||
buildFeatures = lib.optionals customizeFeatures (
|
||||
[ "core" ]
|
||||
++ lib.optional enableCodeforces "codeforces"
|
||||
++ lib.optional enableOsu "osu"
|
||||
);
|
||||
|
||||
cargoBuildFlags = [
|
||||
"--locked"
|
||||
"--package"
|
||||
"youmubot"
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
openssl
|
||||
|
@ -33,4 +47,3 @@ craneLib.buildPackage {
|
|||
|
||||
SQLX_OFFLINE = "true";
|
||||
}
|
||||
|
||||
|
|
|
@ -32,13 +32,13 @@ pub struct ToPrint<'a> {
|
|||
lazy_static! {
|
||||
// Beatmap(set) hooks
|
||||
static ref OLD_LINK_REGEX: Regex = Regex::new(
|
||||
r"(?:https?://)?osu\.ppy\.sh/(?P<link_type>s|b|beatmaps)/(?P<id>\d+)(?:[\&\?]m=(?P<mode>[0123]))?(?:(?P<mods>v2|[[:^alpha:]]\S+\b))?"
|
||||
r"(?:https?://)?osu\.ppy\.sh/(?P<link_type>s|b|beatmaps)/(?P<id>\d+)(?:[\&\?]m=(?P<mode>[0123]))?(?:(?P<mods>v2|[[:^alpha:]][\w@.]+\b))?"
|
||||
).unwrap();
|
||||
static ref NEW_LINK_REGEX: Regex = Regex::new(
|
||||
r"(?:https?://)?osu\.ppy\.sh/beatmapsets/(?P<set_id>\d+)/?(?:\#(?P<mode>osu|taiko|fruits|mania)(?:/(?P<beatmap_id>\d+)|/?))?(?:(?P<mods>v2|[[:^alpha:]]\S+\b))?"
|
||||
r"(?:https?://)?osu\.ppy\.sh/beatmapsets/(?P<set_id>\d+)/?(?:\#(?P<mode>osu|taiko|fruits|mania)(?:/(?P<beatmap_id>\d+)|/?))?(?:(?P<mods>v2|[[:^alpha:]][\w@.]+\b))?"
|
||||
).unwrap();
|
||||
static ref SHORT_LINK_REGEX: Regex = Regex::new(
|
||||
r"(?:^|\s|\W)(?P<main>/(?P<link_type>b|s)/(?P<id>\d+)(?:/(?P<mode>osu|taiko|fruits|mania))?(?:(?P<mods>v2|[[:^alpha:]]\S+\b))?)"
|
||||
r"(?:^|\s|\W)(?P<main>/(?P<link_type>b|s)/(?P<id>\d+)(?:/(?P<mode>osu|taiko|fruits|mania))?(?:(?P<mods>v2|[[:^alpha:]][\w@.]+\b))?)"
|
||||
).unwrap();
|
||||
|
||||
// Score hook
|
||||
|
|
|
@ -1044,7 +1044,7 @@ pub(crate) async fn do_check(
|
|||
osu_client
|
||||
.scores(b.beatmap_id, |f| f.user(UserID::ID(user.id)).mode(m))
|
||||
.map_ok(move |mut v| {
|
||||
v.retain(|s| mods.as_ref().is_none_or(|m| m.contains(&s.mods)));
|
||||
v.retain(|s| mods.as_ref().is_none_or(|m| s.mods.contains(&m)));
|
||||
v
|
||||
})
|
||||
.await
|
||||
|
|
Loading…
Add table
Reference in a new issue