Bring client up to date.

This commit is contained in:
niten 2023-03-19 11:27:32 -07:00
parent 60adc2a7b3
commit 5d3a742454
4 changed files with 149 additions and 56 deletions

View File

@ -2,13 +2,13 @@
:paths ["src"] :paths ["src"]
:deps { :deps {
org.clojure/clojure { :mvn/version "1.11.1" } org.clojure/clojure { :mvn/version "1.11.1" }
org.clojure/core.async { :mvn/version "1.5.648" } org.clojure/core.async { :mvn/version "1.6.673" }
net.bis5.mattermost4j/mattermost4j-core { :mvn/version "0.24.0" } net.bis5.mattermost4j/mattermost4j-core { :mvn/version "0.25.0" }
org.fudo/fudo-clojure { org.fudo/fudo-clojure {
:git/url "https://git.fudo.org/fudo-public/fudo-clojure.git" :git/url "https://git.fudo.org/fudo-public/fudo-clojure.git"
:sha "c6a1ebef2e5b64d432a46ac48639c674e62b7cee" :sha "5fd28094e18281ff409050fb1b0dda94b76671ed"
} }
} }
:aliases { :aliases {

137
flake.lock generated
View File

@ -3,17 +3,18 @@
"clj-nix": { "clj-nix": {
"inputs": { "inputs": {
"devshell": "devshell", "devshell": "devshell",
"flake-utils": "flake-utils_2", "flake-utils": "flake-utils",
"nixpkgs": [ "nixpkgs": [
"helpers",
"nixpkgs" "nixpkgs"
] ]
}, },
"locked": { "locked": {
"lastModified": 1659540150, "lastModified": 1677342613,
"narHash": "sha256-FEA04aRQ5R6yZKbVWu1wvYR7ftzMcDK17LfQU7eUISE=", "narHash": "sha256-BqhKj7jQahSVThEwLHt164kJHGx9LXzBARFZaFNLPW8=",
"owner": "jlesquembre", "owner": "jlesquembre",
"repo": "clj-nix", "repo": "clj-nix",
"rev": "d6f4871b43018c9f2027a109b09c7a093c68177c", "rev": "7d9e244ea96988524ba3bd6c2bbafdf0a5340b96",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -22,10 +23,35 @@
"type": "github" "type": "github"
} }
}, },
"clj2nix": {
"inputs": {
"flake-compat": "flake-compat",
"nixpkgs": "nixpkgs",
"utils": "utils"
},
"locked": {
"lastModified": 1673786922,
"narHash": "sha256-MrwSNEXpq20/AvMxW49MRbuqf8C2M4Vei3jtZeXYjJk=",
"owner": "hlolli",
"repo": "clj2nix",
"rev": "04b0dfbfc69c6316b8613d061e3fe4619d79cd9f",
"type": "github"
},
"original": {
"owner": "hlolli",
"repo": "clj2nix",
"type": "github"
}
},
"devshell": { "devshell": {
"inputs": { "inputs": {
"flake-utils": "flake-utils", "flake-utils": [
"helpers",
"clj-nix",
"flake-utils"
],
"nixpkgs": [ "nixpkgs": [
"helpers",
"clj-nix", "clj-nix",
"nixpkgs" "nixpkgs"
] ]
@ -44,22 +70,23 @@
"type": "github" "type": "github"
} }
}, },
"flake-utils": { "flake-compat": {
"flake": false,
"locked": { "locked": {
"lastModified": 1642700792, "lastModified": 1668681692,
"narHash": "sha256-XqHrk7hFb+zBvRg6Ghl+AZDq03ov6OshJLiSWOoX5es=", "narHash": "sha256-Ht91NGdewz8IQLtWZ9LCeNXMSXHUss+9COoqu6JLmXU=",
"owner": "numtide", "owner": "edolstra",
"repo": "flake-utils", "repo": "flake-compat",
"rev": "846b2ae0fc4cc943637d3d1def4454213e203cba", "rev": "009399224d5e398d03b22badca40a37ac85412a1",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "numtide", "owner": "edolstra",
"repo": "flake-utils", "repo": "flake-compat",
"type": "github" "type": "github"
} }
}, },
"flake-utils_2": { "flake-utils": {
"locked": { "locked": {
"lastModified": 1656928814, "lastModified": 1656928814,
"narHash": "sha256-RIFfgBuKz6Hp89yRr7+NR5tzIAbn52h8vT6vXkYjZoM=", "narHash": "sha256-RIFfgBuKz6Hp89yRr7+NR5tzIAbn52h8vT6vXkYjZoM=",
@ -74,29 +101,97 @@
"type": "github" "type": "github"
} }
}, },
"helpers": {
"inputs": {
"clj-nix": "clj-nix",
"clj2nix": "clj2nix",
"nixpkgs": [
"nixpkgs"
],
"utils": "utils_2"
},
"locked": {
"lastModified": 1677792046,
"narHash": "sha256-GU7czTodGN+6ijrz5MuREJMyfPo9aDsXRjaZA+nl+ys=",
"ref": "refs/heads/master",
"rev": "d54fa928c37e7f260c2b99bc733634347e83d9fd",
"revCount": 32,
"type": "git",
"url": "https://git.fudo.org/fudo-public/nix-helpers.git"
},
"original": {
"type": "git",
"url": "https://git.fudo.org/fudo-public/nix-helpers.git"
}
},
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1659446231, "lastModified": 1673785507,
"narHash": "sha256-hekabNdTdgR/iLsgce5TGWmfIDZ86qjPhxDg/8TlzhE=", "narHash": "sha256-EPUT8yVdvJhhjhbgnFWXXd4IUPKSOmww2+z4AmOdyPI=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "eabc38219184cc3e04a974fe31857d8e0eac098d", "rev": "d06d765eeac716d8f1ca80f0935fd6fc951816ad",
"type": "github"
},
"original": {
"owner": "NixOS",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1679139072,
"narHash": "sha256-Gtw2Yj8DfETie3u7iHv1y5Wt+plGRmp6nTQ0EEfaPho=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "08ef7dc8334521605a5c8b7086cc248e74ee338b",
"type": "github" "type": "github"
}, },
"original": { "original": {
"id": "nixpkgs", "id": "nixpkgs",
"ref": "nixos-21.11", "ref": "nixos-22.11",
"type": "indirect" "type": "indirect"
} }
}, },
"root": { "root": {
"inputs": { "inputs": {
"clj-nix": "clj-nix", "helpers": "helpers",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs_2",
"utils": "utils" "utils": "utils_3"
} }
}, },
"utils": { "utils": {
"locked": {
"lastModified": 1667395993,
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"utils_2": {
"locked": {
"lastModified": 1676283394,
"narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"utils_3": {
"locked": { "locked": {
"lastModified": 1659877975, "lastModified": 1659877975,
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",

View File

@ -2,35 +2,33 @@
description = "BeBot Mattermost chatbot Clojure library."; description = "BeBot Mattermost chatbot Clojure library.";
inputs = { inputs = {
nixpkgs.url = "nixpkgs/nixos-21.11"; nixpkgs.url = "nixpkgs/nixos-22.11";
utils.url = "github:numtide/flake-utils"; utils.url = "github:numtide/flake-utils";
clj-nix = { helpers = {
url = "github:jlesquembre/clj-nix"; url = "git+https://git.fudo.org/fudo-public/nix-helpers.git";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
}; };
outputs = { self, nixpkgs, utils, clj-nix, ... }: outputs = { self, nixpkgs, utils, helpers, ... }:
utils.lib.eachDefaultSystem (system: utils.lib.eachDefaultSystem (system:
let let pkgs = nixpkgs.legacyPackages."${system}";
pkgs = nixpkgs.legacyPackages."${system}";
cljpkgs = clj-nix.packages."${system}";
update-deps = pkgs.writeShellScriptBin "update-deps.sh" ''
${clj-nix.packages."${system}".deps-lock}/bin/deps-lock
'';
in { in {
packages = { packages = rec {
bebot = cljpkgs.mkCljBin { default = bebot;
projectSrc = ./.; bebot = helpers.packages."${system}".mkClojureLib {
name = "org.fudo/bebot"; name = "org.fudo/bebot";
main-ns = "bebot.core"; primaryNamespace = "bebot.core";
jdkRunner = pkgs.jdk17_headless; src = ./.;
}; };
}; };
packages.default = self.packages."${system}".bebot; devShells = rec {
default = updateDeps;
devShells.default = updateDeps = pkgs.mkShell {
pkgs.mkShell { buildInputs = with pkgs; [ clojure update-deps ]; }; buildInputs = with helpers.packages."${system}";
[ updateClojureDeps ];
};
};
}); });
} }

View File

@ -4,10 +4,8 @@
[bebot.api.channel :as chan] [bebot.api.channel :as chan]
[fudo-clojure.result :refer [let-result exception-failure success failure map-success dispatch-result]] [fudo-clojure.result :refer [let-result exception-failure success failure map-success dispatch-result]]
[clojure.core.async :as async :refer [go-loop chan timeout >! <!]]) [clojure.core.async :as async :refer [go-loop chan timeout >! <!]])
(:import (net.bis5.mattermost.client4 ApiResponse (:import net.bis5.mattermost.client4.MattermostClient
MattermostClient) net.bis5.mattermost.model.ChannelView))
net.bis5.mattermost.model.ChannelView)
(:use bebot.api.client))
(defn- to-result [resp] (defn- to-result [resp]
(if (.hasError resp) (if (.hasError resp)
@ -27,24 +25,26 @@
(defn- to-millis [instant] (defn- to-millis [instant]
(.toEpochMilli instant)) (.toEpochMilli instant))
(defn- pthru [o] (clojure.pprint/pprint o) o)
(defn- sort-by-create-date [objs] (defn- sort-by-create-date [objs]
(defn compare-dates [a b] (letfn [(compare-dates [a b]
(.isBefore (created-at a) (created-at b))) (.isBefore (created-at a) (created-at b)))]
(sort compare-dates objs)) (sort compare-dates objs)))
(defn- remove-posts-by [user posts] (defn- remove-posts-by [user posts]
(defn post-by-user? [post] (= (id user) (user-id post))) (letfn [(post-by-user? [post]
(filter (complement post-by-user?) posts)) (= (id user) (user-id post)))]
(filter (complement post-by-user?) posts)))
#_(defn make-lazy-seq #_(defn make-lazy-seq
([f] (make-lazy-seq f 60)) ([f] (make-lazy-seq f 60))
([f delay] ([f delay]
(lazy-seq (concat (f) (make-lazy-seq f delay))))) (lazy-seq (concat (f) (make-lazy-seq f delay)))))
(defn- yield-to-channel [coll-gen & { :keys [poll-delay buffer-size] :or {poll-delay 30 buffer-size 10}}] (defn- yield-to-channel
(let [out-chan (chan 10)] [coll-gen &
{:keys [poll-delay buffer-size]
:or {poll-delay 30 buffer-size 10}}]
(let [out-chan (chan buffer-size)]
(go-loop [result (coll-gen)] (go-loop [result (coll-gen)]
(dispatch-result result (dispatch-result result
([os] (doseq [o (sort-by-create-date os)] ([os] (doseq [o (sort-by-create-date os)]