repl now works
This commit is contained in:
parent
f5fcc142ae
commit
0ae68af441
5 changed files with 48 additions and 42 deletions
4
.gitignore
vendored
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
|
||||||
|
|
65
README.md
65
README.md
|
@ -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,37 +52,39 @@ 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
|
||||||
;; account number you see when you log in and go to your profile
|
#:mastodon-bot.mastodon-api
|
||||||
;; e.g: https://mastodon.social/web/accounts/294795
|
{:access_token "XXXX"
|
||||||
:account-id "XXXX"
|
;; account number you see when you log in and go to your profile
|
||||||
:api_url "https://botsin.space/api/v1/"
|
;; e.g: https://mastodon.social/web/accounts/294795
|
||||||
;; optional boolean to mark content as sensitive
|
:account-id "XXXX"
|
||||||
:sensitive? true
|
:api_url "https://botsin.space/api/v1/"
|
||||||
;; optional boolean defaults to false
|
;; optional boolean to mark content as sensitive
|
||||||
;; only sources containing media will be posted when set to true
|
:sensitive? true
|
||||||
:media-only? true
|
;; optional boolean defaults to false
|
||||||
;; optional visibility flag: direct, private, unlisted, public
|
;; only sources containing media will be posted when set to true
|
||||||
;; defaults to public
|
:media-only? true
|
||||||
:visibility "unlisted"
|
;; optional visibility flag: direct, private, unlisted, public
|
||||||
;; optional limit for the post length
|
;; defaults to public
|
||||||
:max-post-length 300
|
:visibility "unlisted"
|
||||||
;; optional flag specifying wether the name of the account
|
;; optional limit for the post length
|
||||||
;; will be appended in the post, defaults to false
|
:max-post-length 300
|
||||||
:append-screen-name? false
|
;; optional flag specifying wether the name of the account
|
||||||
;; optional signature for posts
|
;; will be appended in the post, defaults to false
|
||||||
:signature "#newsbot"
|
:append-screen-name? false
|
||||||
;; optionally try to resolve URLs in posts to skip URL shorteners
|
;; optional signature for posts
|
||||||
;; defaults to false
|
:signature "#newsbot"
|
||||||
:resolve-urls? true
|
;; optionally try to resolve URLs in posts to skip URL shorteners
|
||||||
;; optional content filter regexes
|
;; defaults to false
|
||||||
;; any posts matching the regexes will be filtered out
|
:resolve-urls? true
|
||||||
:content-filters [".*bannedsite.*"]
|
;; optional content filter regexes
|
||||||
;; optional keyword filter regexes
|
;; any posts matching the regexes will be filtered out
|
||||||
;; any posts not matching the regexes will be filtered out
|
:content-filters [".*bannedsite.*"]
|
||||||
:keyword-filters [".*clojure.*"]
|
;; optional keyword filter regexes
|
||||||
;; Replace Twitter links by Nitter
|
;; any posts not matching the regexes will be filtered out
|
||||||
:nitter-urls? false}}
|
:keyword-filters [".*clojure.*"]
|
||||||
|
;; Replace Twitter links by Nitter
|
||||||
|
:nitter-urls? false}}
|
||||||
```
|
```
|
||||||
|
|
||||||
* the bot looks for `config.edn` at its relative path by default, an alternative location can be specified either using the `MASTODON_BOT_CONFIG` environment variable or passing the path to config as an argument
|
* the bot looks for `config.edn` at its relative path by default, an alternative location can be specified either using the `MASTODON_BOT_CONFIG` environment variable or passing the path to config as an argument
|
||||||
|
|
|
@ -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?
|
||||||
|
|
Reference in a new issue