Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The great configuration overhaul of 2020 #130

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion config/sample.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Sample env file, equivalent to config.sample.edn
# vim: syntax=sh

# Sample env file, equivalent to config.sample.edn
YETIBOT_LOG_LEVEL="debug"

# By default Yetibot uses the ! prefix to match commands.
Expand Down
7 changes: 4 additions & 3 deletions src/yetibot/core/commands/karma.clj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
(s/def ::config any?)

(def config (:value (get-config ::config [:karma])))

(def pos-emoji (or (-> config :emoji :positive) ":rainbow:")) ;; 🌈
(def neg-emoji (or (-> config :emoji :negative) ":thunder_cloud_and_rain:")) ;; ⛈

Expand Down Expand Up @@ -106,8 +105,10 @@
reply-emoji user-id score)})))))))

(cmd-hook
"karma"
{:prefix
{"karma" #"karma"}
}
#"^(?x) \s* @(\w[-\w]*\w) \s*$" get-score
#"^(?x) \s* @(\w[-\w]*\w) \s{0,2} (--|\+\+) (?: \s+(.+) )? \s*$" adjust-score
#"^(?x) \s* @(\w[-\w]*\w) \s{0,2} (--|\+\+) (?: \s+(.+) )? \s*$" adjust-score
#"all" get-all-high-scores
_ get-high-scores)
2 changes: 1 addition & 1 deletion src/yetibot/core/config.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(ns yetibot.core.config
"Config is made available via
[environ](https://github.com/weavejester/environ)"
environ: https://github.com/weavejester/environ"
(:require [dec :refer [explode]]
[clojure.string :refer [blank?]]
[environ.core :refer [env]]
Expand Down
25 changes: 12 additions & 13 deletions src/yetibot/core/hooks.clj
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@
;; else - just the pattern
{(str topic-and-pattern) topic-and-pattern})
cmd-pairs (partition 2 cmds)]

(run!
(fn [[topic re-prefix]]
(let [re-prefix (lockdown-prefix-regex re-prefix)]
Expand All @@ -182,18 +181,18 @@
[prefix & cmds]
(let [cmd-pairs (partition 2 cmds)]
`(cmd-hook-resolved
~prefix
~@(mapcat (fn [[k# v#]]
[(condp = k#
'_ #".*"
k#)
; Need to resolve the var in order to get at its docstring.
; This only applies to regular usage of cmd-hook. If using
; cmd-hook with unresolvable anonymous functions (such as in
; alias) the client must add the help metdata itself as
; cmd-hook cannot extract it.
(if-let [resolved (resolve v#)] resolved v#)])
cmd-pairs))))
~prefix
~@(mapcat (fn [[k# v#]]
[(condp = k#
'_ #".*"
k#)
; Need to resolve the var in order to get at its docstring.
; This only applies to regular usage of cmd-hook. If using
; cmd-hook with unresolvable anonymous functions (such as in
; alias) the client must add the help metdata itself as
; cmd-hook cannot extract it.
(if-let [resolved (resolve v#)] resolved v#)])
cmd-pairs))))

;; TODO make obs-hooks reloadable - maybe each one should have some metadata
;; like name and description of intent assocaited with it?
Expand Down
1 change: 0 additions & 1 deletion src/yetibot/core/models/channel.clj
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
[uuid channel]
(let [results (db/query {:where/map {:chat-source-adapter (pr-str uuid)
:chat-source-channel channel}})]

(->> results
(map (fn [{:keys [key value]}]
[key
Expand Down