Compare commits

...

2 Commits

Author SHA1 Message Date
1fbd7258fe Start CLI development
Some checks failed
Compile and test using leiningen / Run tests (push) Has been cancelled
2026-01-14 00:38:07 +01:00
5fe64ac55c Date and duration formatting 2026-01-14 00:37:46 +01:00
5 changed files with 96 additions and 12 deletions

View File

@@ -1,8 +1,11 @@
{:paths ["src" "resources" "target/classes"] {:paths ["src" "resources" "target/classes"]
:deps {org.clojure/clojure {:mvn/version "1.12.1"} :deps {org.clojure/clojure {:mvn/version "1.12.1"}
cli-matic/cli-matic {:mvn/version "0.5.4"} ;; https://github.com/l3nz/cli-matic ;; https://github.com/lambdaisland/cli
} com.lambdaisland/cli {:mvn/version "1.27.121"}
;; https://github.com/tokenmill/timewords
lt.tokenmill/timewords {:mvn/version "0.5.0"}
}
:aliases {;; Execute the app :aliases {;; Execute the app
;:run {:main-opts ["-m" "totp.app"]} ;:run {:main-opts ["-m" "totp.app"]}
}} }}

View File

@@ -1,9 +1,28 @@
(ns riot.app (ns riot.app
#_{:clj-kondo/ignore [:refer-all]} #_{:clj-kondo/ignore [:refer-all]}
(:require [riot.core :refer :all]) (:require [riot.core :refer :all]
[riot.data :refer :all]
[lambdaisland.cli :as cli]
[clojure.pprint :as pp]
[clojure.string :as s])
(:gen-class)) (:gen-class))
(def cli-options {}) (defn test-fn
[opts]
(println "Options:")
(pp/pprint opts)
(println "Positional args:" (s/join "," (:lambdaisland.cli/argv opts))))
(defn -main [& args] (defn -main [& args]
(greeting-emisor (generate-greeting :high "Juan"))) (cli/dispatch
{:name "cli-test"
:command #'test-fn ; The function to call
:flags ["-v, --verbose" "Increases verbosity"
"--input FILE" "Specify the input file"]}
args))
(comment
(-main "-v" "--input" "boniato.txt" "position1" "pos2")
)

View File

@@ -3,7 +3,10 @@
;; https://github.com/babashka/http-client ;; https://github.com/babashka/http-client
org.babashka/http-client {:mvn/version "0.4.22"} org.babashka/http-client {:mvn/version "0.4.22"}
;; https://github.com/dakrone/cheshire?tab=readme-ov-file ;; https://github.com/dakrone/cheshire?tab=readme-ov-file
cheshire/cheshire {:mvn/version "6.1.0"}} cheshire/cheshire {:mvn/version "6.1.0"}
;; https://juxt.github.io/tick/
tick/tick {:mvn/version "1.0"}
}
:aliases {;; Kaocha runner. You can use the 'kaocha' wrapper located in ~/bin/kaocha :aliases {;; Kaocha runner. You can use the 'kaocha' wrapper located in ~/bin/kaocha
:test {:extra-paths ["test"] :test {:extra-paths ["test"]

View File

@@ -1,6 +1,8 @@
(ns riot.data (ns riot.data
(:require [riot.core :refer :all] (:require [riot.core :refer :all]
[riot.riot-api :refer :all])) [riot.riot-api :refer :all]
[clojure.string :as s]
[tick.core :as t]))
;; ;;
;; High functions to work with RIOT API. ;; High functions to work with RIOT API.
@@ -43,6 +45,7 @@
(get-tft-matches (tft-get-uuid "Errepunto" "4595") :count 5) (get-tft-matches (tft-get-uuid "Errepunto" "4595") :count 5)
) )
;; Get matches data ;; Get matches data
(defn create-match-data (defn create-match-data
@@ -111,11 +114,14 @@
(get-lol-match-data "EUW1_7673677826") (get-lol-match-data "EUW1_7673677826")
(get-tft-match-data "EUW1_7674912532") (get-tft-match-data "EUW1_7674912532")
(call-riot-api :tft-match-by-id :path-params {:match-id "EUW1_7674912532"})
(System/currentTimeMillis) (System/currentTimeMillis)
1767819383643 1767819383643
1767819383643 1767819383643
) )
;; Check if it's playing ;; Check if it's playing
(defn is-playing-lol? (defn is-playing-lol?
@@ -135,4 +141,58 @@
(comment (comment
(is-playing-lol? (lol-get-uuid "Walid Georgey" "EUW")) (is-playing-lol? (lol-get-uuid "Walid Georgey" "EUW"))
(is-playing-tft? (lol-get-uuid "Walid Georgey" "EUW")) (is-playing-tft? (lol-get-uuid "Walid Georgey" "EUW"))
) )
;; Format dates and times
(defn format-millis
([millis]
(format-millis "yyyy-MM-dd HH:mm:ss" millis))
([format millis]
(t/format (t/formatter format)
(t/zoned-date-time (t/instant millis)))))
(defn match-format-dates
([data]
(match-format-dates "yyyy-MM-dd HH:mm:ss" data))
([date-format data]
(-> data
(update-in [:start] (partial format-millis date-format))
(update-in [:end] (partial format-millis date-format)))))
(comment
(t/format (t/formatter "yyyy-MM-dd HH:mm:ss")
(t/zoned-date-time (t/instant (System/currentTimeMillis))))
(match-format-dates (get-lol-match-data "EUW1_7673677826"))
(match-format-dates (get-tft-match-data "EUW1_7674912532"))
)
(defn format-duration
[seconds]
(let [duration (t/new-duration seconds :seconds)
minutes (t/minutes duration)
seconds (- (t/seconds duration) (* 60 minutes))]
(format "%02d:%02d" minutes seconds)))
(defn match-format-durations
[data]
(update-in data [:duration] format-duration))
(comment
(t/format (t/formatter "HH:mm:ss") (t/new-duration 2106 :seconds))
(t/hours (t/new-duration 2106 :seconds))
(t/minutes (t/new-duration 2106 :seconds))
(t/seconds (t/new-duration 2106 :seconds))
(format-duration 2106)
(match-format-durations (get-lol-match-data "EUW1_7673677826"))
(match-format-durations (get-tft-match-data "EUW1_7674912532"))
)
;;

View File

@@ -58,8 +58,7 @@
(comment (comment
(set-riot-api-key :RIOT_DEV_KEY "RGAPI-a8d1f915-859b-4bad-99d8-0a163e349f77") (set-riot-api-key :RIOT_DEV_KEY "RGAPI-c5f2c1da-8b8a-4e2b-861b-5d3f671173be")
(lol-get-uuid "Walid Georgey" "EUW") (lol-get-uuid "Walid Georgey" "EUW")