add starred to main post
This commit is contained in:
		
							parent
							
								
									48ceb29014
								
							
						
					
					
						commit
						15a7a0f904
					
				|  | @ -1,2 +1,21 @@ | |||
| (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)))) | ||||
|  |  | |||
|  | @ -2,6 +2,7 @@ | |||
|   (:require [dhyan.connections.shaarli :as shaarli] | ||||
|             [dhyan.connections.wallabag :as wallabag] | ||||
|             [dhyan.connections.files :as files] | ||||
|             [dhyan.connections.starred :as starred] | ||||
|             [clojure.string :as string] | ||||
|             [dhyan.connections.matrix :as matrix])) | ||||
| 
 | ||||
|  | @ -26,6 +27,10 @@ | |||
|                               "\n  available at: " (get wallabag-entry-of-the-day :url) | ||||
|                               "\n  tagged as: " (string/join ", " (get wallabag-entry-of-the-day :tags))) | ||||
|         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))) | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue