add starred to main post

This commit is contained in:
Anish Lakhwara 2022-12-21 19:36:10 +10:00
parent 48ceb29014
commit 15a7a0f904
2 changed files with 26 additions and 2 deletions

View file

@ -1,2 +1,21 @@
(ns dhyan.connections.starred (ns dhyan.connections.starred
(:require [babashka.fs])) (:require
[cheshire.core :as json]
[clojure.java.io :as io]))
(defn read-json-starred
[]
(with-open [rdr (io/reader "./data/starred.json")]
(reduce conj [] (json/parsed-seq rdr))))
(def json (atom ""))
(defn init
[]
(let [j (read-json-starred)]
(reset! json (first j))))
(defn random-stared
[]
(init)
(clojure.walk/keywordize-keys (rand-nth (deref json))))

View file

@ -2,6 +2,7 @@
(:require [dhyan.connections.shaarli :as shaarli] (:require [dhyan.connections.shaarli :as shaarli]
[dhyan.connections.wallabag :as wallabag] [dhyan.connections.wallabag :as wallabag]
[dhyan.connections.files :as files] [dhyan.connections.files :as files]
[dhyan.connections.starred :as starred]
[clojure.string :as string] [clojure.string :as string]
[dhyan.connections.matrix :as matrix])) [dhyan.connections.matrix :as matrix]))
@ -26,6 +27,10 @@
"\n available at: " (get wallabag-entry-of-the-day :url) "\n available at: " (get wallabag-entry-of-the-day :url)
"\n tagged as: " (string/join ", " (get wallabag-entry-of-the-day :tags))) "\n tagged as: " (string/join ", " (get wallabag-entry-of-the-day :tags)))
on-this-day-file (files/slurp-if-file) on-this-day-file (files/slurp-if-file)
message (string/join "\n\n" [shaarli-message wallabag-message on-this-day-file])] random-starred (starred/random-stared)
starred-message (str "Random starred article: \n"
(get random-starred :title)
(get random-starred :url))
message (string/join "\n\n" [shaarli-message wallabag-message on-this-day-file starred-message])]
(matrix/post-message message))) (matrix/post-message message)))