From 769d9e1f68ac60f67c99b0daa68f7f52945c9c6b Mon Sep 17 00:00:00 2001 From: Trevor Hartman Date: Thu, 16 Apr 2020 12:37:19 -0600 Subject: [PATCH 1/2] Add syntax hint for GitHub --- config/sample.env | 3 ++- src/yetibot/core/config.clj | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/config/sample.env b/config/sample.env index 9c231fc3..77ceaf85 100644 --- a/config/sample.env +++ b/config/sample.env @@ -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. diff --git a/src/yetibot/core/config.clj b/src/yetibot/core/config.clj index b2c61151..3fcea1bc 100644 --- a/src/yetibot/core/config.clj +++ b/src/yetibot/core/config.clj @@ -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]] From c42f79f443de31fd91812993dde80f2c09f0f365 Mon Sep 17 00:00:00 2001 From: Trevor Hartman Date: Mon, 20 Apr 2020 15:50:36 -0600 Subject: [PATCH 2/2] WIP how to tie config to cmd-hook --- src/yetibot/core/commands/karma.clj | 7 ++++--- src/yetibot/core/hooks.clj | 25 ++++++++++++------------- src/yetibot/core/models/channel.clj | 1 - 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/yetibot/core/commands/karma.clj b/src/yetibot/core/commands/karma.clj index 9c50db84..4ec9212e 100644 --- a/src/yetibot/core/commands/karma.clj +++ b/src/yetibot/core/commands/karma.clj @@ -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:")) ;; ⛈ @@ -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) diff --git a/src/yetibot/core/hooks.clj b/src/yetibot/core/hooks.clj index 425db42f..a9bd3496 100644 --- a/src/yetibot/core/hooks.clj +++ b/src/yetibot/core/hooks.clj @@ -132,7 +132,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)] @@ -153,18 +152,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? diff --git a/src/yetibot/core/models/channel.clj b/src/yetibot/core/models/channel.clj index 664203cb..45b5b9b7 100644 --- a/src/yetibot/core/models/channel.clj +++ b/src/yetibot/core/models/channel.clj @@ -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