From 5147a56672f727ee628b7cd2a809997fbd21b32e Mon Sep 17 00:00:00 2001 From: yen Date: Wed, 28 Feb 2024 17:50:06 +0100 Subject: [PATCH] use flake and direnv --- .envrc | 1 + default.nix | 10 -------- flake.lock | 61 ++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 27 +++++++++++++++++++++ seshsecretary.py | 4 ++-- 5 files changed, 91 insertions(+), 12 deletions(-) create mode 100644 .envrc delete mode 100644 default.nix create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..a5dbbcb --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake . diff --git a/default.nix b/default.nix deleted file mode 100644 index 8e98f99..0000000 --- a/default.nix +++ /dev/null @@ -1,10 +0,0 @@ -let - pkgs = import {}; -in pkgs.mkShell { - packages = [ - (pkgs.python3.withPackages (python-pkgs: [ - python-pkgs.python-telegram-bot - ])) - ]; -} - diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..6abb3e2 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1709126324, + "narHash": "sha256-q6EQdSeUZOG26WelxqkmR7kArjgWCdw5sfJVHPH/7j8=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "d465f4819400de7c8d874d50b982301f28a84605", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1709101946, + "narHash": "sha256-TsySgcWm/GlbYdL3AEva49ceeI2BdPQ7muwfYNr1fwo=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "d53c2037394da6fe98decca417fc8fda64bf2443", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "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 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..a3bacbd --- /dev/null +++ b/flake.nix @@ -0,0 +1,27 @@ +{ + description = "Python3 telegram bot environment"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils, ... }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { + inherit system; + }; + pythonEnv = pkgs.python3.withPackages (ps: with ps; [ + python-telegram-bot + ]); + in + { + devShells.default = pkgs.mkShell { + buildInputs = with pkgs; [ + pythonEnv + ]; + }; + }); +} + diff --git a/seshsecretary.py b/seshsecretary.py index bd42b97..d8f3af2 100755 --- a/seshsecretary.py +++ b/seshsecretary.py @@ -1,6 +1,6 @@ #!/usr/bin/python -from telegram.ext import Updater, CommandHandler, Filters +from telegram.ext import Updater, CommandHandler, filters import os from random import randrange import sys @@ -93,7 +93,7 @@ def main(): updater.dispatcher.add_handler(CommandHandler("list", _list)) updater.dispatcher.add_handler(CommandHandler("get", get)) updater.dispatcher.add_handler(CommandHandler("random", random)) - updater.dispatcher.add_handler(CommandHandler("save", save, Filters.reply)) + updater.dispatcher.add_handler(CommandHandler("save", save, filters.REPLY)) updater.start_polling() updater.idle()