Add PIL command. Thanks lvKas for the idea! - annna - Annna the nice friendly bot.
 (HTM) git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/annna/
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Tags
 (DIR) README
       ---
 (DIR) commit c798cee388f555f52c4d728e65cdd943333050e1
 (DIR) parent da39f83957f9f27edb1266e725d4635a911a348d
 (HTM) Author: Annna Robert-Houdin <annna@bitreich.org>
       Date:   Tue, 30 Jun 2026 13:53:14 +0200
       
       Add PIL command. Thanks lvKas for the idea!
       
       Diffstat:
         M annna-message-common                |      21 +++++++++++++++++++++
         A modules/pil/pil.txt                 |       0 
         A pil                                 |      62 +++++++++++++++++++++++++++++++
         A pil-user                            |      35 +++++++++++++++++++++++++++++++
       
       4 files changed, 118 insertions(+), 0 deletions(-)
       ---
 (DIR) diff --git a/annna-message-common b/annna-message-common
       @@ -1214,6 +1214,27 @@ $'\001'"ACTION snouts ${IRC_USER}"$'\001')
                tagname="$(printf "%s\n" "${tagline}" | cut -d ' ' -f 1)"
                taguri="$(printf "%s\n" "${tagline}" | cut -d ' ' -f 2-)"
                annna-say "${tagname}: ${taguri}";;
       +"${IRC_USER}, PIL "*|"${IRC_USER}, pil "*)
       +        minimum_purpose_len=12
       +        offset=$(( ${#IRC_USER} + 6 ))
       +        purposes="$(printf "%s\n" "${IRC_PRIVMSG_TEXT}" \
       +                | cut -c $offset- \
       +                | sed 's,\t,    ,g')"
       +        if [ ${#purposes} -le $minimum_purpose_len ];
       +        then
       +                annna-say "${IRC_CMD_USER}, can you explain better what your purpose in life is?"
       +        else
       +                result="$(pil ${IRC_CMD_USER} "${purposes}")"
       +                if [ $? -eq 0 ];
       +                then
       +                        annna-say "${IRC_CMD_USER}, ${result}"
       +                fi
       +        fi;;
       +"${IRC_USER}, what is my purpose in life?")
       +        if result=$(pil-user ${IRC_CMD_USER});
       +        then
       +                annna-say "${IRC_CMD_USER}, ${result}"
       +        fi;;
        "${IRC_USER}, TIL "*|"${IRC_USER}, til "*)
                minimum_learned_len=12
                offset=$(( ${#IRC_USER} + 6 ))
 (DIR) diff --git a/modules/pil/pil.txt b/modules/pil/pil.txt
 (DIR) diff --git a/pil b/pil
       @@ -0,0 +1,62 @@
       +#!/bin/sh
       +
       +nick="${1}"
       +purposes="${2}"
       +pilmodbase="$HOME/bin/modules/pil"
       +pildb="${pilmodbase}/pil.txt"
       +
       +# Make sure there's a file to store the PILs
       +if [ ! -f "${pildb}" ];
       +then
       +    mkdir -p "${pilmodbase}"
       +    touch "${pildb}"
       +fi
       +
       +# Make sure file is writable.
       +if [ ! -w "${pildb}" ];
       +then
       +    exit 1
       +fi
       +
       +# Clean up the purposes string.
       +purposes="$(printf "%s" "${purposes}" \
       +        | tr -d [:cntrl:] \
       +        | sed 's,\n, ,g')"
       +
       +# Check to see if its already been purposes.
       +already_purposes_entry="$(grep -m 1 "${purposes}" "${pildb}")"
       +if [ $? -eq 0 ]; # Match found (grep exit status of 0)
       +then
       +    timestamp="$(printf "%s" "${already_purposes_entry}" \
       +        | tr "\t" "\n" \
       +        | tail -n 1)"
       +    user="$(printf "%s" "${already_purposes_entry}" \
       +        | tr "\t" "\n" \
       +        | head -n 1)"
       +    purposes_text="$(printf "%s" "${already_purposes_entry}" \
       +        | tr "\t" "\n" \
       +        | tail -n 2 \
       +        | head -n 1)"
       +    paste="$(printf '%s\n%s purposes %s\n' \
       +                '${timestamp}' \
       +                '${user}' \
       +                '${purposes_text}' \
       +                | /br/bin/bitreich-paste)"
       +    printf "looks like that's already an purpose by %s on %s! %s" \
       +                "${user:-someone}" \
       +                "$(date -d "${timestamp}" +"%B %d, %Y")" \
       +                '${paste}'
       +    exit
       +fi
       +
       +# Add the new TIL to the database.
       +timestamp=$(date -u)
       +printf "%s\n" "${nick}        ${purposes}        $(date -u)" \
       +       >> "${pildb}"
       +
       +# Count users TILs
       +pil_count="$(grep -cP "^${nick}\t" "${pildb}")"
       +
       +# Successful return message. 
       +printf "you have ${pil_count} purposes in life so far! :-)"
       +exit 0
 (DIR) diff --git a/pil-user b/pil-user
       @@ -0,0 +1,35 @@
       +#!/bin/sh
       +
       +nick="${1}"
       +pilmodbase="$HOME/bin/modules/pil"
       +pildb="${pilmodbase}/pil.txt"
       +
       +# Make sure there's a file to parse.
       +if [ ! -f "${pildb}" ];
       +then
       +        exit 1
       +fi
       +
       +format_user_pils() {
       +    awk -v nick="${nick}" \
       +'BEGIN {
       +        FS="\t"
       +        print nick "\n"
       +}
       +$1 ~ nick {
       +        print $3 
       +        print "\nPIL" $2 "\n\n"
       +}' "${pildb}"
       +}
       +
       +if user_purposes_count="$(grep -cP "^${nick}\t" "${pildb}")";
       +then
       +        results=$(format_user_pils "${nick}" \
       +                        | fmt -w 69 \
       +                        | /br/bin/bitreich-paste)
       +        printf "here is your purposes in life: %s" "${results}"
       +        exit 0
       +else
       +        printf "you have no purposes in life yet :-O"
       +        exit 0
       +fi