Introduction
Introduction Statistics Contact Development Disclaimer Help
move channel-specific code to its own function - annna - Annna the nice friendl…
git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws6…
Log
Files
Refs
Tags
README
---
commit 4196051654532e3ec00421b6fbaeb425c6418b6f
parent 39f8fef14370ba20fa10d72e8508ffe7694f228f
Author: Josuah Demangeon <[email protected]>
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 <[email protected]>
Diffstat:
M annna-start-services | 80 ++++++++++++++---------------…
1 file changed, 35 insertions(+), 45 deletions(-)
---
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 …
+ return # stop here
+ ;;
+ ${botname}, please help.)
+ annna-say -c "${user}" "»next please.« gets the playlist fur…
+ annna-say -c "${user}" "»please help.« gives you this help l…
+ ;;
+ 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…
-for chan in $common_channels;
+# All channels
+channel_list="#bitreich-en #bitreich-fr #bitreich-de #bitreich-nl #bitreich-it…
+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}/o…
- | 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}. …
- continue;
- fi
-
- if [ "${text}" = "${botname}, please help." ];
- then
- annna-say -c "${user}" "»next please.« gets the play…
- annna-say -c "${user}" "»please help.« gives you thi…
-
- # 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
}
} &
You are viewing proxied material from bitreich.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.