7
.clang-format
Normal file
7
.clang-format
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
BasedOnStyle: GNU
|
||||||
|
IndentWidth: 4
|
||||||
|
BreakBeforeBraces: Attach
|
||||||
|
AlwaysBreakTemplateDeclarations: Yes
|
||||||
|
AlignConsecutiveAssignments: Consecutive
|
||||||
|
BreakAfterAttributes: Always
|
||||||
|
AllowShortEnumsOnASingleLine: False
|
12
.clang-tidy
Normal file
12
.clang-tidy
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
Checks: '
|
||||||
|
, clang-analyzer-*
|
||||||
|
, cppcoreguidelines-*
|
||||||
|
, -cppcoreguidelines-avoid-magic-numbers
|
||||||
|
, -cppcoreguidelines-pro-bounds-constant-array-index
|
||||||
|
, -cppcoreguidelines-macro-usage
|
||||||
|
, -cppcoreguidelines-avoid-const-or-ref-data-members
|
||||||
|
, -cppcoreguidelines-non-private-member-variables-in-classes
|
||||||
|
, -cppcoreguidelines-avoid-non-const-global-variables
|
||||||
|
, -cppcoreguidelines-pro-type-member-init
|
||||||
|
, -cppcoreguidelines-init-variables
|
||||||
|
'
|
10
.gitignore
vendored
Normal file
10
.gitignore
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
# Direnv
|
||||||
|
.envrc
|
||||||
|
.direnv/
|
||||||
|
|
||||||
|
# Emacs
|
||||||
|
*~
|
||||||
|
\#*\#
|
||||||
|
|
||||||
|
# Cache
|
||||||
|
.cache/
|
61
flake.lock
generated
Normal file
61
flake.lock
generated
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1757686808,
|
||||||
|
"narHash": "sha256-PL+Z3OrNpFNHddbsBaxeojYkWObYc2NlyhTmsmpt+hc=",
|
||||||
|
"owner": "nixos",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "098982b6eca9b809cc2f583e733338f5a36b3ad8",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nixos",
|
||||||
|
"ref": "nixpkgs-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": "nixpkgs",
|
||||||
|
"utils": "utils"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"systems": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1681028828,
|
||||||
|
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"utils": {
|
||||||
|
"inputs": {
|
||||||
|
"systems": "systems"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1731533236,
|
||||||
|
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
85
flake.nix
Normal file
85
flake.nix
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
{
|
||||||
|
description = "singh5 discord bot";
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
|
||||||
|
utils.url = "github:numtide/flake-utils";
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs =
|
||||||
|
inputs@{
|
||||||
|
self,
|
||||||
|
nixpkgs,
|
||||||
|
utils,
|
||||||
|
}:
|
||||||
|
utils.lib.eachDefaultSystem (
|
||||||
|
system:
|
||||||
|
let
|
||||||
|
pkgs = import nixpkgs {
|
||||||
|
inherit system;
|
||||||
|
};
|
||||||
|
|
||||||
|
src = pkgs.lib.sourceFilesBySuffices ./. [
|
||||||
|
".hh"
|
||||||
|
".cc"
|
||||||
|
".build"
|
||||||
|
".options"
|
||||||
|
];
|
||||||
|
|
||||||
|
llvm = pkgs.llvmPackages_21;
|
||||||
|
|
||||||
|
package =
|
||||||
|
{ stdenv }:
|
||||||
|
stdenv.mkDerivation {
|
||||||
|
name = "singh5";
|
||||||
|
version = "0.1";
|
||||||
|
inherit src;
|
||||||
|
|
||||||
|
outputs = [ "out" ];
|
||||||
|
|
||||||
|
nativeBuildInputs = with pkgs; [
|
||||||
|
meson
|
||||||
|
ninja
|
||||||
|
pkg-config
|
||||||
|
];
|
||||||
|
|
||||||
|
buildInputs = with pkgs; [
|
||||||
|
(dpp.override { inherit stdenv; })
|
||||||
|
(ffmpeg.overrideAttrs (_: {
|
||||||
|
inherit stdenv;
|
||||||
|
makeFlags = [
|
||||||
|
"HOSTCC=$\{CC}"
|
||||||
|
"HOSTLD=$\{LD}"
|
||||||
|
];
|
||||||
|
}))
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
shell =
|
||||||
|
{ stdenv }:
|
||||||
|
pkgs.mkShell.override { inherit stdenv; } {
|
||||||
|
name = "singh5";
|
||||||
|
inputsFrom = [ (package { inherit stdenv; }) ];
|
||||||
|
packages = with pkgs; [
|
||||||
|
llvm.clang-tools
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
in
|
||||||
|
{
|
||||||
|
packages = rec {
|
||||||
|
singh5 = package { stdenv = pkgs.gcc15Stdenv; };
|
||||||
|
singh5-clang = package { stdenv = llvm.libcxxStdenv; };
|
||||||
|
default = singh5-clang;
|
||||||
|
};
|
||||||
|
|
||||||
|
devShells = rec {
|
||||||
|
singh5 = shell { stdenv = pkgs.gcc15Stdenv; };
|
||||||
|
singh5-clang = shell { stdenv = llvm.libcxxStdenv; };
|
||||||
|
default = singh5-clang;
|
||||||
|
};
|
||||||
|
|
||||||
|
formatter = pkgs.nixfmt-tree;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
13
meson.build
Normal file
13
meson.build
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
project('singh5', 'cpp',
|
||||||
|
version : '0.1',
|
||||||
|
license : 'GPLv3',
|
||||||
|
default_options : ['warning_level=3',
|
||||||
|
'werror=true',
|
||||||
|
'optimization=3',
|
||||||
|
'cpp_std=c++23'])
|
||||||
|
|
||||||
|
compiler = meson.get_compiler('cpp')
|
||||||
|
|
||||||
|
lib_cpp_args = []
|
||||||
|
|
||||||
|
subdir('src')
|
29
src/main.cc
Normal file
29
src/main.cc
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
#include <cstdlib>
|
||||||
|
#include <dpp/dpp.h>
|
||||||
|
|
||||||
|
const char *
|
||||||
|
get_bot_token () {
|
||||||
|
return getenv ("BOT_TOKEN");
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main () {
|
||||||
|
dpp::cluster bot (get_bot_token ());
|
||||||
|
|
||||||
|
bot.on_log (dpp::utility::cout_logger ());
|
||||||
|
|
||||||
|
bot.on_slashcommand ([] (const dpp::slashcommand_t &event) {
|
||||||
|
if (event.command.get_command_name () == "ping") {
|
||||||
|
event.reply ("Pong!");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
bot.on_ready ([&bot] (const dpp::ready_t &_) {
|
||||||
|
if (dpp::run_once<struct register_bot_commands> ()) {
|
||||||
|
bot.global_command_create (
|
||||||
|
dpp::slashcommand ("ping", "Ping pong!", bot.me.id));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
bot.start (dpp::st_wait);
|
||||||
|
}
|
15
src/meson.build
Normal file
15
src/meson.build
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
sources = files(
|
||||||
|
'main.cc',
|
||||||
|
)
|
||||||
|
|
||||||
|
dpp = dependency('dpp', version: '>=10.1.2', static: true)
|
||||||
|
libavformat = dependency('libavformat', version: '>=61.7.100')
|
||||||
|
libavcodec = dependency('libavcodec', version: '>=61.19.101')
|
||||||
|
|
||||||
|
executable(
|
||||||
|
'singh5',
|
||||||
|
sources,
|
||||||
|
dependencies: [ dpp, libavformat, libavcodec ],
|
||||||
|
install : true,
|
||||||
|
cpp_args: lib_cpp_args
|
||||||
|
)
|
Reference in New Issue
Block a user