Add new revamped brcon-countdown script. - 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 1471ecccb7580cffdcd0d10e58562c875fda1ca0
 (DIR) parent ddef9880f96f2d8a0d9290a2a94ab77e59dfb46c
 (HTM) Author: Annna Robert-Houdin <annna@bitreich.org>
       Date:   Thu, 13 May 2021 22:35:38 +0200
       
       Add new revamped brcon-countdown script.
       
       Diffstat:
         A brcon-countdown                     |      74 +++++++++++++++++++++++++++++++
       
       1 file changed, 74 insertions(+), 0 deletions(-)
       ---
 (DIR) diff --git a/brcon-countdown b/brcon-countdown
       @@ -0,0 +1,74 @@
       +#!/bin/sh
       +
       +PATH="$HOME/bin:$PATH"
       +
       +announcechannels="#bitreich-con #bitreich-en #bitreich-de #bitreich-fr #bitreich-nl #bitreich-nl #bitreich-it" 
       +schedulebase="/br/gopher/con/%s/index.gph"
       +
       +function announce {
       +        announcechannels="$1"
       +        announcestr="$2"
       +
       +        #echo "$announcestr"
       +        annna-say -c "${announcechannels}" "${announcestr}"
       +}
       +
       +if [ $# -gt 0 ];
       +then
       +        curdate="$1T00:00:00"
       +else
       +        curdate="$(date +%Y-%m-%d -d "00:00:00")"
       +fi
       +
       +year="$(date +%Y -d "${curdate}")"
       +schedule="$(printf "${schedulebase}" "${year}")"
       +
       +days="$(grep -E "^${year}-[0-9]{2}-[0-9]{2} - " "${schedule}" | cut -d' ' -f 1)"
       +fromdate="$(printf "%s\n" "${days}" | head -n 1)"
       +todate="$(printf "%s\n" "${days}" | tail -n 1)"
       +
       +daysuntil=$((($(date +%s -d "${fromdate}T00:00:00") - $(date +%s -d "${curdate}")) / 3600 / 24))
       +if [ $daysuntil -gt 0 ];
       +then
       +        case "$daysuntil" in
       +        1)
       +                daysstr="${daysuntil} day"
       +                ;;
       +        *)
       +                daysstr="${daysuntil} days"
       +                ;;
       +        esac
       +        announce "${announcechannels}" \
       +                "$(printf "%s until bitreichcon! gopher://bitreich.org/1/con/%s\n" \
       +                "${daysstr}" "${year}")"
       +        exit 0
       +fi
       +
       +dayssince=$((($(date +%s -d "${curdate}") - $(date +%s -d "${todate}T00:00:00")) / 3600 / 24))
       +if [ $dayssince -gt 0 ];
       +then
       +        [ $dayssince -gt 10 ] && exit 0
       +
       +        case "$dayssince" in
       +        1)
       +                daysstr="${dayssince} day"
       +                ;;
       +        *)
       +                daysstr="${dayssince} days"
       +                ;;
       +        esac
       +
       +        announce "${announcechannels}" \
       +                "$(printf "It has been %s since bitreichcon. Are you still happy?\n" \
       +                "${daysstr}")"
       +        exit 0
       +fi
       +
       +conferenceday=$((($(date +%s -d "${curdate}") - $(date +%s -d "${fromdate}T00:00:00")) / 3600 / 24))
       +daytopic="$(grep -E "^$(date +%Y-%m-%d -d"${curdate}") - " "${schedule}" | cut -d' ' -f 3-)"
       +announce "${announcechannels}" \
       +        "$(printf "Welcome to bitreichcon %s day %s ( %s )! Schedule: gopher://bitreich.org/1/con/%s\n" \
       +        "${year}" "${conferenceday}" "${daytopic}" "${year}")"
       +
       +exit 0
       +