Support Shikhin's facts #6

Merged
uplime merged 1 commits from shikhin-facts into master 2021-06-19 23:39:48 +00:00
1 changed files with 12 additions and 6 deletions

18
rowbot
View File

@ -561,9 +561,15 @@ hook_pre_PRIVMSG_CTCP() {
} }
hook_post_PRIVMSG_factoids() { hook_post_PRIVMSG_factoids() {
if [[ ${params[0]:0:1} != \# ]]; then if [[ ${params[0]:0:1} != \# && $from != shikhin ]]; then
return 0 return 0
elif [[ ${words[0]} = "$trigger"* ]]; then elif [[ ${words[0]} = "$trigger"* ]]; then
local to=${params[0]}
if [[ ${params[0]:0:1} != \# ]]; then
to=$from
fi
case ${words[0]:${#trigger}} in case ${words[0]:${#trigger}} in
is) is)
if (( ${#words[@]} < 3 )); then if (( ${#words[@]} < 3 )); then
@ -575,7 +581,7 @@ hook_post_PRIVMSG_factoids() {
val=${key#* } key=${key%% *} val=${key#* } key=${key%% *}
info "%s said in %s to remember %s as %s" "$from" "${params[0]}" "$key" "$val" info "%s said in %s to remember %s as %s" "$from" "${params[0]}" "$key" "$val"
privmsg "${params[0]}" "I'm sure I'll remember that." privmsg "$to" "I'm sure I'll remember that."
mkdir -p "$fact_root"/"${params[0]}" mkdir -p "$fact_root"/"${params[0]}"
printf %s "$val" > "$fact_root"/"${params[0]}"/"$key" printf %s "$val" > "$fact_root"/"${params[0]}"/"$key"
;; ;;
@ -589,13 +595,13 @@ hook_post_PRIVMSG_factoids() {
if [[ -f $fact_root/${params[0]}/$key ]]; then if [[ -f $fact_root/${params[0]}/$key ]]; then
info "%s said in %s to delete %s" "$from" "${params[0]}" "$key" info "%s said in %s to delete %s" "$from" "${params[0]}" "$key"
privmsg "${params[0]}" "I forgot what that was anyways." privmsg "$to" "I forgot what that was anyways."
rm -f "$fact_root"/"${params[0]}"/"$key" rm -f "$fact_root"/"${params[0]}"/"$key"
fi fi
;; ;;
ls) ls)
local facts=( "$fact_root"/"${params[0]}"/* ) local facts=( "$fact_root"/"${params[0]}"/* )
privmsg "${params[0]}" "${facts[*]##*/}" privmsg "$to" "${facts[*]##*/}"
;; ;;
*) *)
local key=${words[0]:${#trigger}} local key=${words[0]:${#trigger}}
@ -607,9 +613,9 @@ hook_post_PRIVMSG_factoids() {
if (( ${#words[@]} > 1 )) && [[ ${words[1]} = \> ]]; then if (( ${#words[@]} > 1 )) && [[ ${words[1]} = \> ]]; then
local target local target
target=${params[1]#*\>} target=${target# } target=${target% } target=${params[1]#*\>} target=${target# } target=${target% }
privmsg "${params[0]}" "$target: $msg" privmsg "$to" "$target: $msg"
else else
privmsg "${params[0]}" "$from: $msg" privmsg "$to" "$from: $msg"
fi fi
fi fi
esac esac