URI: 
       move channel-specific code to its own function - annna - Annna the nice friendly bot.
  HTML git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/annna/
   DIR Log
   DIR Files
   DIR Refs
   DIR Tags
   DIR README
       ---
   DIR commit 4196051654532e3ec00421b6fbaeb425c6418b6f
   DIR parent 39f8fef14370ba20fa10d72e8508ffe7694f228f
  HTML Author: Josuah Demangeon <mail@josuah.net>
       Date:   Mon,  8 Mar 2021 00:08:19 +0100
       
       move channel-specific code to its own function
       
       - Use a single channel list.
       - Use one function per channel.
       - Factorise a few per-channel code.
       - Use the same style with case "${text}" in... everywhere
       
       Signed-off-by: Annna Robert-Houdin <annna@bitreich.org>
       
       Diffstat:
         M annna-start-services                |      80 ++++++++++++++-----------------
       
       1 file changed, 35 insertions(+), 45 deletions(-)
       ---
   DIR diff --git a/annna-start-services b/annna-start-services
       @@ -779,13 +779,35 @@ annna_common() {
        
        }
        
       +annna_radio() {
       +        channel="$1"
       +        user="$2"
       +        text="$3"
       +
       +        [ "$user" = "${botname}" ] && return
       +
       +        case "${text}" in
       +        ${botname}, next please.)
       +                /br/bin/bitreich-radio-playlist-next
       +                annna-say -c "${channel}" "You are very kind ${user}. To your command."
       +                return # stop here
       +                ;;
       +        ${botname}, please help.)
       +                annna-say -c "${user}" "»next please.« gets the playlist further, ${user}."
       +                annna-say -c "${user}" "»please help.« gives you this help listing, ${user}."
       +                ;;
       +        esac
       +
       +        annna_common "${channel}" "${user}" "${text}"
       +}
       +
        # Permissions
        [ -d ${iiroot} ] && chmod o+rx ${iiroot}
        [ -d ${iibase} ] && chmod o+rx ${iibase}
        
       -# All channels only requiring annna_common.
       -common_channels="#bitreich-en #bitreich-fr #bitreich-de #bitreich-nl #bitreich-it #bitreich-con #bitreich-scm #bitreich-cooking #bitreich-lawn #bitreich-tv #bitreich-meme"
       -for chan in $common_channels;
       +# All channels
       +channel_list="#bitreich-en #bitreich-fr #bitreich-de #bitreich-nl #bitreich-it #bitreich-con #bitreich-scm #bitreich-cooking #bitreich-lawn #bitreich-tv #bitreich-meme #bitreich-radio"
       +for chan in $channel_list;
        do
                [ -d "${iibase}/${chan}" ] \
                        && chmod o+rx "${iibase}/${chan}"
       @@ -795,7 +817,7 @@ done
        
        # Channels with extra features or external scripts.
        ## SCM (/scm/post-receive)
       -## This one is handled by common_channels.
       +## This one is handled by channel_list.
        
        ## Radio (/br/radio/playlist.sh + this script)
        [ -d "${iibase}/#bitreich-radio" ] \
       @@ -806,47 +828,8 @@ done
        
        # Channel handlers.
        
       -## Special handlers first.
       -if [ -f "${iibase}/#bitreich-radio/out" ];
       -then
       -{
       -        channel="#bitreich-radio"
       -        ls "${iibase}/${channel}/out" | entr tail -n 1 "${iibase}/${channel}/out" \
       -                | grep -v --line-buffered '[0-9]* -!- ' \
       -                | sed -u 's,[0-9]* <\([^ >]*\)> \(.*\),\1\n\2,' \
       -                | {
       -        while read -r user;
       -        do
       -                read -r text
       -
       -                [ "$user" = "${botname}" ] && continue
       -
       -                if [ "${text}" = "${botname}, next please." ];
       -                then
       -                        /br/bin/bitreich-radio-playlist-next
       -                        annna-say -c "${channel}" "You are very kind ${user}. To your command."
       -                        continue;
       -                fi
       -
       -                if [ "${text}" = "${botname}, please help." ];
       -                then
       -                        annna-say -c "${user}" "»next please.« gets the playlist further, ${user}."
       -                        annna-say -c "${user}" "»please help.« gives you this help listing, ${user}."
       -
       -                        # Give out common help too.
       -                        annna_common "${channel}" "${user}" "${text}"
       -                        continue;
       -                fi
       -                
       -                # Allow common functions too.
       -                annna_common "${channel}" "${user}" "${text}"
       -        done
       -        }
       -} &
       -fi
       -
        ## Common channel handler.
       -for channel in $common_channels;
       +for channel in $channel_list;
        do
                if [ -f "${iibase}/${channel}/out" ];
                then
       @@ -859,7 +842,14 @@ do
                        do
                                read -r text
        
       -                        annna_common "${channel}" "${user}" "${text}"
       +                        case "${channel}" in
       +                        \#bitreich-radio)
       +                                annna_radio "${channel}" "${user}" "${text}"
       +                                ;;
       +                        *)
       +                                annna_common "${channel}" "${user}" "${text}"
       +                                ;;
       +                        esac
                        done
                        }
                } &