From ce164398d51cccb6a0427b404b71fd07e56a7ee0 Mon Sep 17 00:00:00 2001 From: niten Date: Mon, 19 Feb 2024 15:42:46 -0800 Subject: [PATCH] Initial checkin --- deps-lock.json | 426 +++++++++++++++++++++++++++++++++++++++++++ deps.edn | 9 + flake.lock | 230 +++++++++++++++++++++++ flake.nix | 34 ++++ src/mebot/client.clj | 228 +++++++++++++++++++++++ src/mebot/core.clj | 1 + 6 files changed, 928 insertions(+) create mode 100644 deps-lock.json create mode 100644 deps.edn create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 src/mebot/client.clj create mode 100644 src/mebot/core.clj diff --git a/deps-lock.json b/deps-lock.json new file mode 100644 index 0000000..67ebcfb --- /dev/null +++ b/deps-lock.json @@ -0,0 +1,426 @@ +{ + "lock-version": 3, + "git-deps": [], + "mvn-deps": [ + { + "mvn-path": "camel-snake-kebab/camel-snake-kebab/0.4.3/camel-snake-kebab-0.4.3.jar", + "mvn-repo": "https://repo.clojars.org/", + "hash": "sha256-gZHzNXdjENeFekCtMyVL5mrbNjgGsYE22IQxlpI6wsg=" + }, + { + "mvn-path": "camel-snake-kebab/camel-snake-kebab/0.4.3/camel-snake-kebab-0.4.3.pom", + "mvn-repo": "https://repo.clojars.org/", + "hash": "sha256-LVp6g6ymqHa1ZOMHYD0CRaNxZ4osT0xoEH7dC5sLv7s=" + }, + { + "mvn-path": "clj-http/clj-http/3.12.3/clj-http-3.12.3.jar", + "mvn-repo": "https://repo.clojars.org/", + "hash": "sha256-OJ0pdhKo6KzGbF0NZKbJO99lDe1iXG9q4Wk7kzaKkaU=" + }, + { + "mvn-path": "clj-http/clj-http/3.12.3/clj-http-3.12.3.pom", + "mvn-repo": "https://repo.clojars.org/", + "hash": "sha256-Jx0VRYS9iV/S4w9jEVAE8ce4xySq6tLLKpl8XFWEBfA=" + }, + { + "mvn-path": "clj-tuple/clj-tuple/0.2.2/clj-tuple-0.2.2.jar", + "mvn-repo": "https://repo.clojars.org/", + "hash": "sha256-WNv3Pai8403EmN5sNH+HLvmPMBo6KdyVeX1k+A5ra0c=" + }, + { + "mvn-path": "clj-tuple/clj-tuple/0.2.2/clj-tuple-0.2.2.pom", + "mvn-repo": "https://repo.clojars.org/", + "hash": "sha256-ahZELYfCkwwDImtKo9KYkVfVi5TtPnyNZ2aLDrZYOJs=" + }, + { + "mvn-path": "com/fasterxml/jackson/jackson-bom/2.15.2/jackson-bom-2.15.2.pom", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-Hq1jAlXEiMUbXgq1YMdsI3GtJq422t8JKcUmVy6ls4s=" + }, + { + "mvn-path": "com/fasterxml/jackson/jackson-parent/2.15/jackson-parent-2.15.pom", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-bN+XvGbzifY+NoUNL1UtEhZoj45aWHJ9P2qY7fhnXN4=" + }, + { + "mvn-path": "com/fasterxml/oss-parent/50/oss-parent-50.pom", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-9dpV3XuI+xcMRoAdF3dKZS+y9FgftbHQpfyGqhgrhXc=" + }, + { + "mvn-path": "commons-codec/commons-codec/1.15/commons-codec-1.15.jar", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-s+n21jp5AQm/DQVmEfvtHPaQVYJt7+uYlKcTadJG7WM=" + }, + { + "mvn-path": "commons-codec/commons-codec/1.15/commons-codec-1.15.pom", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-yG7hmKNaNxVIeGD0Gcv2Qufk2ehxR3eUfb5qTjogq1g=" + }, + { + "mvn-path": "commons-io/commons-io/2.14.0/commons-io-2.14.0.jar", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-410d9yMlaO1Lgdmp7ZSgFZs/9s8ZFcwh7vXLVdexV6I=" + }, + { + "mvn-path": "commons-io/commons-io/2.14.0/commons-io-2.14.0.pom", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-NNQLWPioZXQgDwisi40dChqnTHLBx/bYmPi4t27afYs=" + }, + { + "mvn-path": "commons-io/commons-io/2.8.0/commons-io-2.8.0.pom", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-18hkGjfW5282+56B/BQg4moJ1j+jLwD3R2TeBnyoNH0=" + }, + { + "mvn-path": "commons-logging/commons-logging/1.2/commons-logging-1.2.jar", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-2t3qHqC+D1aXirMAa4rJKDSv7vvZt+TmMW/KV98PpjY=" + }, + { + "mvn-path": "commons-logging/commons-logging/1.2/commons-logging-1.2.pom", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-yRq1qlcNhvb9B8wVjsa8LFAIBAKXLukXn+JBAHOfuyA=" + }, + { + "mvn-path": "io/netty/netty-bom/4.1.100.Final/netty-bom-4.1.100.Final.pom", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-BGTXWdI8THPwRzcGNzPmg/s9FG/0OUGsHdRffnBk3yU=" + }, + { + "mvn-path": "org/apache/apache/13/apache-13.pom", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-/1E9sDYf1BI3vvR4SWi8FarkeNTsCpSW+BEHLMrzhB0=" + }, + { + "mvn-path": "org/apache/apache/18/apache-18.pom", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-eDEwcoX9R1u8NrIK4454gvEcMVOx1ZMPhS1E7ajzPBc=" + }, + { + "mvn-path": "org/apache/apache/21/apache-21.pom", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-rxDBCNoBTxfK+se1KytLWjocGCZfoq+XoyXZFDU3s4A=" + }, + { + "mvn-path": "org/apache/apache/23/apache-23.pom", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-vBBiTgYj82V3+sVjnKKTbTJA7RUvttjVM6tNJwVDSRw=" + }, + { + "mvn-path": "org/apache/apache/27/apache-27.pom", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-srD8aeIqZQw4kvHDZtdwdvKVdcZzjfTHpwpEhESEzfk=" + }, + { + "mvn-path": "org/apache/apache/30/apache-30.pom", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-Y91KOTqcDfyzFO/oOHGkHSQ7yNIAy8fy0ZfzDaeCOdg=" + }, + { + "mvn-path": "org/apache/commons/commons-parent/34/commons-parent-34.pom", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-Oi5p0G1kHR87KTEm3J4uTqZWO/jDbIfgq2+kKS0Et5w=" + }, + { + "mvn-path": "org/apache/commons/commons-parent/52/commons-parent-52.pom", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-ddvo806Y5MP/QtquSi+etMvNO18QR9VEYKzpBtu0UC4=" + }, + { + "mvn-path": "org/apache/commons/commons-parent/62/commons-parent-62.pom", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-dM1i1osJqtf7lCTqiCaat2q6DWUIjZVp/yc70gdCdDk=" + }, + { + "mvn-path": "org/apache/cxf/cxf-bom/3.5.6/cxf-bom-3.5.6.pom", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-EI/F+5FdF3VzqwWV7CAxrl6PT34cxdNzvTPBLEzaFP8=" + }, + { + "mvn-path": "org/apache/cxf/cxf/3.5.6/cxf-3.5.6.pom", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-BYc/nu4eAMnZLNw6j7Rez/fqkXOXyv3eVESyTQ1XMHE=" + }, + { + "mvn-path": "org/apache/httpcomponents/httpasyncclient/4.1.4/httpasyncclient-4.1.4.jar", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-UOmBqOVnoW69rRBGBbFWVAqGNFn6EnuLpkfzEN/IPvg=" + }, + { + "mvn-path": "org/apache/httpcomponents/httpasyncclient/4.1.4/httpasyncclient-4.1.4.pom", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-NPJO+Ya4nVG4CgkDh6o9DIJNQPCHrlzPrUf/PCYsLkc=" + }, + { + "mvn-path": "org/apache/httpcomponents/httpclient-cache/4.5.13/httpclient-cache-4.5.13.jar", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-Zs797nR1mFJWr2gL86581dfULo/euTmmJ3ki4b3u1Do=" + }, + { + "mvn-path": "org/apache/httpcomponents/httpclient-cache/4.5.13/httpclient-cache-4.5.13.pom", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-o1h75UcWw7gKMonBHfhlqWK8cr5HiRReQgxpSL9FpKQ=" + }, + { + "mvn-path": "org/apache/httpcomponents/httpclient/4.5.13/httpclient-4.5.13.jar", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-b+kCalZsalABYIzz/DIZZkH2weXhmG0QN8zb1fMe90M=" + }, + { + "mvn-path": "org/apache/httpcomponents/httpclient/4.5.13/httpclient-4.5.13.pom", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-eOua2nSSn81j0HrcT0kjaEGkXMKdX4F79FgB9RP9fmw=" + }, + { + "mvn-path": "org/apache/httpcomponents/httpcomponents-asyncclient/4.1.4/httpcomponents-asyncclient-4.1.4.pom", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-6WXrNprx2LWmi31LeGHVOlJhaugD4TFi6N+EImFwAYA=" + }, + { + "mvn-path": "org/apache/httpcomponents/httpcomponents-client/4.5.13/httpcomponents-client-4.5.13.pom", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-nLpZTAjbcnHQwg6YRdYiuznmlYORC0Xn1d+C9gWNTdk=" + }, + { + "mvn-path": "org/apache/httpcomponents/httpcomponents-core/4.4.10/httpcomponents-core-4.4.10.pom", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-YelCfUvjJsMHp/FrqCjRyzsUcTybBPyLqZKljzdsMTY=" + }, + { + "mvn-path": "org/apache/httpcomponents/httpcomponents-core/4.4.14/httpcomponents-core-4.4.14.pom", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-IJ7ZMctXmYJS3+AnyqnAOtpiBhNkIylnkTEWX4scutE=" + }, + { + "mvn-path": "org/apache/httpcomponents/httpcomponents-parent/10/httpcomponents-parent-10.pom", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-yq+WfZSvshdT82CCxghiBr0fSIJf9ZaTLM66crZdOfo=" + }, + { + "mvn-path": "org/apache/httpcomponents/httpcomponents-parent/11/httpcomponents-parent-11.pom", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-qQH4exFcVQcMfuQ+//Y+IOewLTCvJEOuKSvx9OUy06o=" + }, + { + "mvn-path": "org/apache/httpcomponents/httpcore-nio/4.4.10/httpcore-nio-4.4.10.jar", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-3r7n6VcsAqFs4Mqk9WWp7OsSkNM816HjKXCHvUZ9r/Q=" + }, + { + "mvn-path": "org/apache/httpcomponents/httpcore-nio/4.4.10/httpcore-nio-4.4.10.pom", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-pMmVtzjRBLdcyLEWTbYAUzFWwEfsy0yO5dknshoX7HM=" + }, + { + "mvn-path": "org/apache/httpcomponents/httpcore/4.4.14/httpcore-4.4.14.jar", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-+VYgnkUMsdDFF3bfvSPlPp3Y25oSmO1itwvwlEumOyg=" + }, + { + "mvn-path": "org/apache/httpcomponents/httpcore/4.4.14/httpcore-4.4.14.pom", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-VXFjmKl48QID+eJciu/AWA2vfwkHxu0K6tgexftrf9g=" + }, + { + "mvn-path": "org/apache/httpcomponents/httpmime/4.5.13/httpmime-4.5.13.jar", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-BudU2ZJFuY3MKGDctD0g5zfWUNor8gd6EF9orMvVxcw=" + }, + { + "mvn-path": "org/apache/httpcomponents/httpmime/4.5.13/httpmime-4.5.13.pom", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-k0GN8hCu7VBQJUjbzysXwPHZFEMDDnL+++7RZSscKN0=" + }, + { + "mvn-path": "org/apache/httpcomponents/project/7/project-7.pom", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-PW66QoVVpVjeBGtddurMH1pUtPXyC4TWNu16/xiqSMM=" + }, + { + "mvn-path": "org/apache/logging/log4j/log4j-bom/2.20.0/log4j-bom-2.20.0.pom", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-+LtpLpWmt72mAehxAJWOg9AGG38SMlC2gSiUOhlenaE=" + }, + { + "mvn-path": "org/apache/logging/logging-parent/7/logging-parent-7.pom", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-5YkR3J/GsXOhDlqp7bk8eZStBmAnBd0Gftz8bh6eFys=" + }, + { + "mvn-path": "org/apache/tika/tika-core/2.9.1/tika-core-2.9.1.jar", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-HFJBmR2dzc10/qCidgDzHoUkpExho2DlFWSFA2f5ZGI=" + }, + { + "mvn-path": "org/apache/tika/tika-core/2.9.1/tika-core-2.9.1.pom", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-X4SU13sJWynaD/NkKZ9tx035p40hhhrpaiTaP9FRrkg=" + }, + { + "mvn-path": "org/apache/tika/tika-parent/2.9.1/tika-parent-2.9.1.pom", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-t2CHBtgoDgAjaNC2dvvN3qVPMxLpQLDyrSAzZ+Wwejk=" + }, + { + "mvn-path": "org/clojure/clojure/1.10.3/clojure-1.10.3.jar", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-fxJHLa7Y9rUXSYqqKrE6ViR1w+31FHjkWBzHYemJeaM=" + }, + { + "mvn-path": "org/clojure/clojure/1.10.3/clojure-1.10.3.pom", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-GJwAxDNAdJai+7DsyzeQjJSVXZHq0b5IFWdE7MGBbZQ=" + }, + { + "mvn-path": "org/clojure/clojure/1.11.0/clojure-1.11.0.jar", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-PiH6daB+yd278bK1A1bPGAcQ0DmN6qT0TpHNYwRVWUc=" + }, + { + "mvn-path": "org/clojure/clojure/1.11.0/clojure-1.11.0.pom", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-SQjMS0yeYsmoFJb5PLWsb2lBd8xkXc87jOXkkavOHro=" + }, + { + "mvn-path": "org/clojure/clojure/1.11.1/clojure-1.11.1.jar", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-I4G26UI6tGUVFFWUSQPROlYkPWAGuRlK/Bv0+HEMtN4=" + }, + { + "mvn-path": "org/clojure/clojure/1.11.1/clojure-1.11.1.pom", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-IMRaGr7b2L4grvk2BQrjGgjBZ0CzL4dAuIOM3pb/y4o=" + }, + { + "mvn-path": "org/clojure/core.specs.alpha/0.2.56/core.specs.alpha-0.2.56.jar", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-/PRCveArBKhj8vzFjuaiowxM8Mlw99q4VjTwq3ERZrY=" + }, + { + "mvn-path": "org/clojure/core.specs.alpha/0.2.56/core.specs.alpha-0.2.56.pom", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-AarxdIP/HHSCySoHKV1+e8bjszIt9EsptXONAg/wB0A=" + }, + { + "mvn-path": "org/clojure/core.specs.alpha/0.2.62/core.specs.alpha-0.2.62.jar", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-Bu6owHC75FwVhWfkQ0OWgbyMRukSNBT4G/oyukLWy8g=" + }, + { + "mvn-path": "org/clojure/core.specs.alpha/0.2.62/core.specs.alpha-0.2.62.pom", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-F3i70Ti9GFkLgFS+nZGdG+toCfhbduXGKFtn1Ad9MA4=" + }, + { + "mvn-path": "org/clojure/data.json/2.5.0/data.json-2.5.0.jar", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-Z3nDbuH5DXDzX+uHL7MXVqoOG4vWxl4QXngLq7SyVwQ=" + }, + { + "mvn-path": "org/clojure/data.json/2.5.0/data.json-2.5.0.pom", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-BPCy1pKdF8IvmGslALqAVYVYDeE7gGkke4JUYKhwQf4=" + }, + { + "mvn-path": "org/clojure/pom.contrib/0.3.0/pom.contrib-0.3.0.pom", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-fxgrOypUPgV0YL+T/8XpzvasUn3xoTdqfZki6+ee8Rk=" + }, + { + "mvn-path": "org/clojure/pom.contrib/1.1.0/pom.contrib-1.1.0.pom", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-EOzku1+YKQENwWVh9C67g7ry9HYFtR+RBbkvPKoIlxU=" + }, + { + "mvn-path": "org/clojure/spec.alpha/0.2.194/spec.alpha-0.2.194.jar", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-z2iZ+YUpjGSxPqEplGrZAo3uja3w6rmuGORVAn04JJw=" + }, + { + "mvn-path": "org/clojure/spec.alpha/0.2.194/spec.alpha-0.2.194.pom", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-WhHw4eizwFLmUcSYxpRbRNs1Nb8sGHGf3PZd8fiLE+Y=" + }, + { + "mvn-path": "org/clojure/spec.alpha/0.3.218/spec.alpha-0.3.218.jar", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-Z+yJjrVcZqlXpVJ53YXRN2u5lL2HZosrDeHrO5foquA=" + }, + { + "mvn-path": "org/clojure/spec.alpha/0.3.218/spec.alpha-0.3.218.pom", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-bY3hTDrIdXYMX/kJVi/5hzB3AxxquTnxyxOeFp/pB1g=" + }, + { + "mvn-path": "org/eclipse/jetty/jetty-bom/9.4.53.v20231009/jetty-bom-9.4.53.v20231009.pom", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-+vlzoZh0JmzQhlsCmeup8WfLsHB13U/tvj1hVjV+ndU=" + }, + { + "mvn-path": "org/junit/junit-bom/5.10.0/junit-bom-5.10.0.pom", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-4AbdiJT5/Ht1/DK7Ev5e2L5lZn1bRU+Z4uC4xbuNMLM=" + }, + { + "mvn-path": "org/slf4j/slf4j-api/2.0.9/slf4j-api-2.0.9.jar", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-CBiTDcjX3rtAMgRhFpHaWOSdQsULb/z9zgLa23w8K2w=" + }, + { + "mvn-path": "org/slf4j/slf4j-api/2.0.9/slf4j-api-2.0.9.pom", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-nDplT50KoaNLMXjr5TqJx2eS4dgfwelznL6bFhBSM4U=" + }, + { + "mvn-path": "org/slf4j/slf4j-bom/2.0.9/slf4j-bom-2.0.9.pom", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-6u9FhIB9gSxqC2z4OdXkf1DHVDJ3GbnOCB4nHRXaYkM=" + }, + { + "mvn-path": "org/slf4j/slf4j-parent/2.0.9/slf4j-parent-2.0.9.pom", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-wwfwQkFB8cUArlzw04aOSGbLIZ7V45m2bFoHxh6iH9U=" + }, + { + "mvn-path": "org/sonatype/oss/oss-parent/7/oss-parent-7.pom", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-tR+IZ8kranIkmVV/w6H96ne9+e9XRyL+kM5DailVlFQ=" + }, + { + "mvn-path": "org/testcontainers/testcontainers-bom/1.19.1/testcontainers-bom-1.19.1.pom", + "mvn-repo": "https://repo1.maven.org/maven2/", + "hash": "sha256-LEQmp23yZw7pZX3CUXI8wv/P15xiE9kADQhdkoP+YSU=" + }, + { + "mvn-path": "potemkin/potemkin/0.4.5/potemkin-0.4.5.jar", + "mvn-repo": "https://repo.clojars.org/", + "hash": "sha256-KzZsg02Hy26mMbpoaXvDdNDRr4H23rQsKECUTaMgvZk=" + }, + { + "mvn-path": "potemkin/potemkin/0.4.5/potemkin-0.4.5.pom", + "mvn-repo": "https://repo.clojars.org/", + "hash": "sha256-3tL5YlDzDlqPmI60YeMvKzDzbBy0Qz+6qHu82kJRTDo=" + }, + { + "mvn-path": "riddley/riddley/0.1.12/riddley-0.1.12.jar", + "mvn-repo": "https://repo.clojars.org/", + "hash": "sha256-OY9h+kgluPhskWrlgMfhM7fEd9C3Kn07KY04EDJ0C64=" + }, + { + "mvn-path": "riddley/riddley/0.1.12/riddley-0.1.12.pom", + "mvn-repo": "https://repo.clojars.org/", + "hash": "sha256-At+3ryDvgcJTZQVfYCjoscwpBdCyaLuJzEKM2nIwo2U=" + }, + { + "mvn-path": "slingshot/slingshot/0.12.2/slingshot-0.12.2.jar", + "mvn-repo": "https://repo.clojars.org/", + "hash": "sha256-porCK/LqPNVM4023D9aYRNYx71SfZFDCeMMOb3nfY/M=" + }, + { + "mvn-path": "slingshot/slingshot/0.12.2/slingshot-0.12.2.pom", + "mvn-repo": "https://repo.clojars.org/", + "hash": "sha256-SrxOK5ppxzvTc+gy0/AOWQZ4Q/+DUe/V7rsfOCTbnFE=" + } + ] +} diff --git a/deps.edn b/deps.edn new file mode 100644 index 0000000..f039771 --- /dev/null +++ b/deps.edn @@ -0,0 +1,9 @@ +{ + :paths ["src"] + :deps { + clj-http/clj-http { :mvn/version "3.12.3" } + org.clojure/data.json { :mvn/version "2.5.0" } + camel-snake-kebab/camel-snake-kebab {:mvn/version "0.4.3"} + org.apache.tika/tika-core { :mvn/version "2.9.1" } + } + } diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..d867f84 --- /dev/null +++ b/flake.lock @@ -0,0 +1,230 @@ +{ + "nodes": { + "clj-nix": { + "inputs": { + "devshell": "devshell", + "flake-utils": "flake-utils", + "nixpkgs": [ + "helpers", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1677342613, + "narHash": "sha256-BqhKj7jQahSVThEwLHt164kJHGx9LXzBARFZaFNLPW8=", + "owner": "jlesquembre", + "repo": "clj-nix", + "rev": "7d9e244ea96988524ba3bd6c2bbafdf0a5340b96", + "type": "github" + }, + "original": { + "owner": "jlesquembre", + "repo": "clj-nix", + "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": { + "inputs": { + "flake-utils": [ + "helpers", + "clj-nix", + "flake-utils" + ], + "nixpkgs": [ + "helpers", + "clj-nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1658746384, + "narHash": "sha256-CCJcoMOcXyZFrV1ag4XMTpAPjLWb4Anbv+ktXFI1ry0=", + "owner": "numtide", + "repo": "devshell", + "rev": "0ffc7937bb5e8141af03d462b468bd071eb18e1b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1668681692, + "narHash": "sha256-Ht91NGdewz8IQLtWZ9LCeNXMSXHUss+9COoqu6JLmXU=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "009399224d5e398d03b22badca40a37ac85412a1", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1656928814, + "narHash": "sha256-RIFfgBuKz6Hp89yRr7+NR5tzIAbn52h8vT6vXkYjZoM=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "7e2a3b3dfd9af950a856d66b0a7d01e3c18aa249", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "helpers": { + "inputs": { + "clj-nix": "clj-nix", + "clj2nix": "clj2nix", + "nixpkgs": [ + "nixpkgs" + ], + "utils": "utils_2" + }, + "locked": { + "lastModified": 1683740681, + "narHash": "sha256-KmOssuvCVsOiSspVzpqW/OdPWMCbRieUUACDQcPs7cI=", + "ref": "refs/heads/master", + "rev": "7930d2d726a4e434d27022ca84ae25cdc833cd72", + "revCount": 33, + "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": { + "locked": { + "lastModified": 1673785507, + "narHash": "sha256-EPUT8yVdvJhhjhbgnFWXXd4IUPKSOmww2+z4AmOdyPI=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "d06d765eeac716d8f1ca80f0935fd6fc951816ad", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1708294118, + "narHash": "sha256-evZzmLW7qoHXf76VCepvun1esZDxHfVRFUJtumD7L2M=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "e0da498ad77ac8909a980f07eff060862417ccf7", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-23.11", + "type": "indirect" + } + }, + "root": { + "inputs": { + "helpers": "helpers", + "nixpkgs": "nixpkgs_2", + "utils": "utils_3" + } + }, + "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": { + "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": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1705309234, + "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..4eea22e --- /dev/null +++ b/flake.nix @@ -0,0 +1,34 @@ +{ + description = "MeBot Matrix chatbot Clojure library."; + + inputs = { + nixpkgs.url = "nixpkgs/nixos-23.11"; + utils.url = "github:numtide/flake-utils"; + helpers = { + url = "git+https://git.fudo.org/fudo-public/nix-helpers.git"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = { self, nixpkgs, utils, helpers, ... }: + utils.lib.eachDefaultSystem (system: + let pkgs = nixpkgs.legacyPackages."${system}"; + in { + packages = rec { + default = mebot; + mebot = helpers.packages."${system}".mkClojureLib { + name = "org.fudo/mebot"; + primaryNamespace = "mebot.core"; + src = ./.; + }; + }; + + devShells = rec { + default = updateDeps; + updateDeps = pkgs.mkShell { + buildInputs = with helpers.packages."${system}"; + [ updateClojureDeps ]; + }; + }; + }); +} diff --git a/src/mebot/client.clj b/src/mebot/client.clj new file mode 100644 index 0000000..7b0bb9d --- /dev/null +++ b/src/mebot/client.clj @@ -0,0 +1,228 @@ +(ns mebot.client + (:require [clojure.data.json :as json] + [clj-http.client :as http] + [clojure.pprint :refer [pprint]] + [clojure.string :as str] + [clojure.java.io :as io] + [camel-snake-kebab.core :refer [->kebab-case]]) + (:import java.net.InetAddress + java.net.URLEncoder + java.net.URI + java.util.UUID + org.apache.tika.Tika)) + +(defn pthru [o] (pprint o) o) + +(defmulti decode-body :content-type) +(defmethod decode-body :json [res] + (-> res :body (json/read-str :key-fn keyword))) +(defmethod decode-body :default [res] res) + +(defmulti encode-body :content-type) +(defmethod encode-body :json [req] + (update req :body json/write-str)) +(defmethod encode-body :default [req] req) + +(defmulti exec-request! :method) +(defmethod exec-request! :get + [& {:keys [url accept] :as opts}] + (-> (pthru url) + (http/get opts) + (assoc :content-type accept) + (decode-body))) +(defmethod exec-request! :post + [& {:keys [url accept] :as opts}] + (-> (pthru url) + (http/post (encode-body opts)) + (assoc :content-type accept) + (decode-body))) +(defmethod exec-request! :put + [& {:keys [url accept] :as opts}] + (-> (pthru url) + (http/put (encode-body opts)) + (assoc :content-type accept) + (decode-body))) +(defmethod exec-request! :default + [& {:keys [method]}] + (throw (RuntimeException. (str "Bad method: " method)))) + +(defn- put-bytes! + ([url] (put-bytes! url {})) + ([url opts] (-> url + (http/put (-> opts + (update :accept (fn [_] :json)) + (update :content-type (fn [_] :json)))) + :body + (json/read-str :key-fn keyword)))) + +(defn- put-multipart! + ([url] (put-multipart! url {})) + ([url opts] (-> url + (http/put (-> opts + (update :accept (fn [_] :json)))) + :body + (json/read-str :key-fn keyword)))) + +(defn- matrix-url + [base components & {:keys [api version] + :or {api "client" version 3}}] + (letfn [(to-component [c] (URLEncoder/encode (name c) "utf-8"))] + (str base "/_matrix/" api "/v" version "/" + (str/join "/" (map to-component components))))) + +(defn- get-wellknown-url! [domain] + (-> + (exec-request! {:url (str "https://" domain "/.well-known/matrix/client") + :method :get + :accept :json}) + :m.homeserver + :base_url)) + +(defn get-jwt-token! [& {:keys [provider-url client-id username password]}] + (-> (exec-request! {:url provider-url + :method :post + :accept :json + :form-params {:grant_type "client_credentials" + :client_id client-id + :username username + :password password}}) + :access_token)) + +;; +;; Mebot Client +;; + +(defn- normalize-keys [m] + (into {} (map (fn [[k v]] [(->kebab-case k) v])) m)) + +(defn make-client! [domain] + {:base-url (get-wellknown-url! domain)}) + +(defn request-access! [client jwt-token] + (let [hostname (.getCanonicalHostName (InetAddress/getLocalHost))] + (-> (exec-request! {:url (matrix-url (:base-url client) [:login]) + :method :post + :accept :json + :content-type :json + :body {:type "org.matrix.login.jwt" + :token jwt-token + :initial_device_display_name hostname}}) + (normalize-keys) + (merge client)))) + +(defn- set-default [default] (fn [val] (if val val default))) + +(defmacro ->* [& fns] + (let [v (gensym)] + `(fn [~v] (-> ~v ~@fns)))) + +(defn get! + ([client path] (get! client path {})) + ([{:keys [base-url access-token]} path + {{:keys [api version] :or {api "client" version 3}} :api :as opts}] + (exec-request! (-> opts + (dissoc :api) + (assoc :url (matrix-url base-url path :api api :version version) + :method :get) + (update :accept (set-default :json)) + (update :headers (->* (assoc :authorization (str "Bearer " access-token)))))))) + +(defn post! + ([client path] (post! client path {})) + ([{:keys [base-url access-token]} path + {{:keys [api version] :or {api "client" version 3}} :api :as opts}] + (exec-request! (-> opts + (assoc :url (matrix-url base-url path :api api :version version) + :method :post) + (update :accept (set-default :json)) + (update :headers (->* (assoc :authorization (str "Bearer " access-token)))))))) + +(defn put! + ([client path] (put! client path {})) + ([{:keys [base-url access-token]} path + {{:keys [api version] :or {api "client" version 3}} :api :as opts}] + (exec-request! (-> opts + (assoc :url (matrix-url base-url path :api api :version version) + :method :put) + (update :accept (set-default :json)) + (update :headers (->* (assoc :authorization (str "Bearer " access-token)))))))) + +(defn get-room-info! [client room-alias] + (get! client [:directory :room room-alias])) + +(defn list-public-rooms! [client] + (get! client [:publicRooms])) + +(defn- assoc-if-present [m k v] + (if v (assoc m k v) m)) + +(defn create-private-room! [client & {:keys [name alias topic invitees] + :or {invitees []}}] + (post! client [:createRoom] + {:content-type :json + :body (-> {:preset "private_chat"} + (assoc-if-present :name name) + (assoc-if-present :alias alias) + (assoc-if-present :topic topic) + (assoc :invite invitees))})) + +(defn get-room-members! [client room-id] + (get! client [:rooms room-id :members])) + +(defn is-message? [msg] + (-> msg :type (= "m.room.message"))) + +(defn mentions? [user msg] + (letfn [(matches-user? [u] (= u user))] + (some->> msg :content :m.mentions :user_ids (some matches-user?)))) + +(defn get-room-events! [client room-id] + (get! client [:rooms room-id :messages] + {:query-params {:dir "b"}})) + +(defn get-room-messages! [client room-id] + (->> (get-room-events! client room-id) + :chunk + (filter is-message?))) + +(defn get-room-mentions! [client room-id user] + (filter (partial mentions? user) + (get-room-messages! client room-id))) + +(defn send-message! [client room-id msg] + (let [txn-id (str (UUID/randomUUID))] + (put! client [:rooms room-id :send "m.room.message" txn-id] + {:content-type :json + :accept :json + :body {:msgtype "m.text" + :body msg}}))) + +(defn invite-user! [client room-id user-id] + (post! client [:rooms room-id :invite] + {:body {:user_id user-id} + :accept :json + :content-type :json})) + +(defn- detect-mime-type [is] + (let [tika (Tika.)] + (.detect tika is))) + +(defn send-image! [client room-id img-data filename] + (let [media-uri (-> (post! client [:create] + {:api {:api "media" :version 1}}) + :content_uri + (URI.)) + media-id (-> media-uri (.getPath) (io/file) (.getName)) + server-name (-> media-uri (.getHost))] + (put! client [:upload server-name media-id] + {:headers {:content-type (detect-mime-type img-data)} + :query-params {:filename filename} + :api {:api "media" :version 3} + :body img-data}) + (let [txn-id (str (UUID/randomUUID))] + (put! client [:rooms room-id :send "m.room.message" txn-id] + {:body {:msgtype "m.image" + :body filename + :url (str media-uri)} + :accept :json + :content-type :json})))) diff --git a/src/mebot/core.clj b/src/mebot/core.clj new file mode 100644 index 0000000..0b40457 --- /dev/null +++ b/src/mebot/core.clj @@ -0,0 +1 @@ +(ns mebot.core)