Skip to content
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ parametri da command line:
* --wall : invia l'output a tutte le console : attenzione , se non siete root o sudoers disattivare il flag -n
* --shutdown : se si e' root spegne il computer dopo aver finito di invocare sant (dipende da --nds)
* --off : equivalente a --nds 1 --shutdown

* **--saintoftheday : NEW FEATURE!!, variante che invoca biastime e improperi verso i santi del giorno**

Rilasciato sotto Licenza GNU-GPL v.3

idea originale by Alexiobash dallo script incazzatore.sh
Expand Down
41 changes: 30 additions & 11 deletions mannaggia.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash
############################################################
# Mannaggiatore automatico per VUA depressi
# idea originale by Alexiobash dallo script incazzatore.sh
Expand All @@ -21,7 +21,9 @@
# --nds <n> : numero di santi da invocare (di default continua all'infinito)
# --shutdown : se nds > 0 e si e` root al termine delle invocazioni spegne
# --off : se si e` root invoca un solo santo e spegne (equivale a --nds 1 --shutdown)
# --saintoftheday : variante che invoca biastime e improperi verso i santi del giorno
audioflag=false
saintofthedayflag=false
spm=1
spmflag=false
nds=-1
Expand All @@ -30,19 +32,28 @@ ndsflag=false
wallflag=false
shutdown=false
off=false
DELSTRING1="</FONT>"
DELSTRING2="</b>"
#DELSTRING1="</FONT>"
#DELSTRING2="</b>"
DEFPLAYER="mplayer -cache 1024 -"
PLAYER="${PLAYER:-$DEFPLAYER}"
LC_CTYPE=C

if [ $(uname) = "Darwin" ]
then
shufCmd=gshuf
audiodev=coreaudio
urand=$(LC_ALL=C tr -dc 'A-Z' < /dev/urandom | head -c 1)
else
shufCmd=shuf
audiodev=alsa
urand=$(</dev/urandom tr -dc A-Z|head -c1)
fi

say() {
local IFS=+
mplayer -ao $audiodev -really-quiet -noconsolecontrols "http://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&q=$*&tl=it"
}

# lettura parametri da riga comando
for parm in "$@"
do
Expand Down Expand Up @@ -110,6 +121,12 @@ for parm in "$@"
then
off=true
fi
# imposta saintofthedayflag su true per invocare la url apposita che raccoglie il subset di Santi del giorno
if [ "$parm" = "--saintoftheday" ]
then
saintofthedayflag=true
nds=1
fi

done

Expand All @@ -118,30 +135,32 @@ if [ $off = true ]
shutdown=true
nds=1
fi

while [ "$nds" != 0 ]
do
# shellcheck disable=SC2019
MANNAGGIA="Mannaggia $(curl -s "www.santiebeati.it/$(</dev/urandom tr -dc A-Z|head -c1)/"|grep -a tit|cut -d'>' -f 4-9|$shufCmd -n1 |awk -F "$DELSTRING1" '{print$1$2}'|awk -F "$DELSTRING2" '{print$1}' | iconv -f ISO-8859-1)"
MANNAGGIAURL="http://www.ispeech.org/p/generic/getaudio?text=$MANNAGGIA%2C&voice=euritalianmale&speed=0&action=convert"

# l'if condizionale per il parametro che permette di invocare i santi dalla pagina del giorno o della global
if [ "$saintofthedayflag" = true ]
then
MANNAGGIA="Mannaggia $(curl -Ls "www.santiebeati.it/$(date +%m/%d)/"|grep -a tit|cut -d'>' -f 3-9|sed 's/<\/FONT> <FONT SIZE="-1"><b>/ /;s/<\/A>//g;s/<\/b>.*$//g;/^[[:space:]]*$/d'|$shufCmd -n1 |iconv -f ISO-8859-1)"
else
MANNAGGIA="Mannaggia $(curl -Ls "www.santiebeati.it/${urand}/"|grep -a tit|cut -d'>' -f 3-9|sed 's/<\/FONT> <FONT SIZE="-1"><b>/ /;s/<\/A>//g;s/<\/b>.*$//g;/^[[:space:]]*$/d'|$shufCmd -n1 |iconv -f ISO-8859-1)"
fi

if [ "$wallflag" = true ]
then
pot=$(( nds % 50 ))
if [ "$pot" = 0 ]
then
echo "systemd merda, poettering vanaglorioso fonte di danni, ti strafulmini santa cunegonda bipalluta protrettice dei VUA"
echo "Systemd merda, Poettering vanaglorioso fonte di danni, ti strafulmini santa Cunegonda Bipalluta protrettice dei VUA"
else
# attenzione: se non siete root o sudoers dovete togliere dalla riga successiva "sudo" e "-n"
echo "$MANNAGGIA" | sudo wall -n
fi
else
echo "$MANNAGGIA" > /dev/stdout
fi

if [ "$audioflag" = true ]
then
wget "$MANNAGGIAURL" -O - 2> /dev/null | $PLAYER >> /dev/null 2>&1
say $MANNAGGIA 2>/dev/null
fi

sleep "$spm"
Expand Down