Preparing multi-server support. - 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 f2073d06cdc3f2b9f39c74384e9d93e90c5cb968 DIR parent c128f94676902d9f277acd269fd01db21c3c8470 HTML Author: Annna Robert-Houdin <annna@bitreich.org> Date: Fri, 31 Dec 2021 12:31:12 +0100 Preparing multi-server support. * check if credentials are present, so invoke ii differently. Diffstat: M annna-channel-service | 7 +++++-- M annna-message-common | 7 ++++--- M annna-message-radio | 7 ++++--- M annna-say | 13 ++++++++++--- M annna-start-main | 17 ++++++++++++----- 5 files changed, 35 insertions(+), 16 deletions(-) --- DIR diff --git a/annna-channel-service b/annna-channel-service @@ -21,10 +21,13 @@ while read -r user text; do case "${channel}" in \#bitreich-radio) - annna-message-radio "${channel}" "${user}" "${text}" + annna-message-radio "${server}" "${channel}" "${user}" "${text}" + ;; + \#gopherproject) + annna-message-gopherproject "${server}" "${channel}" "${user}" "${text}" ;; *) - annna-message-common "${channel}" "${user}" "${text}" + annna-message-common "${server}" "${channel}" "${user}" "${text}" ;; esac done DIR diff --git a/annna-message-common b/annna-message-common @@ -14,9 +14,10 @@ printnhashtags=2 botname="annna" brmembers="__20h__ Evil_Bob chripo posativ quinq stateless solene josuah parazyd bin KatolaZ adc" -channel="$1" -user="$2" -text="$3" +server="$1" +channel="$2" +user="$3" +text="$4" annnasumerian="𒈹" hashtags() { DIR diff --git a/annna-message-radio b/annna-message-radio @@ -3,9 +3,10 @@ modbase="/home/annna/bin/modules/" botname="annna" -channel="$1" -user="$2" -text="$3" +server="$1" +channel="$2" +user="$3" +text="$4" [ "$user" = "${botname}" ] && exit DIR diff --git a/annna-say b/annna-say @@ -6,23 +6,30 @@ export PATH="$PATH:/home/annna/bin" usage() { - printf "usage: %s [-h] [-i ircbase] -c \"channel0 ... channel1 ...\" text\n" \ + printf "usage: %s [-h] [-i ircbase] [-s server] -c \"channel0 ... channel1 ...\" text\n" \ "$(basename "$1")" >&2 exit 1 } channels="" -ircbase="/home/annna/irc/irc.bitreich.org" +server="irc.bitreich.org" +ircbase="/home/annna/irc/${server}" +ircbaseset=0 -while getopts "hb:c:" opt; +while getopts "hb:c:s:" opt; do case $opt in b) ircbase="$OPTARG" + ircbaseset=1 ;; c) channels="$OPTARG" ;; + s) + server="$OPTARG" + [ $ircbaseset -eq 0 ] && ircbase="/home/annna/irc/${server}" + ;; *) usage $0 ;; DIR diff --git a/annna-start-main b/annna-start-main @@ -32,13 +32,20 @@ rm -f "$HOME/irc/${server}/sock" #done # Connection -export ircuser="$(sed -n 's/^user: //p' $HOME/annna/${server}/irc-credentials.txt)" -export ircpass="$(sed -n 's/^pass: //p' $HOME/annna/${server}/irc-credentials.txt)" +export ircuser="$(sed -n 's/^user: //p' $HOME/annna/${server}/irc-credentials.txt 2>/dev/null)" +export ircpass="$(sed -n 's/^pass: //p' $HOME/annna/${server}/irc-credentials.txt 2>/dev/null)" #ii -s "${server}" -t -p 6697 -n "$ircuser" -k ircpass \ # -f "Annna Robert-Houdin" & -ii -s "${server}" -v -t -p 6697 -n "$ircuser" \ - -f "Annna Robert-Houdin" & -iipid=$! +if [ -n "${ircuser}" -a -n "${ircpass}" ]; +then + ii -s "${server}" -v -t -p 6697 -n "$ircuser" \ + -f "Annna Robert-Houdin" & + iipid=$! +else + ii -s "${server}" -v -t -p 6697 \ + -f "Annna Robert-Houdin" & + iipid=$! +fi { # Watch for ii to exit. Then remove the used directory to have all