diff --git a/rowbot b/rowbot index 60413b8..3f2ab10 100755 --- a/rowbot +++ b/rowbot @@ -97,6 +97,7 @@ trigger=${opts[trigger]:-\`} fact_root=${opts[fact-root]:-.} reload=${opts[reload]:-no} dev=${opts[dev]:-no} +sysfacts_file=${opts[sysfacts]:-./sysfacts.txt} if [[ -v USER ]]; then owner=${opts[owner]:-"$USER"} @@ -712,6 +713,29 @@ hook_post_PRIVMSG_control_panel() { fi } +sysfacts=( ) + +if [[ -f $sysfacts_file ]]; then + mapfile -t sysfacts < "$sysfacts_file" +fi + +hook_post_PRIVMSG_sysfacts() { + local to=${params[0]} idx + + if [[ ${params[0]:0:1} != \# ]]; then + to=$from + fi + + if [[ ${words[0]} = "$trigger"sysfact ]]; then + if (( ${#sysfacts[@]} == 0 )); then + privmsg "$to" "sysfacts are not loaded :(" + else + (( idx = RANDOM % ${#sysfacts[@]} )) + privmsg "$to" "sysfact #$(( idx + 1 )): ${sysfacts[$idx]}" + fi + fi +} + hook_post_433_alternick() { if [[ -z $desired_nick && $registered = no ]]; then desired_nick=${params[1]}