Uberjar reads files now

This commit is contained in:
Clemens Geibel 2021-03-12 11:10:46 +01:00
parent de5239bd7a
commit a4948f5ae0
4 changed files with 96 additions and 14 deletions

View file

@ -2,26 +2,19 @@
(:gen-class)
(:require
[clojure.spec.alpha :as s]
[clojure.java.io :as io]
[dda.k8s-mastodon-bot.core :as core]))
(def usage
"usage:
k8s-mastodon-bot '{your configuraton}' '{your authorization}'")
k8s-mastodon-bot {your configuraton file} {your authorization file}")
; Checks if a string validates a given spec after the string is transformed to Clojure data structure by clojure.edn/read-string.
(defn spec-string? [spec]
(fn [str]
(s/and
(string? str)
(s/valid? spec (clojure.edn/read-string str)))))
(s/def ::config-map-str (spec-string? ::core/config))
(s/def ::auth-map-str (spec-string? ::core/auth))
(s/def ::filename string?)
(s/def ::cmd-args (s/cat :options ::core/options
:config ::config-map-str
:auth ::config-map-str))
:config ::filename
:auth ::filename))
(defn invalid-args-msg [spec args]
(do (s/explain spec args)
@ -32,8 +25,8 @@
(if (= ::s/invalid parsed-args-cmd)
(invalid-args-msg ::cmd-args cmd-args)
(let [{:keys [options config auth]} parsed-args-cmd
config-map (clojure.edn/read-string config)
auth-map (clojure.edn/read-string auth)]
config-map (slurp config)
auth-map (slurp auth)]
(cond
(some #(= "-h" %) options)
(println usage)

View file

@ -0,0 +1,14 @@
{:auth {;; add Twitter config to mirror Twitter accounts
:twitter {:consumer_key "XXXX"
:consumer_secret "XXXX"
:access_token_key "XXXX"
:access_token_secret "XXXX"}
: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/"}
:tumblr {:consumer_key "XXXX"
:consumer_secret "XXXX"
:token "XXXX"
:token_secret "XXXX"}}}

View file

@ -0,0 +1,25 @@
{:transform [{:source {:source-type :twitter
;; optional, defaults to false
:include-replies? false
;; optional, defaults to false
:include-rts? false
;; Replace Twitter links by Nitter
:nitter-urls? false
;; accounts you wish to mirror
:accounts ["arstechnica" "WIRED"]}
:target {:target-type :mastodon
;; optional flag specifying wether the name of the account
;; will be appended in the post, defaults to false
:append-screen-name? false
;; optional visibility flag: direct, private, unlisted, public
;; defaults to public
:visibility "unlisted"
;; optional boolean to mark content as sensitive. Defaults to true.
:sensitive? true
;; optional boolean defaults to false
;; only sources containing media will be posted when set to true
:media-only? true
;; optional limit for the post length. Defaults to 300.
:max-post-length 300
;; optional signature for posts. Defaults to "not present".
:signature "#newsbot"}}]}

View file

@ -0,0 +1,50 @@
<configuration scan="true" scanPeriod="1 seconds" debug="false">
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
</filter>
</appender>
<appender name="PALLETFILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>logs/pallet.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>logs/old/pallet.%d{yyyy-MM-dd}.log</fileNamePattern>
<maxHistory>3</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%date %level [%thread] %logger{10} %msg%n</pattern>
</encoder>
</appender>
<logger name="clj-ssh.ssh" level="ERROR">
<appender-ref ref="PALLETFILE" />
</logger>
<logger name="pallet" level="DEBUG">
<appender-ref ref="PALLETFILE" />
</logger>
<logger name="pallet.ssh" level="ERROR">
<appender-ref ref="PALLETFILE" />
</logger>
<logger name="pallet.algo" level="ERROR">
<appender-ref ref="PALLETFILE" />
</logger>
<logger name="dda" level="DEBUG">
<appender-ref ref="PALLETFILE" />
</logger>
<logger name="meissa" level="DEBUG">
<appender-ref ref="PALLETFILE" />
</logger>
<root level="DEBUG">
<appender-ref ref="CONSOLE" />
</root>
</configuration>