Add list factoids function

Thanks to bill-auger for this function from pbot-ng which works also in hyperbot
This commit is contained in:
quiliro 2020-10-06 19:34:17 -05:00 committed by Gaming4JC
parent 1e141d2633
commit 55cd3ec4a9
No known key found for this signature in database
GPG Key ID: AEAADD85D2F527B0

View File

@ -321,6 +321,22 @@ function process_event
# factoids # # factoids #
############ ############
# list factoids
',' | ',list' | ',factoids' | "${my_own_name}: list factoids" )
local factoids=( $(ls info/) )
local n_factoids=${#factoids[*]}
local begin_msg="ask me about:"
local end_msg="e.g. ${server_nick_current}: what is ${factoids[0]} (or ,${factoids[0]})"
send_msg "${personoslash}" "${begin_msg}"
for (( factoid_n = 0 ; factoid_n < n_factoids ; factoid_n = factoid_n 10 ))
do send_msg "${personoslash}" " ${factoids[*]:${factoid_n}:10}"
sleep 1
done
send_msg "${personoslash}" "${end_msg}"
;;
# set factoid
"${my_own_name}: "+([!/])" is "+([![:space:]])* ) "${my_own_name}: "+([!/])" is "+([![:space:]])* )
declare -l thing="${sentence#${my_own_name}: }" declare -l thing="${sentence#${my_own_name}: }"
thing="${thing%% is *}" thing="${thing%% is *}"
@ -349,6 +365,8 @@ function process_event
forget_fact forget_fact
;; ;;
# display factoid
','+([!/]) ) ','+([!/]) )
thing="${sentence#,}" thing="${sentence#,}"