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
|
||||
package-lock.json
|
||||
/.shadow-cljs
|
||||
/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.
|
||||
|
||||
```clojure
|
||||
#:mastodon-bot.core
|
||||
{;; add Twitter config to mirror Twitter accounts
|
||||
:twitter {:access-keys
|
||||
{: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
|
||||
:rss {"Hacker News" "https://hnrss.org/newest"
|
||||
"r/Clojure" "https://www.reddit.com/r/clojure/.rss"}
|
||||
:mastodon {:access_token "XXXX"
|
||||
;; account number you see when you log in and go to your profile
|
||||
;; e.g: https://mastodon.social/web/accounts/294795
|
||||
:account-id "XXXX"
|
||||
:api_url "https://botsin.space/api/v1/"
|
||||
;; optional boolean to mark content as sensitive
|
||||
:sensitive? true
|
||||
;; optional boolean defaults to false
|
||||
;; only sources containing media will be posted when set to true
|
||||
:media-only? true
|
||||
;; optional visibility flag: direct, private, unlisted, public
|
||||
;; defaults to public
|
||||
:visibility "unlisted"
|
||||
;; optional limit for the post length
|
||||
:max-post-length 300
|
||||
;; optional flag specifying wether the name of the account
|
||||
;; will be appended in the post, defaults to false
|
||||
:append-screen-name? false
|
||||
;; optional signature for posts
|
||||
:signature "#newsbot"
|
||||
;; optionally try to resolve URLs in posts to skip URL shorteners
|
||||
;; defaults to false
|
||||
:resolve-urls? true
|
||||
;; optional content filter regexes
|
||||
;; any posts matching the regexes will be filtered out
|
||||
:content-filters [".*bannedsite.*"]
|
||||
;; optional keyword filter regexes
|
||||
;; any posts not matching the regexes will be filtered out
|
||||
:keyword-filters [".*clojure.*"]
|
||||
;; Replace Twitter links by Nitter
|
||||
:nitter-urls? false}}
|
||||
:mastodon
|
||||
#:mastodon-bot.mastodon-api
|
||||
{:access_token "XXXX"
|
||||
;; account number you see when you log in and go to your profile
|
||||
;; e.g: https://mastodon.social/web/accounts/294795
|
||||
:account-id "XXXX"
|
||||
:api_url "https://botsin.space/api/v1/"
|
||||
;; optional boolean to mark content as sensitive
|
||||
:sensitive? true
|
||||
;; optional boolean defaults to false
|
||||
;; only sources containing media will be posted when set to true
|
||||
:media-only? true
|
||||
;; optional visibility flag: direct, private, unlisted, public
|
||||
;; defaults to public
|
||||
:visibility "unlisted"
|
||||
;; optional limit for the post length
|
||||
:max-post-length 300
|
||||
;; optional flag specifying wether the name of the account
|
||||
;; will be appended in the post, defaults to false
|
||||
:append-screen-name? false
|
||||
;; optional signature for posts
|
||||
:signature "#newsbot"
|
||||
;; optionally try to resolve URLs in posts to skip URL shorteners
|
||||
;; defaults to false
|
||||
:resolve-urls? true
|
||||
;; optional content filter regexes
|
||||
;; any posts matching the regexes will be filtered out
|
||||
:content-filters [".*bannedsite.*"]
|
||||
;; optional keyword filter regexes
|
||||
;; any posts not matching the regexes will be filtered out
|
||||
: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
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
{:source-paths ["src/main"
|
||||
"src/test"]
|
||||
:dependencies [[orchestra "2018.12.06-2"]]
|
||||
:builds {:dev {:target :node-script
|
||||
:repl-init-ns mastodon-bot.core
|
||||
:output-to "target/mastodon-bot.js"
|
||||
:main mastodon-bot.core/dummy
|
||||
:repl-pprint true}
|
||||
:builds {:dev {:target :node-library
|
||||
:output-to "target/lib-mastodon-bot.js"
|
||||
:exports {:infra mastodon-bot.infra/js->edn}
|
||||
:repl-pprint true
|
||||
}
|
||||
:app {:target :node-script
|
||||
:output-to "target/mastodon-bot.js"
|
||||
:main mastodon-bot.core/main
|
||||
|
|
|
@ -15,9 +15,12 @@
|
|||
[mastodon-bot.infra :as infra]
|
||||
[mastodon-bot.mastodon-api :as masto]))
|
||||
|
||||
(defn dummy [])
|
||||
|
||||
(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
|
||||
(defn-spec mastodon-config ::mastodon-config
|
||||
|
@ -135,7 +138,7 @@
|
|||
(fn [timeline]
|
||||
(let [last-post-time (-> timeline first :created_at (js/Date.))]
|
||||
;;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
|
||||
client (twitter-client access-keys)]
|
||||
(doseq [account accounts]
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
(s/def ::content-filters (s/* ::content-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
|
||||
::max-post-length ::signature ::visibility
|
||||
::append-screen-name? ::sensitive? ::resolve-urls?
|
||||
|
|
Reference in a new issue