summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--TODO7
-rwxr-xr-xmodules/cat14
-rwxr-xr-xmodules/ein_mal_eins38
-rwxr-xr-xmodules/espeak2
-rwxr-xr-xmodules/help2
-rwxr-xr-xmodules/mpc2
-rwxr-xr-xmodules/ping24
-rwxr-xr-xmodules/play10
-rwxr-xr-xmodules/pong26
-rwxr-xr-xmodules/sendmail55
-rwxr-xr-xmodules/shackstatus127
-rwxr-xr-xmodules/sleep6
-rwxr-xr-xmodules/stream50
-rwxr-xr-xmodules/twitter5
-rwxr-xr-xmodules/wall2
-rwxr-xr-xmodules/zeit2
-rwxr-xr-xnoise25
17 files changed, 377 insertions, 20 deletions
diff --git a/TODO b/TODO
index f3c9b4ca..a20f74e9 100644
--- a/TODO
+++ b/TODO
@@ -1,8 +1,6 @@
#### file:noise/TODO
- /channels
-- /query NICK -- falls NICK gesetzt
- - /query ID -- sonst
- /hist N -- zum anzeigen von N letzten Nachrichten
- Log? Es werden maximal chat_histsize Zeilen gespeichert.
- Anbindung ans MoinMoin
@@ -42,14 +40,12 @@
broadcast to chat_channel that X has quit...
- split /twitter into /tweet and X, to make it clear when tweets are fired
- POP3 mail off googlemail and show them to curious telnetters
-
+- /set x 23 -> blah $x
- /rewrite -- e.g. /rewrite "!%s" "/play %s" oder sowasi
- Zugriff per ssh
-- /zeit Eins uhr
- module to standard unix-commands (name like /system)
- unix-commands should simply link to system
-- /unset
- /save TOKEN, /load TOKEN
- /op # NUR VIA SSH! (s.o.)
- MODULE-TEST-SUITE [blackbox]
@@ -59,5 +55,6 @@
- /help -> show all (main) modules
- /help MODULE -> show help of MODULE and show all sub-modules
- /help MODULE SUB-MODULE -> show help of SUB-MODULE and show all sub^2...
+- watchdog
#### end of file.
diff --git a/modules/cat b/modules/cat
new file mode 100755
index 00000000..e090acba
--- /dev/null
+++ b/modules/cat
@@ -0,0 +1,14 @@
+#! /bin/sh
+case "$1" in
+ (--help) : ;;
+ (*)
+ while read line ; do
+ case "$line" in
+ (/quit)
+ break 2
+ ;;
+ (*)
+ echo "[$line]"
+ esac
+ done
+esac
diff --git a/modules/ein_mal_eins b/modules/ein_mal_eins
new file mode 100755
index 00000000..1715eb3d
--- /dev/null
+++ b/modules/ein_mal_eins
@@ -0,0 +1,38 @@
+#! /bin/bash
+
+R() {
+ echo "`od -t d -N 1 /dev/urandom | sed -rn '1s/^[0-9]+ +//p'` % $@" | bc
+}
+
+
+
+
+case "$1" in
+ (--help) echo Stellt eine einfache Aufgabe ;;
+ (*)
+ a="`R 69`"
+ b="`R 69`"
+ op="`echo "\
+Was ist, A hoch B
+Was ist, A plus B
+Was ist, A minus B
+Was ist, A mal B
+Was ist, sinus von 0
+Was ist, Pi halbe mal 2
+Was ist, 2 hoch 8
+Was ist, 2 hoch 16
+Was ist, 2 hoch 32
+Was ist, 42 geteilt durch Pi mal 100
+Was ist, l n von 1
+Was ist, 42
+Was ist, 23
+Starte den Server neu
+Löte ein Kabel an einen Kompjuter
+Was ist, A geteilt durch B"`"
+ o="$(R `echo "$op" | wc -l` + 1)"
+
+ aufgabe=`echo "$op" | sed -n "$o{s/A/$a/;s/B/$b/;p}"`
+
+ echo "Löse die Aufgabe: $aufgabe?" |
+ espeak -v de --stdout | paplay
+esac
diff --git a/modules/espeak b/modules/espeak
index 1f5c901d..4aad90b9 100755
--- a/modules/espeak
+++ b/modules/espeak
@@ -18,7 +18,7 @@ case "$1" in
print_var amplitude $a
print_var gap $g
#echo "espeak -p \"$pitch\" -v \"$lang\" \"$*\"" >&2
- espeak -a $a -k $k -p $p -v $v -g $g<<EOF
+ (espeak --stdout -a $a -k $k -p $p -v $v -g $g | paplay)<<EOF
$*
EOF
esac
diff --git a/modules/help b/modules/help
index e9dba2fe..bc4c2931 100755
--- a/modules/help
+++ b/modules/help
@@ -4,7 +4,7 @@ case "$1" in
('') { for directory in `echo "$NOISE_PATH" | tr : \ ` ; do
for module in "$directory"/* ; do
echo `basename "$module"` `$module --help`
- done
+ done 2>/dev/null
done
## print all documented built-in commands
sed -rn 's:^noise_([a-z]+)\(\) \{ # (.+)?$:\1 \2:p' "$NOISE"
diff --git a/modules/mpc b/modules/mpc
index 6626532b..0ab72058 100755
--- a/modules/mpc
+++ b/modules/mpc
@@ -10,5 +10,5 @@ case "$1" in
##echo test-module called with following arguments: "$@"
## send command for re-evaluation:
##echo /espeak test >$NOISE_linefeed
- mpc $@
+ MPD_HOST=mpd.shack mpc $@
esac
diff --git a/modules/ping b/modules/ping
new file mode 100755
index 00000000..acf2529f
--- /dev/null
+++ b/modules/ping
@@ -0,0 +1,24 @@
+#! /bin/sh
+cd /tmp/noise
+case "$1" in
+ (--help) : ;;
+ ('')
+ . $NOISE_pid/environment
+ ping_timestamp=${ping_timestamp-0}
+ ping_challenger=${ping_challenger-0}
+ if test $ping_challenger != 0 ; then
+ echo There is already a ping challange running
+ else
+ timestamp=`date +%s%N`
+ for client in * ; do
+ echo /ping $NOISE_pid $timestamp >$client/linefeed &
+ done
+ fi
+ ;;
+ (*)
+ echo "/set -q ping_timestamp $2" >$NOISE_pid/linefeed
+ if test $NOISE_pid != $1 ; then
+ echo "/set -q ping_challenger $1" >$NOISE_pid/linefeed
+ echo "PING?"
+ fi
+esac
diff --git a/modules/play b/modules/play
index dcb8749f..749b450a 100755
--- a/modules/play
+++ b/modules/play
@@ -22,9 +22,13 @@ case "$1" in
esac && break
done || cat<<EOF
\
-Keine Audiodatei mit dem Namen $1.EXT gefunden... \
-am besten gleich uploaden:
-$ scp NAME $LOGNAME@shack:noise/samples/
+Keine Audiodatei mit dem Namen
+
+ $1.EXT
+
+gefunden... am besten gleich uploaden:
+
+ scp NAME shack@shack.shack:noise/samples/
folgende Dateiendungen werden erkannt: $ffs
EOF
diff --git a/modules/pong b/modules/pong
new file mode 100755
index 00000000..eb2df46d
--- /dev/null
+++ b/modules/pong
@@ -0,0 +1,26 @@
+#! /bin/sh
+cd /tmp/noise
+case "$1" in
+ (--help) : ;;
+ ('')
+ . $NOISE_pid/environment
+ ping_timestamp=${ping_timestamp-0}
+ ping_challenger=${ping_challenger-0}
+ if test $ping_challenger = 0 ; then
+ echo There is no ping challange running
+ else
+ timestamp=`date +%s%N`
+ echo /pong $NOISE_pid $timestamp >$ping_challenger/linefeed
+ ## reset ping TODO /unset
+ echo /set -q ping_timestamp 0 >$NOISE_pid/linefeed
+ echo /set -q ping_challenger 0 >$NOISE_pid/linefeed
+ fi
+ ;;
+ (*)
+ . $1/environment
+ # XXX is attendee the right counterpart to 'challenger'?
+ attendee_nick=$chat_nick
+ . $NOISE_pid/environment
+ time=`echo "scale=3; ($2 - $ping_timestamp)/10^9" | bc`
+ echo "PONG! $attendee_nick ${time}s"
+esac
diff --git a/modules/sendmail b/modules/sendmail
new file mode 100755
index 00000000..182d96e3
--- /dev/null
+++ b/modules/sendmail
@@ -0,0 +1,55 @@
+#!/usr/bin/python
+import os,sys,smtplib,string
+'''
+ Mail Plugin for the noise telnet suite
+ See: http://docs.python.org/library/smtplib.html
+ Author: Felix
+'''
+
+# help
+if len(sys.argv) == 2:
+ if sys.argv[1] == "--help":
+ print "send an e-mail ( \"TO(s)\" \"SUBJECT\" [string instead of EOF])"
+ sys.exit(0)
+
+# sanity
+if len(sys.argv) <= 2:
+ print "wrong number of parameters, see help"
+ sys.exit(1)
+
+# write variables
+# check of EOF
+if len(sys.argv) == 4 :
+ EOFstring="%s\n"% sys.argv[3]
+else:
+ EOFstring="EOF\n"
+
+fromaddr=u"Karl Koch<shockspasm@googlemail.com>"
+toaddrs=sys.argv[1]
+subject=sys.argv[2]
+
+
+#write header:
+msg = u"From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n" % (fromaddr, toaddrs,subject)
+print "Write your text now, finish with %s" % EOFstring
+sys.stdout.flush() # flushing is important to make sure the line is written
+
+while 1:
+ try:
+ line = sys.stdin.readline()
+ if line == EOFstring:
+ break
+ msg = msg + line
+ except EOFError:
+ break
+
+msg = msg + "[!] Written with NOISE telnet"
+
+print "Thank you for your message! Delivering it now..."
+sys.stdout.flush()
+server = smtplib.SMTP('localhost')
+#server.set_debuglevel(1)
+server.sendmail(fromaddr,toaddrs.split(','),msg)
+server.quit()
+print "mail send successfully"
+sys.exit(0)
diff --git a/modules/shackstatus b/modules/shackstatus
new file mode 100755
index 00000000..d05dba87
--- /dev/null
+++ b/modules/shackstatus
@@ -0,0 +1,127 @@
+#! /bin/bash
+inputdir=$HOME/noise/streams
+
+speak () {
+ echo "$@" >> $NOISE_linefeed
+}
+
+wochentag () {
+ case $(date +%a) in
+ Mon) echo Montag ;;
+ Tue) echo Dienstag ;;
+ Wed) echo Mittwoch ;;
+ Thu) echo Donnerstag ;;
+ Fri) echo Freitag ;;
+ Sat) echo Samstag ;;
+ Sun) echo Sonntag ;;
+ esac
+}
+
+tag () {
+ case $(date +%d) in
+ 1) echo erste ;;
+ 2) echo zweite ;;
+ 3) echo dritte ;;
+ 4) echo vierte ;;
+ 5) echo fünfte ;;
+ 6) echo sechste ;;
+ 7) echo siebte ;;
+ 8) echo achte ;;
+ 9) echo neunte ;;
+ 10) echo zehnte ;;
+ 11) echo elfte ;;
+ 12) echo zwölfte ;;
+ 13) echo dreizehnte ;;
+ 14) echo vierzehnte ;;
+ 15) echo fünfzehnte ;;
+ 16) echo sechzehnte ;;
+ 17) echo siebzehnte ;;
+ 18) echo achtzehnte ;;
+ 19) echo neunzehnte ;;
+ 20) echo zwanzigste ;;
+ 21) echo einundzwanzigste ;;
+ 22) echo zweiundzwanzigste ;;
+ 23) echo dreiundzwanzigste ;;
+ 24) echo vierundzwanzigste ;;
+ 25) echo füfundzwanzigste ;;
+ 26) echo sechsundzwanzigste ;;
+ 27) echo siebenundzwanzigste ;;
+ 28) echo achtundzwanzigste ;;
+ 29) echo neunundzwanzigste ;;
+ 30) echo dreissigste ;;
+ 31) echo einunddreissigste ;;
+ esac
+}
+
+monat () {
+ case $(date +%b) in
+ Jan) echo Januar ;;
+ Feb) echo Februar ;;
+ Mar) echo März ;;
+ Apr) echo April ;;
+ May) echo Mai ;;
+ Jun) echo Juni ;;
+ Jul) echo Juli ;;
+ Aug) echo August ;;
+ Sep) echo September ;;
+ Oct) echo Oktober ;;
+ Nov) echo November ;;
+ Dec) echo Dezember ;;
+ esac
+}
+
+case "$1" in
+ (--help)
+ echo "report status of all shack services."
+ ;;
+ (*)
+# just a multiline comment
+cat << EOF > /dev/null
+ /set pitch 10
+ /espeak Hallo. Krietscher hat seinen Meister vermisst.
+ /espeak Heute ist `wochentag`, der `tag` --- `monat` -- `date +%Y`
+ /zeit
+ /espeak check der systeme:
+ /espeak Energie versorgung -- aktiv
+ /espeak schäckhost -- läuft
+ /espeak telnet -- läuft
+ /espeak interner - de - enn -- es, interne domein -- $STAT_DNS_I
+ /espeak interner - de - enn -- es, externe domein -- $STAT_DNS_E
+ /espeak externer - de - enn -- es - $STAT_DNS_X
+ /espeak Leitungsqualität - $STAT_LINE prozent.
+ /espeak Die Aussen temper atur beträgt $STAT_TEMP
+ /espeak Willkommen zu Hause, -- Meister
+EOF
+
+[ $( dig +short localhost @10.42.0.10 ) = "127.0.0.1" ] && STAT_DNS_I="läuft" || STAT_DNS_I="antwortet nicht"
+[ $( dig +short shackspace.de @10.42.0.10 ) = "141.31.176.214" ] && STAT_DNS_E="läuft"|| STAT_DNS_E="antwortet nicht"
+[ $( dig +short shackspace.de @141.31.176.214 ) = "141.31.176.214" ] && STAT_DNS_X="läuft"|| STAT_DNS_X="antwortet nicht"
+
+STAT_LINE=$( ping -c 5 -i 0.2 -q 141.31.176.214 | awk '/packet loss/ { print 100-$6}' )
+STAT_TEMP=$( dig +short txt outside.elwood.temp.citecs.de |
+ sed 's/^"DEG //;
+ s/"$//;
+ s/^-/minus /;
+ s/\./ komma /;
+ s/\(.\)$/ \1 grad zelsius/
+ '
+)
+
+cat <<-EOF >> $NOISE_linefeed
+ /set pitch 10
+ /espeak Hallo. Krietscher hat seinen Meister vermisst.
+ /espeak Heute ist `wochentag`, der `tag` --- `monat` -- `date +%Y`
+ /zeit
+ /espeak check der systeme:
+ /espeak Energie versorgung -- aktiv
+ /espeak schäckhost -- läuft
+ /espeak telnet -- läuft
+ /espeak interner - de - enn -- es, interne domein -- $STAT_DNS_I
+ /espeak interner - de - enn -- es, externe domein -- $STAT_DNS_E
+ /espeak externer - de - enn -- es - $STAT_DNS_X
+ /espeak Leitungsqualität - $STAT_LINE prozent.
+ /espeak Die Aussen temper atur beträgt $STAT_TEMP
+ /espeak Willkommen zu Hause, -- Meister
+EOF
+ ;;
+esac 2>&1
diff --git a/modules/sleep b/modules/sleep
index b8d350f7..89712cac 100755
--- a/modules/sleep
+++ b/modules/sleep
@@ -2,9 +2,9 @@
case "$1" in
(--help) echo "pause for NUMBER seconds" ;;
(*)
- if ! echo "$1" | grep -Eq '^([0-9]+(\.[0-9]*)?|[0-9]*\.[0-9]+)$' ; then
- echo 'FAIL: $1 is not a number'
- else
+ if echo "$1" | grep -Eq '^([0-9]+(\.[0-9]*)?|[0-9]*\.[0-9]+)$' ; then
sleep "$1"
+ else
+ echo 'FAIL: $1 is not a number'
fi
esac
diff --git a/modules/stream b/modules/stream
new file mode 100755
index 00000000..76e86317
--- /dev/null
+++ b/modules/stream
@@ -0,0 +1,50 @@
+#! /bin/sh
+inputdir=$HOME/noise/streams
+case "$1" in
+ (--help)
+ echo "play an audio stream" ;;
+ (*)
+ exec 2>&1
+ ffs='xml'
+
+ if test -z "$*" ; then
+ echo -e "\x1B[32m/stream off \x1B[33m- turn stream off\x1B[m"
+ for i in `ls $inputdir` ; do
+ filename="$inputdir/$i"
+ shortcut=`xmlstarlet sel -t -v /station/@shortcut "$inputdir/$i"`
+ title=`xmlstarlet sel -t -v /station/@title "$inputdir/$i"`
+ topic=`xmlstarlet sel -t -v /station/@topic "$inputdir/$i"`
+ stream=`xmlstarlet sel -t -v /station/@stream "$inputdir/$i"`
+ echo -e "\x1B[32m/stream $shortcut \x1B[33m- $title \x1B[35m$topic\x1B[m"
+ done
+ else if [ "$1" = "off" ]; then
+ [ ! -d /tmp/noise ] || ( echo "no directory /tmp/noise; aborting" ; exit 1 )
+ [ -f /tmp/noise/stream.pid ] && ( kill ` cat /tmp/noise/stream.pid ` )
+ [ -e /tmp/noise/stream.pid ] && rm /tmp/noise/stream.pid || ( echo "can't remove /tmp/noise/stream.pid; aborting" ; exit 1 )
+ else
+ for i in `ls $inputdir` ; do
+ filename="$inputdir/$i"
+ shortcut=`xmlstarlet sel -t -v /station/@shortcut "$inputdir/$i"`
+ stream=`xmlstarlet sel -t -v /station/@stream "$inputdir/$i"`
+ if [ "$shortcut" == "$1" ]; then
+ [ ! -d /tmp/noise ] || ( umask 077 ; mkdir /tmp/noise ) || ( echo "can't create /tmp/noise; aborting" ; exit 1 )
+ [ -f /tmp/noise/stream.pid ] && ( kill ` cat /tmp/noise/stream.pid ` )
+ [ -e /tmp/noise/stream.pid ] && rm /tmp/noise/stream.pid || ( echo "can't remove /tmp/noise/stream.pid; aborting" ; exit 1 )
+ mplayer -cache 2048 -quiet "$stream" &
+ ( umask 077 ; echo $! > /tmp/noise/stream.pid )
+ break
+ fi
+ done || cat<<EOF
+\
+Keine Audiostreambeschreibung mit dem Namen
+
+ $1.EXT
+
+gefunden... am besten gleich anlegen:
+
+ ssh shack@shack.shack:noise/streams/
+
+folgende Dateiendungen werden erkannt: $ffs
+EOF
+ fi fi
+esac
diff --git a/modules/twitter b/modules/twitter
index 49d092fb..5b1b0be9 100755
--- a/modules/twitter
+++ b/modules/twitter
@@ -1,6 +1,10 @@
#!/usr/bin/python
#encode=utf8
+print "Bug Robert to implement Twitter-OAuth!"
+exit(1)
+
+
import sys, twitter
sys.stderr = sys.stdout
@@ -57,7 +61,6 @@ if len(sys.argv) > 1 and sys.argv[1] == "--help":
-
api = twitter.Api(username="shackspam", password="sh4ckit")
#api.SetXTwitterHeaders("Shackspace UTTERANCE","","0.00.0.01.42")
diff --git a/modules/wall b/modules/wall
index 7c32d01d..c73744ea 100755
--- a/modules/wall
+++ b/modules/wall
@@ -3,6 +3,6 @@ case "$1" in
(--help) : ;;
(?*)
for linefeed in /tmp/noise/*/linefeed ; do
- echo /msg "$*" >$linefeed
+ echo /echo "$*" >$linefeed
done
esac
diff --git a/modules/zeit b/modules/zeit
index 4c41fa10..9fbc33e4 100755
--- a/modules/zeit
+++ b/modules/zeit
@@ -5,7 +5,7 @@ case "$1" in
echo "say current time" ;;
(*)
exec >>$NOISE_linefeed
- k=`date +%k`
+ k=`date +%k|sed 's/^[[:space:]]*1[[:space:]]*$/ein/'`
M=`date +%M|sed 's/0*//'`
echo /set pitch 10
case "$lang" in
diff --git a/noise b/noise
index 9d4f815f..c410168c 100755
--- a/noise
+++ b/noise
@@ -39,6 +39,22 @@ noise_set() { # set a variable
esac
}
+noise_unset() { # unset a variable
+ case "$1" in
+ (-q|--quiet) echo=: ; shift ;;
+ (*) echo=echo ;;
+ esac
+ case $# in
+ (1) ##
+ unset "noise_$1"
+ sed -ni "/^$1=/!p" $env
+ ;;
+ (*)
+ fail "broken commandline: $@"
+ ;;
+ esac
+}
+
noise_quit() { # exit
echo "Good bye!"
exit
@@ -56,7 +72,7 @@ cleanup() {
rmdir /tmp/noise 2>/dev/null
}
-
+exec 2>&1
qname="`readlink -f "$0"`"
dirname="`dirname "$qname"`"
export HOME='/home/shack'
@@ -64,7 +80,7 @@ if test -d "$dirname/modules" ; then
export NOISE_PATH="${NOISE_PATH+$NOISE_PATH:}$dirname/modules"
export NOISE_PATH="${NOISE_PATH+$NOISE_PATH:}$HOME/noise/modules"
fi
-mkdir -vp /tmp/noise/$$
+mkdir -p /tmp/noise/$$
linefeed="/tmp/noise/$$/linefeed"
env="/tmp/noise/$$/environment"
trap cleanup EXIT
@@ -111,7 +127,10 @@ jobs="${jobs+$jobs }`jobs -p`"
##
cat<<EOF
Welcome to 23.shack version 0.9 beta 4 \
-commit `cat $dirname/.git/refs/heads/master | dd count=23 bs=1`...
+commit `
+ cd $dirname &&
+ git log -n 1 | head -n 1 | cut -d\ -f 2 | dd count=23 bs=1 2>/dev/null
+`...

## Motto Of The Day\