Add a command for remembering facts

This commit is contained in:
Nick Chambers 2021-07-18 22:49:07 -05:00
parent 8d0c245f13
commit 65bb121fcd
1 changed files with 39 additions and 0 deletions

39
rowbot
View File

@ -924,6 +924,45 @@ on_late_msg_NICK_alternick() {
fi
}
# factoids
factoids_cmd_is() {
local fact_name=${action_line%% *}
if [[ $fact_name = "$action_line" || $fact_name = "$action_line " ]]; then
irc_privmsg "${msg[to]}" "Can you repeat that?"
return 0
fi
local fact_value=${action_line#"$fact_name"}
fact_value=${fact_value# }
irc_privmsg "${msg[to]}" "I'm sure I'll remember that."
mkdir -p "${config[fact-root]}"/"${msg[to]}"
printf %s "$fact_value" > "${config[fact-root]}"/"${msg[to]}"/"$fact_name"
}
factoids_cmd_isnt() {
true
}
factoids_cmd_ls() {
true
}
plugin_not_found_factoids() {
true
}
on_init_factoids() {
get_option fact-root ""
if [[ ${config[fact-root]} && -d ${config[fact-root]} ]]; then
plugin_reg is factoids_cmd_is
plugin_reg isnt factoids_cmd_isnt
plugin_reg ls factoids_cmd_ls
fi
}
###
# cleanup
###