mv chop tail
This commit is contained in:
parent
0cfe940226
commit
52ce74be18
2 changed files with 10 additions and 8 deletions
|
@ -35,10 +35,7 @@
|
||||||
(defn in [needle haystack]
|
(defn in [needle haystack]
|
||||||
(some (partial = needle) haystack))
|
(some (partial = needle) haystack))
|
||||||
|
|
||||||
; If the text ends in a link to the media (which is uploaded anyway),
|
|
||||||
; chop it off instead of including the link in the toot
|
|
||||||
(defn chop-tail-media-url [text media]
|
|
||||||
(string/replace text #" (\S+)$" #(if (in (%1 1) (map :url media)) "" (%1 0))))
|
|
||||||
|
|
||||||
(defn parse-tweet [{created-at :created_at
|
(defn parse-tweet [{created-at :created_at
|
||||||
text :full_text
|
text :full_text
|
||||||
|
@ -47,7 +44,7 @@
|
||||||
{:created-at (js/Date. created-at)
|
{:created-at (js/Date. created-at)
|
||||||
:text (transform/trim-text
|
:text (transform/trim-text
|
||||||
(mastodon-config config)
|
(mastodon-config config)
|
||||||
(str (chop-tail-media-url text media)
|
(str (twitter/chop-tail-media-url text media)
|
||||||
(if (masto/append-screen-name? (mastodon-config config))
|
(if (masto/append-screen-name? (mastodon-config config))
|
||||||
(str "\n - " screen_name) "")))
|
(str "\n - " screen_name) "")))
|
||||||
:media-links (keep #(when (= (:type %) "photo") (:media_url_https %)) media)})
|
:media-links (keep #(when (= (:type %) "photo") (:media_url_https %)) media)})
|
||||||
|
|
|
@ -21,9 +21,6 @@
|
||||||
(s/def ::accounts (s/* ::account))
|
(s/def ::accounts (s/* ::account))
|
||||||
(def twitter-config? (s/keys :req-un [::access-keys ::include-rts? ::include-replies?]))
|
(def twitter-config? (s/keys :req-un [::access-keys ::include-rts? ::include-replies?]))
|
||||||
|
|
||||||
(defn strip-utm [news-link]
|
|
||||||
(first (string/split news-link #"\?utm")))
|
|
||||||
|
|
||||||
(defn-spec twitter-client any?
|
(defn-spec twitter-client any?
|
||||||
[twitter-config twitter-config?]
|
[twitter-config twitter-config?]
|
||||||
(let [{:keys [access-keys]} twitter-config]
|
(let [{:keys [access-keys]} twitter-config]
|
||||||
|
@ -33,6 +30,14 @@
|
||||||
(infra/exit-with-error
|
(infra/exit-with-error
|
||||||
(str "failed to connect to Twitter: " (.-message e)))))))
|
(str "failed to connect to Twitter: " (.-message e)))))))
|
||||||
|
|
||||||
|
(defn strip-utm [news-link]
|
||||||
|
(first (string/split news-link #"\?utm")))
|
||||||
|
|
||||||
|
; If the text ends in a link to the media (which is uploaded anyway),
|
||||||
|
; chop it off instead of including the link in the toot
|
||||||
|
(defn chop-tail-media-url [text media]
|
||||||
|
(string/replace text #" (\S+)$" #(if (in (%1 1) (map :url media)) "" (%1 0))))
|
||||||
|
|
||||||
(defn-spec user-timeline any?
|
(defn-spec user-timeline any?
|
||||||
[twitter-config twitter-config?
|
[twitter-config twitter-config?
|
||||||
account ::account
|
account ::account
|
||||||
|
|
Reference in a new issue