feat(tg-fitness-bot): add telegram fitness bot with web app
Telegram workout tracker bot with Mini App web UI, SQLite database, API server, and cloudflared tunnel support. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
7288d93741
commit
ae09ab2eec
14 changed files with 1892 additions and 0 deletions
87
telegram-fitness-bot/flake.nix
Normal file
87
telegram-fitness-bot/flake.nix
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
{
|
||||
description = "Telegram Fitness Bot — Mini App for tracking gym workouts";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils }:
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
|
||||
python = pkgs.python3;
|
||||
|
||||
pythonEnv = python.withPackages (ps: with ps; [
|
||||
python-telegram-bot
|
||||
aiohttp
|
||||
]);
|
||||
|
||||
# localtunnel via npm
|
||||
localtunnel = pkgs.buildNpmPackage {
|
||||
pname = "localtunnel";
|
||||
version = "2.0.2";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "localtunnel";
|
||||
repo = "localtunnel";
|
||||
rev = "v2.0.2";
|
||||
hash = "sha256-deKDwCjGT+0YjeW/AM2J6IH+hEoQrESmKKM23n0JLWY=";
|
||||
};
|
||||
npmDepsHash = "sha256-R9FYkEe93oGF+dR7i1MxwzEW3EM3SasH/B6LLC2CNXM=";
|
||||
dontNpmBuild = true;
|
||||
};
|
||||
|
||||
runtimePath = pkgs.lib.makeBinPath [
|
||||
pythonEnv
|
||||
localtunnel
|
||||
];
|
||||
|
||||
in {
|
||||
packages.default = pkgs.stdenv.mkDerivation {
|
||||
pname = "telegram-fitness-bot";
|
||||
version = "0.1.0";
|
||||
|
||||
src = pkgs.lib.cleanSource ./.;
|
||||
|
||||
nativeBuildInputs = [ pkgs.makeWrapper ];
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/lib/telegram-fitness-bot
|
||||
cp -r start.py bot.py server.py database.py config.py webapp $out/lib/telegram-fitness-bot/
|
||||
|
||||
mkdir -p $out/bin
|
||||
|
||||
# Main entry point: `nix run` → start.py
|
||||
makeWrapper ${pythonEnv}/bin/python $out/bin/telegram-fitness-bot \
|
||||
--prefix PATH : ${runtimePath} \
|
||||
--add-flags "$out/lib/telegram-fitness-bot/start.py"
|
||||
'';
|
||||
|
||||
meta = with pkgs.lib; {
|
||||
description = "Telegram Mini App for tracking gym workouts";
|
||||
license = licenses.mit;
|
||||
mainProgram = "telegram-fitness-bot";
|
||||
};
|
||||
};
|
||||
|
||||
# `nix develop` — interactive dev shell
|
||||
devShells.default = pkgs.mkShell {
|
||||
packages = [
|
||||
pythonEnv
|
||||
localtunnel
|
||||
];
|
||||
|
||||
shellHook = ''
|
||||
echo ""
|
||||
echo " Fitness Bot dev shell"
|
||||
echo " python: $(python --version)"
|
||||
echo " lt: $(lt --version)"
|
||||
echo ""
|
||||
echo " Run: python start.py"
|
||||
echo ""
|
||||
'';
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue