repl now works

master
jem 4 years ago
parent f5fcc142ae
commit 0ae68af441

4
.gitignore vendored

@ -1,5 +1,5 @@
.shadow-cljs
config.edn config.edn
package-lock.json package-lock.json
/.shadow-cljs
/node_modules /node_modules
target/mastodon-bot.js /target

@ -27,6 +27,7 @@ If you get a [permission failure](https://github.com/anmonteiro/lumo/issues/206)
with later timestamps to avoid duplicate posts. On the first run the timestamp will default to current time. with later timestamps to avoid duplicate posts. On the first run the timestamp will default to current time.
```clojure ```clojure
#:mastodon-bot.core
{;; add Twitter config to mirror Twitter accounts {;; add Twitter config to mirror Twitter accounts
:twitter {:access-keys :twitter {:access-keys
{:consumer_key "XXXX" {:consumer_key "XXXX"
@ -51,7 +52,9 @@ with later timestamps to avoid duplicate posts. On the first run the timestamp w
;; add RSS config to follow feeds ;; add RSS config to follow feeds
:rss {"Hacker News" "https://hnrss.org/newest" :rss {"Hacker News" "https://hnrss.org/newest"
"r/Clojure" "https://www.reddit.com/r/clojure/.rss"} "r/Clojure" "https://www.reddit.com/r/clojure/.rss"}
:mastodon {:access_token "XXXX" :mastodon
#:mastodon-bot.mastodon-api
{:access_token "XXXX"
;; account number you see when you log in and go to your profile ;; account number you see when you log in and go to your profile
;; e.g: https://mastodon.social/web/accounts/294795 ;; e.g: https://mastodon.social/web/accounts/294795
:account-id "XXXX" :account-id "XXXX"

@ -1,11 +1,11 @@
{:source-paths ["src/main" {:source-paths ["src/main"
"src/test"] "src/test"]
:dependencies [[orchestra "2018.12.06-2"]] :dependencies [[orchestra "2018.12.06-2"]]
:builds {:dev {:target :node-script :builds {:dev {:target :node-library
:repl-init-ns mastodon-bot.core :output-to "target/lib-mastodon-bot.js"
:output-to "target/mastodon-bot.js" :exports {:infra mastodon-bot.infra/js->edn}
:main mastodon-bot.core/dummy :repl-pprint true
:repl-pprint true} }
:app {:target :node-script :app {:target :node-script
:output-to "target/mastodon-bot.js" :output-to "target/mastodon-bot.js"
:main mastodon-bot.core/main :main mastodon-bot.core/main

@ -15,9 +15,12 @@
[mastodon-bot.infra :as infra] [mastodon-bot.infra :as infra]
[mastodon-bot.mastodon-api :as masto])) [mastodon-bot.mastodon-api :as masto]))
(defn dummy [])
(s/def ::mastodon-config masto/mastodon-config?) (s/def ::mastodon-config masto/mastodon-config?)
(s/def ::twitter map?)
(s/def ::tumblr map?)
(s/def ::rss map?)
(def config? (s/keys :req [::mastodon-config]
:opt [::twitter ::tumblr ::rss]))
;this has to stay on top - only ns-keywords can be uses in spec ;this has to stay on top - only ns-keywords can be uses in spec
(defn-spec mastodon-config ::mastodon-config (defn-spec mastodon-config ::mastodon-config
@ -135,7 +138,7 @@
(fn [timeline] (fn [timeline]
(let [last-post-time (-> timeline first :created_at (js/Date.))] (let [last-post-time (-> timeline first :created_at (js/Date.))]
;;post from Twitter ;;post from Twitter
(when-let [twitter-config (:twitter config)] (when-let [twitter-config (::twitter config)]
(let [{:keys [access-keys accounts include-replies? include-rts?]} twitter-config (let [{:keys [access-keys accounts include-replies? include-rts?]} twitter-config
client (twitter-client access-keys)] client (twitter-client access-keys)]
(doseq [account accounts] (doseq [account accounts]

@ -28,7 +28,7 @@
(s/def ::content-filters (s/* ::content-filter)) (s/def ::content-filters (s/* ::content-filter))
(s/def ::keyword-filters (s/* ::keyword-filter)) (s/def ::keyword-filters (s/* ::keyword-filter))
(s/def ::mastodon-js-config (s/keys :req [::access_token ::a:pi_url])) (s/def ::mastodon-js-config (s/keys :req [::access_token ::api_url]))
(s/def ::mastodon-clj-config (s/keys :req [::account-id ::content-filters ::keyword-filters (s/def ::mastodon-clj-config (s/keys :req [::account-id ::content-filters ::keyword-filters
::max-post-length ::signature ::visibility ::max-post-length ::signature ::visibility
::append-screen-name? ::sensitive? ::resolve-urls? ::append-screen-name? ::sensitive? ::resolve-urls?