From 4b65c37645b6b72a0531fbbdb75310bf93ee99de Mon Sep 17 00:00:00 2001 From: root Date: Thu, 5 May 2011 09:38:59 +0200 Subject: modules/noise: prepare for import to krebscode --- modules/cat | 14 --- modules/chat | 33 ------ modules/date | 6 -- modules/echo | 6 -- modules/ein_mal_eins | 37 ------- modules/espeak | 34 ------- modules/help | 24 ----- modules/join | 15 --- modules/lang | 22 ---- modules/mpc | 14 --- modules/names | 22 ---- modules/nick | 10 -- modules/noise/TODO | 60 +++++++++++ modules/noise/cron/bin/zeit | 16 +++ modules/noise/init.d/noise | 48 +++++++++ modules/noise/modules/cat | 14 +++ modules/noise/modules/chat | 33 ++++++ modules/noise/modules/date | 6 ++ modules/noise/modules/echo | 6 ++ modules/noise/modules/ein_mal_eins | 37 +++++++ modules/noise/modules/espeak | 34 +++++++ modules/noise/modules/help | 24 +++++ modules/noise/modules/join | 15 +++ modules/noise/modules/lang | 22 ++++ modules/noise/modules/mpc | 14 +++ modules/noise/modules/names | 22 ++++ modules/noise/modules/nick | 10 ++ modules/noise/modules/part | 15 +++ modules/noise/modules/ping | 24 +++++ modules/noise/modules/play | 36 +++++++ modules/noise/modules/pong | 26 +++++ modules/noise/modules/query | 23 +++++ modules/noise/modules/send_to_channel | 17 ++++ modules/noise/modules/sendmail | 55 ++++++++++ modules/noise/modules/shackstatus | 104 +++++++++++++++++++ modules/noise/modules/sleep | 10 ++ modules/noise/modules/stream | 64 ++++++++++++ modules/noise/modules/temp | 56 +++++++++++ modules/noise/modules/test | 13 +++ modules/noise/modules/twitter | 125 +++++++++++++++++++++++ modules/noise/modules/vvs | 17 ++++ modules/noise/modules/wall | 8 ++ modules/noise/modules/zeit | 19 ++++ modules/noise/noise | 182 ++++++++++++++++++++++++++++++++++ modules/noise/noise-as-user | 4 + modules/noise/noise-server | 4 + modules/part | 15 --- modules/ping | 24 ----- modules/play | 36 ------- modules/pong | 26 ----- modules/query | 23 ----- modules/send_to_channel | 17 ---- modules/sendmail | 55 ---------- modules/shackstatus | 104 ------------------- modules/sleep | 10 -- modules/stream | 64 ------------ modules/temp | 56 ----------- modules/test | 13 --- modules/twitter | 125 ----------------------- modules/vvs | 17 ---- modules/wall | 8 -- modules/zeit | 19 ---- 62 files changed, 1163 insertions(+), 849 deletions(-) delete mode 100755 modules/cat delete mode 100755 modules/chat delete mode 100755 modules/date delete mode 100755 modules/echo delete mode 100755 modules/ein_mal_eins delete mode 100755 modules/espeak delete mode 100755 modules/help delete mode 100755 modules/join delete mode 100755 modules/lang delete mode 100755 modules/mpc delete mode 100755 modules/names delete mode 100755 modules/nick create mode 100644 modules/noise/TODO create mode 100755 modules/noise/cron/bin/zeit create mode 100755 modules/noise/init.d/noise create mode 100755 modules/noise/modules/cat create mode 100755 modules/noise/modules/chat create mode 100755 modules/noise/modules/date create mode 100755 modules/noise/modules/echo create mode 100755 modules/noise/modules/ein_mal_eins create mode 100755 modules/noise/modules/espeak create mode 100755 modules/noise/modules/help create mode 100755 modules/noise/modules/join create mode 100755 modules/noise/modules/lang create mode 100755 modules/noise/modules/mpc create mode 100755 modules/noise/modules/names create mode 100755 modules/noise/modules/nick create mode 100755 modules/noise/modules/part create mode 100755 modules/noise/modules/ping create mode 100755 modules/noise/modules/play create mode 100755 modules/noise/modules/pong create mode 100755 modules/noise/modules/query create mode 100755 modules/noise/modules/send_to_channel create mode 100755 modules/noise/modules/sendmail create mode 100755 modules/noise/modules/shackstatus create mode 100755 modules/noise/modules/sleep create mode 100755 modules/noise/modules/stream create mode 100755 modules/noise/modules/temp create mode 100755 modules/noise/modules/test create mode 100755 modules/noise/modules/twitter create mode 100755 modules/noise/modules/vvs create mode 100755 modules/noise/modules/wall create mode 100755 modules/noise/modules/zeit create mode 100755 modules/noise/noise create mode 100755 modules/noise/noise-as-user create mode 100755 modules/noise/noise-server delete mode 100755 modules/part delete mode 100755 modules/ping delete mode 100755 modules/play delete mode 100755 modules/pong delete mode 100755 modules/query delete mode 100755 modules/send_to_channel delete mode 100755 modules/sendmail delete mode 100755 modules/shackstatus delete mode 100755 modules/sleep delete mode 100755 modules/stream delete mode 100755 modules/temp delete mode 100755 modules/test delete mode 100755 modules/twitter delete mode 100755 modules/vvs delete mode 100755 modules/wall delete mode 100755 modules/zeit (limited to 'modules') diff --git a/modules/cat b/modules/cat deleted file mode 100755 index e090acba..00000000 --- a/modules/cat +++ /dev/null @@ -1,14 +0,0 @@ -#! /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/chat b/modules/chat deleted file mode 100755 index e5badc36..00000000 --- a/modules/chat +++ /dev/null @@ -1,33 +0,0 @@ -#! /bin/sh - -case "$1" in - (--help) echo send text to everyone with @@ prepended ;; - (/nick) - echo set nick to $2 - echo /set chat_nick $2 >$NOISE_linefeed;; - (/names) - cd /tmp/noise - . $NOISE_pid/environment - nick="${chat_nick-$NOISE_pid}" - channel="$chat_channel" - echo "Users in channel $channel" - for client in * ; do - . $client/environment - chat_nick="${chat_nick-$client}" - if test "$channel" = "$chat_channel" && test "$default_command" = chat ; then - echo "$chat_nick" - fi - unset chat_nick - unset chat_channel - unset default_command - done ;; - (*) - cd /tmp/noise - . $NOISE_pid/environment - nick="${chat_nick-$NOISE_pid}" - - echo "/send_to_channel $chat_channel $nick: $*" > $NOISE_linefeed - - - #echo /wall @@ $* >$NOISE_linefeed -esac diff --git a/modules/date b/modules/date deleted file mode 100755 index 8cd1b0c1..00000000 --- a/modules/date +++ /dev/null @@ -1,6 +0,0 @@ -#! /bin/sh -case "$1" in - (--help) : ;; - (*) - date --rfc-3339=s -esac diff --git a/modules/echo b/modules/echo deleted file mode 100755 index 344dd963..00000000 --- a/modules/echo +++ /dev/null @@ -1,6 +0,0 @@ -#! /bin/sh -case "$1" in - (--help) : ;; - (*) - echo "$*" -esac diff --git a/modules/ein_mal_eins b/modules/ein_mal_eins deleted file mode 100755 index fb385b31..00000000 --- a/modules/ein_mal_eins +++ /dev/null @@ -1,37 +0,0 @@ -#! /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 "/espeak -v Löse die Aufgabe: $aufgabe?" >$NOISE_linefeed -esac diff --git a/modules/espeak b/modules/espeak deleted file mode 100755 index 4e88918f..00000000 --- a/modules/espeak +++ /dev/null @@ -1,34 +0,0 @@ -#! /bin/sh - -print_var() { - echo "$1 = $2" -} - -speak() { - p="${noise_pitch-100}" - v="${noise_lang-de}" - k="${noise_capital-0}" - a="${noise_amplitude-100}" - g="${noise_gap-1}" - if test "$debug" = true; then - print_var pitch $p - print_var lang $v - print_var capital $k - print_var amplitude $a - print_var gap $g - fi - if test "$verbose" = true; then - echo "espeak: $@" - fi - #echo "espeak -p \"$pitch\" -v \"$lang\" \"$*\"" >&2 - (espeak --stdout -a $a -k $k -p $p -v $v -g $g | aplay -Dplug:default)</dev/null - done - ## print all documented built-in commands - sed -rn 's:^noise_([a-z]+)\(\) \{ # (.+)?$:\1 \2:p' "$NOISE" - } | sort | uniq | sed -rn ' - $s/$// - s:^([a-z]+) (.+):type /\1 to \2:p' ;; - (*) - ## call - for directory in `echo "$NOISE_PATH" | tr : \ ` ; do - for module in "$directory/$1" ; do - if test -e $module ; then - shift - exec $module --help --verbose "$@" 2>&1 - fi - done - done -esac diff --git a/modules/join b/modules/join deleted file mode 100755 index 68afcb66..00000000 --- a/modules/join +++ /dev/null @@ -1,15 +0,0 @@ -#! /bin/sh - -case "$1" in - (--help) echo set default_command to chat and join channel ;; - (*) - . /tmp/noise/$NOISE_pid/environment - nick="${chat_nick-$NOISE_pid}" - echo /send_to_channel "${1-#23}" "$nick" joined the channel >$NOISE_linefeed - echo /set default_command chat >$NOISE_linefeed - echo /set chat_channel "${1-#23}" >$NOISE_linefeed - echo " joined channel ${1-#23}" - echo /part to go back to espeak ;; - - -esac diff --git a/modules/lang b/modules/lang deleted file mode 100755 index 07b6802e..00000000 --- a/modules/lang +++ /dev/null @@ -1,22 +0,0 @@ -#! /bin/sh - -case "$1" in - (--help) - echo "set language or list available languages" ;; - (list) - espeak --voices | sed -n '1!p' | awk '{\ - printf"/lang %s set lang to %s\n",$2,$4 - }' ;; - ('') - echo /set lang >$NOISE_linefeed ;; - (*) - if test -z "$2" ; then - echo /set lang "$1" - else - echo /set lang "$1" - shift - echo "$*" - echo /set lang "${noise_lang-de}" - fi >$NOISE_linefeed -esac - diff --git a/modules/mpc b/modules/mpc deleted file mode 100755 index 0ab72058..00000000 --- a/modules/mpc +++ /dev/null @@ -1,14 +0,0 @@ -#! /bin/sh - -case "$1" in - (--help) - case "$2" in - (--verbose) mpc --help ;; - (*) echo access mpd - esac ;; - (*) - ##echo test-module called with following arguments: "$@" - ## send command for re-evaluation: - ##echo /espeak test >$NOISE_linefeed - MPD_HOST=mpd.shack mpc $@ -esac diff --git a/modules/names b/modules/names deleted file mode 100755 index f5922064..00000000 --- a/modules/names +++ /dev/null @@ -1,22 +0,0 @@ -#! /bin/sh - -case "$1" in - (--help) echo send text to everyone with @@ prepended ;; - (*) - cd /tmp/noise - . $NOISE_pid/environment - if test "$default_command" != chat ; then exit ; fi - nick="${chat_nick-$NOISE_pid}" - channel="${1-$chat_channel}" - echo "Users in channel $channel" - for client in * ; do - . $client/environment - chat_nick="${chat_nick-$client}" - if test "$channel" = "$chat_channel" && test "$default_command" = chat ; then - echo "$chat_nick" - fi - unset chat_nick - unset chat_channel - unset default_command - done -esac diff --git a/modules/nick b/modules/nick deleted file mode 100755 index 5ed1e9d9..00000000 --- a/modules/nick +++ /dev/null @@ -1,10 +0,0 @@ -#! /bin/sh - -case "$1" in - (--help) echo send text to everyone with @@ prepended ;; - (*) - . /tmp/noise/$NOISE_pid/environment - nick="${chat_nick-$NOISE_pid}" - echo /send_to_channel $chat_channel $nick is now known as $1 > $NOISE_linefeed - echo /set chat_nick $1 >$NOISE_linefeed;; -esac diff --git a/modules/noise/TODO b/modules/noise/TODO new file mode 100644 index 00000000..a20f74e9 --- /dev/null +++ b/modules/noise/TODO @@ -0,0 +1,60 @@ +#### file:noise/TODO + +- /channels +- /hist N -- zum anzeigen von N letzten Nachrichten + - Log? Es werden maximal chat_histsize Zeilen gespeichert. +- Anbindung ans MoinMoin +- IRC <-> 23.shack - Brücke +- when nick changes say "You're now known as XXX" to yourself +- twitter: push new tweets as they arrive to all connected clients with + the variable tweet_me set to ON + +- Author, Maintainer etc. direkt in die Module in der erweiterten Hilfe, also + in /help MODULENAME -> man sollte sich auf ein einheitliches Dokmentierungs- + Format einigen. + - All modules should contain: + - Author(s) w/ e-mail, Copyright, License + - Maintainer(s) w/ e-mail + - Module-Version + - last tested System-Version + - we need to export the system version +- GIT commits tweeten (shack und root) +- /kick [CHANNEL] # from channel / telnet +- /ban # :-) +- /op +- USER-A: /ping USER-B + - USER-B: /pong + - write time to USER-{A,B} +- style-sheets for everything MOAR!!1 +- libraries +- HTTP-interface +- /whois, /whoami, /whowas +- join,part&co. should support multiple channels +- /TODO,/bug,/issue or something should be added as tracking-system +- /part should say something like "X has left." +- /join should say something like "X has joined." + # it's obvious that the channels is meant... + - or else say: "X has joined channel Y." when we can join more than one + channel +- /part should unset chat_channel (somehow) else keeping /part'ing will + 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 +- module to standard unix-commands (name like /system) + - unix-commands should simply link to system +- /save TOKEN, /load TOKEN +- /op # NUR VIA SSH! (s.o.) +- MODULE-TEST-SUITE [blackbox] +- sub-modules like /chat-join which may be abbreviated as /join when + $default_command is set to /chat, YAY + - unclutter /help: + - /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/noise/cron/bin/zeit b/modules/noise/cron/bin/zeit new file mode 100755 index 00000000..ec50c898 --- /dev/null +++ b/modules/noise/cron/bin/zeit @@ -0,0 +1,16 @@ +#! /bin/sh + +expect >/dev/null <$NOISE_linefeed;; + (/names) + cd /tmp/noise + . $NOISE_pid/environment + nick="${chat_nick-$NOISE_pid}" + channel="$chat_channel" + echo "Users in channel $channel" + for client in * ; do + . $client/environment + chat_nick="${chat_nick-$client}" + if test "$channel" = "$chat_channel" && test "$default_command" = chat ; then + echo "$chat_nick" + fi + unset chat_nick + unset chat_channel + unset default_command + done ;; + (*) + cd /tmp/noise + . $NOISE_pid/environment + nick="${chat_nick-$NOISE_pid}" + + echo "/send_to_channel $chat_channel $nick: $*" > $NOISE_linefeed + + + #echo /wall @@ $* >$NOISE_linefeed +esac diff --git a/modules/noise/modules/date b/modules/noise/modules/date new file mode 100755 index 00000000..8cd1b0c1 --- /dev/null +++ b/modules/noise/modules/date @@ -0,0 +1,6 @@ +#! /bin/sh +case "$1" in + (--help) : ;; + (*) + date --rfc-3339=s +esac diff --git a/modules/noise/modules/echo b/modules/noise/modules/echo new file mode 100755 index 00000000..344dd963 --- /dev/null +++ b/modules/noise/modules/echo @@ -0,0 +1,6 @@ +#! /bin/sh +case "$1" in + (--help) : ;; + (*) + echo "$*" +esac diff --git a/modules/noise/modules/ein_mal_eins b/modules/noise/modules/ein_mal_eins new file mode 100755 index 00000000..fb385b31 --- /dev/null +++ b/modules/noise/modules/ein_mal_eins @@ -0,0 +1,37 @@ +#! /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 "/espeak -v Löse die Aufgabe: $aufgabe?" >$NOISE_linefeed +esac diff --git a/modules/noise/modules/espeak b/modules/noise/modules/espeak new file mode 100755 index 00000000..4e88918f --- /dev/null +++ b/modules/noise/modules/espeak @@ -0,0 +1,34 @@ +#! /bin/sh + +print_var() { + echo "$1 = $2" +} + +speak() { + p="${noise_pitch-100}" + v="${noise_lang-de}" + k="${noise_capital-0}" + a="${noise_amplitude-100}" + g="${noise_gap-1}" + if test "$debug" = true; then + print_var pitch $p + print_var lang $v + print_var capital $k + print_var amplitude $a + print_var gap $g + fi + if test "$verbose" = true; then + echo "espeak: $@" + fi + #echo "espeak -p \"$pitch\" -v \"$lang\" \"$*\"" >&2 + (espeak --stdout -a $a -k $k -p $p -v $v -g $g | aplay -Dplug:default)</dev/null + done + ## print all documented built-in commands + sed -rn 's:^noise_([a-z]+)\(\) \{ # (.+)?$:\1 \2:p' "$NOISE" + } | sort | uniq | sed -rn ' + $s/$// + s:^([a-z]+) (.+):type /\1 to \2:p' ;; + (*) + ## call + for directory in `echo "$NOISE_PATH" | tr : \ ` ; do + for module in "$directory/$1" ; do + if test -e $module ; then + shift + exec $module --help --verbose "$@" 2>&1 + fi + done + done +esac diff --git a/modules/noise/modules/join b/modules/noise/modules/join new file mode 100755 index 00000000..68afcb66 --- /dev/null +++ b/modules/noise/modules/join @@ -0,0 +1,15 @@ +#! /bin/sh + +case "$1" in + (--help) echo set default_command to chat and join channel ;; + (*) + . /tmp/noise/$NOISE_pid/environment + nick="${chat_nick-$NOISE_pid}" + echo /send_to_channel "${1-#23}" "$nick" joined the channel >$NOISE_linefeed + echo /set default_command chat >$NOISE_linefeed + echo /set chat_channel "${1-#23}" >$NOISE_linefeed + echo " joined channel ${1-#23}" + echo /part to go back to espeak ;; + + +esac diff --git a/modules/noise/modules/lang b/modules/noise/modules/lang new file mode 100755 index 00000000..07b6802e --- /dev/null +++ b/modules/noise/modules/lang @@ -0,0 +1,22 @@ +#! /bin/sh + +case "$1" in + (--help) + echo "set language or list available languages" ;; + (list) + espeak --voices | sed -n '1!p' | awk '{\ + printf"/lang %s set lang to %s\n",$2,$4 + }' ;; + ('') + echo /set lang >$NOISE_linefeed ;; + (*) + if test -z "$2" ; then + echo /set lang "$1" + else + echo /set lang "$1" + shift + echo "$*" + echo /set lang "${noise_lang-de}" + fi >$NOISE_linefeed +esac + diff --git a/modules/noise/modules/mpc b/modules/noise/modules/mpc new file mode 100755 index 00000000..0ab72058 --- /dev/null +++ b/modules/noise/modules/mpc @@ -0,0 +1,14 @@ +#! /bin/sh + +case "$1" in + (--help) + case "$2" in + (--verbose) mpc --help ;; + (*) echo access mpd + esac ;; + (*) + ##echo test-module called with following arguments: "$@" + ## send command for re-evaluation: + ##echo /espeak test >$NOISE_linefeed + MPD_HOST=mpd.shack mpc $@ +esac diff --git a/modules/noise/modules/names b/modules/noise/modules/names new file mode 100755 index 00000000..f5922064 --- /dev/null +++ b/modules/noise/modules/names @@ -0,0 +1,22 @@ +#! /bin/sh + +case "$1" in + (--help) echo send text to everyone with @@ prepended ;; + (*) + cd /tmp/noise + . $NOISE_pid/environment + if test "$default_command" != chat ; then exit ; fi + nick="${chat_nick-$NOISE_pid}" + channel="${1-$chat_channel}" + echo "Users in channel $channel" + for client in * ; do + . $client/environment + chat_nick="${chat_nick-$client}" + if test "$channel" = "$chat_channel" && test "$default_command" = chat ; then + echo "$chat_nick" + fi + unset chat_nick + unset chat_channel + unset default_command + done +esac diff --git a/modules/noise/modules/nick b/modules/noise/modules/nick new file mode 100755 index 00000000..5ed1e9d9 --- /dev/null +++ b/modules/noise/modules/nick @@ -0,0 +1,10 @@ +#! /bin/sh + +case "$1" in + (--help) echo send text to everyone with @@ prepended ;; + (*) + . /tmp/noise/$NOISE_pid/environment + nick="${chat_nick-$NOISE_pid}" + echo /send_to_channel $chat_channel $nick is now known as $1 > $NOISE_linefeed + echo /set chat_nick $1 >$NOISE_linefeed;; +esac diff --git a/modules/noise/modules/part b/modules/noise/modules/part new file mode 100755 index 00000000..d35ac501 --- /dev/null +++ b/modules/noise/modules/part @@ -0,0 +1,15 @@ +#! /bin/sh + +case "$1" in + (--help) echo leave chat mode ;; + (*) + . /tmp/noise/$NOISE_pid/environment + nick="${chat_nick-$NOISE_pid}" + + echo "/send_to_channel $chat_channel $nick has quit ${*-no reason}" > $NOISE_linefeed + + echo /set default_command espeak >$NOISE_linefeed + echo "disabled chat mode (set back to espeak)" ;; + + +esac diff --git a/modules/noise/modules/ping b/modules/noise/modules/ping new file mode 100755 index 00000000..acf2529f --- /dev/null +++ b/modules/noise/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/noise/modules/play b/modules/noise/modules/play new file mode 100755 index 00000000..749b450a --- /dev/null +++ b/modules/noise/modules/play @@ -0,0 +1,36 @@ +#! /bin/sh +case "$1" in + (--help) + echo "play an audio file" ;; + (*) + exec 2>&1 + ffs='wav mp3 ogg asf flac' + + if test -z "$*" ; then + ls $HOME/noise/samples | sed -r ' + s:\.('"`echo "$ffs" | tr \ \|`"')$: \1: + s:^:/play : + s:.*:&: + ' + else + for i in $ffs ; do + f=$HOME/noise/samples/$1.$i + test -f "$f" && + case "$i" in + wav) aplay "$f" & ;; + *) mplayer "$f" & ;; + esac && break + done || cat<$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/noise/modules/query b/modules/noise/modules/query new file mode 100755 index 00000000..ceeff8a5 --- /dev/null +++ b/modules/noise/modules/query @@ -0,0 +1,23 @@ +#! /bin/sh + +case "$1" in + (--help) echo send a message to a specific user ;; + (*) + cd /tmp/noise + . $NOISE_pid/environment + nick="${chat_nick-$NOISE_pid}" + target="$1" + shift + for client in * ; do + . $client/environment + if test "$target" = "${chat_nick-$client}" ; then + echo "/echo <-- $nick: $*" > $client/linefeed + echo "--> $target: $*" + exit + fi + unset chat_channel + + done + + echo "$nick not found" +esac diff --git a/modules/noise/modules/send_to_channel b/modules/noise/modules/send_to_channel new file mode 100755 index 00000000..4a0470af --- /dev/null +++ b/modules/noise/modules/send_to_channel @@ -0,0 +1,17 @@ +#! /bin/sh + +case "$1" in + (--help) : ;; + (*) + cd /tmp/noise + channel="$1" + shift + for client in * ; do + . $client/environment + if test "$channel" = "$chat_channel" && test "$default_command" = chat ; then + echo "/echo $*" > $client/linefeed + fi + unset chat_channel + + done +esac diff --git a/modules/noise/modules/sendmail b/modules/noise/modules/sendmail new file mode 100755 index 00000000..182d96e3 --- /dev/null +++ b/modules/noise/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" +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/noise/modules/shackstatus b/modules/noise/modules/shackstatus new file mode 100755 index 00000000..a5058f0a --- /dev/null +++ b/modules/noise/modules/shackstatus @@ -0,0 +1,104 @@ +#! /bin/bash + +main() { + case "$1" in + (--help) + echo "report status of all shack services." + ;; + (*) + test "$(dig +short localhost @10.42.0.10 )" = "127.0.0.1" && + STAT_DNS_I="läuft" || STAT_DNS_I="antwortet nicht" + test "$(dig +short shackspace.de @10.42.0.10 )" = "141.31.176.214" && + STAT_DNS_E="läuft" || STAT_DNS_E="antwortet nicht" + test "$(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}' ) + + cat <<-EOF >$NOISE_linefeed + /set pitch 10 + /espeak -v Hallo - Ich bin Krebs. + /espeak -v Heute ist `wochentag`, der `tag` --- `monat` -- `date +%Y` + /zeit + /espeak -v tcheck der systeme: + /espeak -v Energie versorgung -- aktiv + /espeak -v shackhost -- läuft + /espeak -v telnet -- läuft + /espeak -v interner - D N S -- interne - do-mejn -- $STAT_DNS_I + /espeak -v interner - D N S -- externe - do-mejn -- $STAT_DNS_E + /espeak -v externer - D N S - $STAT_DNS_X + /espeak -v Leitungsqualität - $STAT_LINE prozent. + /temp + /espeak -v krebs kompjuting bereit + EOF + ;; + esac 2>&1 +} + +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 +} + +main "$@" diff --git a/modules/noise/modules/sleep b/modules/noise/modules/sleep new file mode 100755 index 00000000..89712cac --- /dev/null +++ b/modules/noise/modules/sleep @@ -0,0 +1,10 @@ +#! /bin/sh +case "$1" in + (--help) echo "pause for NUMBER seconds" ;; + (*) + 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/noise/modules/stream b/modules/noise/modules/stream new file mode 100755 index 00000000..1e6fd0c5 --- /dev/null +++ b/modules/noise/modules/stream @@ -0,0 +1,64 @@ +#! /bin/sh +inputdir=$HOME/noise/streams +basename="`basename "$0"`" +case "$1" in + (--help) + if echo "$0 $*" | grep -q '[[:space:]]--verbose\>'; then + echo -e "\x1B[35mtype \x1B[32m/$basename off \x1B[35mto 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[35mtype \x1B[32m/$basename $shortcut \x1B[35mfor $topic\x1B[m" + done + else + echo "play an audio stream" + fi + ;; + (*) + 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<] +## Echo temperature in K. If formula is given then return that result instead. +inside_temp() { + echo "scale=2; x=`/krebs/modules/temper/temper` + 273.15; ${1-x}" | bc +} + +outside_temp() { + echo "scale=2; x=`dig +short txt outside.elwood.temp.citecs.de | + sed 's/^"DEG \([0-9]\+\.[0-9]\+\)"$/\1/' + ` + 273.15; ${1-x}" | bc +} + +espeak_inside() { + echo Die Krebs-tempera-tur beträgt $@ | to_espeak +} + +espeak_outside() { + echo Die Außen-tempera-tur beträgt $@ | to_espeak +} + +to_espeak() { + sed ' + s/\(\.[0-9]\)0\+/\1/g + s/\(\.[0-9]\)\([0-9]\)[0-9]*/ \1 \2 /; + s/^-/minus /; + s/\./ komma /; + ' | tee $NOISE_linefeed +} + +main "$@" diff --git a/modules/noise/modules/test b/modules/noise/modules/test new file mode 100755 index 00000000..2c0b8e0d --- /dev/null +++ b/modules/noise/modules/test @@ -0,0 +1,13 @@ +#! /bin/sh + +case "$1" in + (--help) echo do some test-module related stuff ;; + (*) + + echo -n ">> " + read TEST + if [ $TEST == 'q' ]; then exit; fi + echo /wall @@ $TEST >$NOISE_linefeed + #sleep 1 + #sleep 1; echo /test >$NOISE_linefeed & +esac diff --git a/modules/noise/modules/twitter b/modules/noise/modules/twitter new file mode 100755 index 00000000..26982525 --- /dev/null +++ b/modules/noise/modules/twitter @@ -0,0 +1,125 @@ +#!/usr/bin/python +#encode=utf8 + +#print "TODO Bug Robert to implement Twitter-OAuth!" +#exit(1) +import sys + +#sys.path.append("/usr/local/lib/") + +import twitter, os, pwd + +#os.getlogin = lambda: pwd.getpwuid(os.getuid())[0] + +sys.stderr = sys.stdout + +def shorten(text): + + text = text.replace("about ", "~") + text = text.replace("an", "1") + text = text.replace(" minutes", "m") + text = text.replace(" minute", "m") + text = text.replace(" hours", "h") + text = text.replace(" hour", "h") + text = text.replace(" seconds", "s") + text = text.replace(" second", "s") + text = text.replace(" days", "d") + text = text.replace(" day", "d") + text = text.replace(" weeks", "w") + text = text.replace(" week", "w") + text = text.replace(" years", "y") + text = text.replace(" year", "y") + text = text.replace(" ago", "") + text = text.replace("a", "1") + return text + + +def parse(text): + text = text.replace("\n","") + t = text.split(" ") + new = "" + for piece in t: + escape = "" + if piece.startswith("@"): + escape = "" + if piece[1:].lower() == "shackspam" or piece[1:].lower() == "shackspace": + escape = "" + + elif piece.startswith("#"): + escape = "" + elif piece.startswith("http://"): + escape = "" + if escape: + new += escape + piece + " " + else: + new += piece + " " + + return new + +if len(sys.argv) > 1 and sys.argv[1] == "--help": + print "read or post to the shackspam twitter timeline" + if len(sys.argv) == 3 and sys.argv[2] == "--verbose": + print "call without parameters to read" + print "use /twitter [your tweet] to tweet something to the shackspam twitter timeline" + exit() + + + +api = twitter.Api("Z7f9npE5ixvZ0lMCHDZBOg", "8z0gyfOABar1HxKvqL6fYXLqRFUPLQ9OOzDFt7Q4F4", "139766258-94TGPvNsJ8tYVv68eZewfXOIyDvRCWdycNlUgHrs", "NRnDQZPCoLrDizFvakZkSWgoG4vgGuT3OOMChSfiI") + +#api.SetXTwitterHeaders("Shackspace UTTERANCE","","0.00.0.01.42") + +if len(sys.argv) > 1: + + + tweet = u"" + + for t in sys.argv[1:]: + tweet += t.decode("utf8") + u" " + tweet = tweet[:-1] + + print u"Length: " + str(len(tweet)) + u"" + + if len(tweet) > 140: + print u"Your Tweet must be shorter than 140 characters.\n" + exit() + + status = api.PostUpdate(tweet) + + + + +else: + """print "\tshackspace tweets:" + for i in api.GetUserTimeline(): + i.text = parse(i.text) + print ("" + i.user.screen_name + " " + i.GetRelativeCreatedAt() + " " + i.text).encode("utf8").replace("\n"," ") + + print "\n\tfriends tweets" + """ + a = api.GetFriendsTimeline() + a.reverse() + for i in a: + text = i.text + ilen = len(i.user.screen_name) + len(shorten(i.GetRelativeCreatedAt())) + 2 + if i.user.screen_name.lower() == "shackspace" or i.user.screen_name.lower() == "shackspam": + info = "" + i.user.screen_name + " " + shorten(i.GetRelativeCreatedAt()) + "" + else: + info = "" + i.user.screen_name + " " + shorten(i.GetRelativeCreatedAt()) + "" + text = info + " " + parse(text) + + t = text.split(" ") + tmp = "" + for n in t: + if ((len(tmp) + len(n)) >= 80): + print parse(tmp).encode("utf8") + tmp = " " * ilen + + tmp += " " + n + if len(tmp) > ilen: + print parse(tmp).encode("utf8") + + + + + diff --git a/modules/noise/modules/vvs b/modules/noise/modules/vvs new file mode 100755 index 00000000..fc23375f --- /dev/null +++ b/modules/noise/modules/vvs @@ -0,0 +1,17 @@ +#! /bin/sh + +wrapper() { + exec 2>&1 + echo date: `date +%H:%M` + "$@" +} + +case "$1" in + (--help) echo query VVS ;; + (*) + case $# in + (2) wrapper vvs.de "$@" ;; + (0) wrapper vvs ;; + (*) echo "Syntax: /vvs [ORIGIN DESTINATION]" ; return ;; + esac +esac diff --git a/modules/noise/modules/wall b/modules/noise/modules/wall new file mode 100755 index 00000000..c73744ea --- /dev/null +++ b/modules/noise/modules/wall @@ -0,0 +1,8 @@ +#! /bin/sh +case "$1" in + (--help) : ;; + (?*) + for linefeed in /tmp/noise/*/linefeed ; do + echo /echo "$*" >$linefeed + done +esac diff --git a/modules/noise/modules/zeit b/modules/noise/modules/zeit new file mode 100755 index 00000000..9fbc33e4 --- /dev/null +++ b/modules/noise/modules/zeit @@ -0,0 +1,19 @@ +#! /bin/sh + +case "$1" in + (--help) + echo "say current time" ;; + (*) + exec >>$NOISE_linefeed + k=`date +%k|sed 's/^[[:space:]]*1[[:space:]]*$/ein/'` + M=`date +%M|sed 's/0*//'` + echo /set pitch 10 + case "$lang" in + (de|'') echo "/espeak Es ist $k Uhr $M" ;; + (en|*-en) + test -z "$M" || M="and $M minutes" + echo "/espeak It is $k o clock $M" ;; + (*) echo "Error: unsupported lang = $lang" >&2 + esac + echo /set pitch ${noise_pitch-100} +esac 2>&1 diff --git a/modules/noise/noise b/modules/noise/noise new file mode 100755 index 00000000..bd6b17c8 --- /dev/null +++ b/modules/noise/noise @@ -0,0 +1,182 @@ +#! /bin/sh + +noise_set() { # set a variable + case "$1" in + (-q|--quiet) echo=: ; shift ;; + (*) echo=echo ;; + esac + case $# in + (0) ## print all noise variables + env | sed -rn ' + s/^noise_([[:alnum:]_]+)=(.*)$/\1 = \2/p + ' | sort + ;; + (1) ## print value the specified variable + eval "echo \"$1 = \$noise_$1\"" + ;; + (*) ## set the specified variable + if echo "$1" | grep -q '[^[:alnum:]_]' ; then + fail invalid variable name "$1" + return 23 + fi + eval "old=\"\$noise_$1\"" + if test "x$old" = "x$2" ; then + eval "$echo \"$1 is already $2\"" + elif test -z "$old" ; then + eval "export noise_$1='$2' ; $echo \ +\"$1 set to $2\"" + else + eval "export noise_$1='$2' ; $echo \ +\"$1 changed from $old to $2\"" + fi + ## write variable to $env + if grep -q "^$1=" "$env" ; then + sed -ri "s'^($1)=(.*)\$'\1=\'$2\''" $env + else + echo "$1='$2'" >>$env + fi + ;; + 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 +} + +fail() { + echo "FAIL: $*" + return 23 +} + +cleanup() { + kill $jobs + rm -f $linefeed $env + rmdir /tmp/noise/$$ 2>/dev/null + rmdir /tmp/noise 2>/dev/null +} + +exec 2>&1 +qname="`readlink -f "$0"`" +dirname="`dirname "$qname"`" +export HOME='/home/noise' +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 -p /tmp/noise/$$ +linefeed="/tmp/noise/$$/linefeed" +env="/tmp/noise/$$/environment" +trap cleanup EXIT +mkfifo $linefeed +touch $env +## +## +## +readline() { + { read REPLY && echo "$REPLY" ; } | sed -rn " + s/[']//g + s/~%/\n/g + s/([^\\])([#<>])/\1\\\\\2/g + s:^/([a-z_]+)([[:space:]]+(.*))?$:command=\1; args='\3';:p;t + s@^([[:alnum:]_/+-]+):[[:space:]]*(.*)@command=lang; args='\1 \2';@p;t + s@^\![[:space:]]*(.*)@command=play; args='\1';@p;t + s:.*:command='$noise_default_command'; args='&';:p;t + " +} +## +## +## +while echo -n "$noise_prompt" && eval "`readline`" ; do + ## modcall + for dir in `echo "$NOISE_PATH" | tr : \ ` ; do + module="$dir/$command" + if test -x "$module" ; then +#echo foo $module:$@: + #shift + eval 'NOISE="$0" NOISE_pid="$$" NOISE_linefeed="$linefeed" "$module"' "$args" + continue 2 + fi + done + ## funcall + if type noise_$command | grep -q function ; then + eval 'noise_$command' "$args" + continue + fi + ## + fail unknown command "$command" +done <$linefeed & +jobs="${jobs+$jobs }`jobs -p`" +## +## +## +cat</dev/null +`... + +## Motto Of The Day\ + +Join the 23.shack-dev-team, we've got ` + sloccount $dirname/* | + sed -rn ' + s/.*\(SLOC\)[[:space:]]*=[[:space:]]*([0-9]+)$/\1/p + '` SLOC, ` + { + ls $dirname/modules/ + test -d ~noise/modules && ls ~noise/modules/ + } | sort | uniq | wc -l + ` mods, +`grep ^- $dirname/TODO | wc -l`+ TODOs and drive the irregular Hackathon @shackspace. +Follow http://twitter.com/shackspam FTW! + +## Hints\ + +Start your telnet session with rlwrap for MAXIMUM profit. +Get online-help with /help. + +EOF +# TODO: MOTD-candidates: +#twitter: #shackspam +#mail: shockspasm@googlemail.com +#irc: freenode/#shackspace +#afk: @shackspace +## +## +## +exec >>$linefeed +## +## +## +echo '/set -q default_command espeak' +echo '/set -q prompt "READY.~%"' +## +## +## +while read REPLY; do + case $REPLY in + (/quit) echo /quit ; exit ;; + (*) tr \; \\n | grep . ;; + esac< $NOISE_linefeed - - echo /set default_command espeak >$NOISE_linefeed - echo "disabled chat mode (set back to espeak)" ;; - - -esac diff --git a/modules/ping b/modules/ping deleted file mode 100755 index acf2529f..00000000 --- a/modules/ping +++ /dev/null @@ -1,24 +0,0 @@ -#! /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 deleted file mode 100755 index 749b450a..00000000 --- a/modules/play +++ /dev/null @@ -1,36 +0,0 @@ -#! /bin/sh -case "$1" in - (--help) - echo "play an audio file" ;; - (*) - exec 2>&1 - ffs='wav mp3 ogg asf flac' - - if test -z "$*" ; then - ls $HOME/noise/samples | sed -r ' - s:\.('"`echo "$ffs" | tr \ \|`"')$: \1: - s:^:/play : - s:.*:&: - ' - else - for i in $ffs ; do - f=$HOME/noise/samples/$1.$i - test -f "$f" && - case "$i" in - wav) aplay "$f" & ;; - *) mplayer "$f" & ;; - esac && break - done || cat<$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/query b/modules/query deleted file mode 100755 index ceeff8a5..00000000 --- a/modules/query +++ /dev/null @@ -1,23 +0,0 @@ -#! /bin/sh - -case "$1" in - (--help) echo send a message to a specific user ;; - (*) - cd /tmp/noise - . $NOISE_pid/environment - nick="${chat_nick-$NOISE_pid}" - target="$1" - shift - for client in * ; do - . $client/environment - if test "$target" = "${chat_nick-$client}" ; then - echo "/echo <-- $nick: $*" > $client/linefeed - echo "--> $target: $*" - exit - fi - unset chat_channel - - done - - echo "$nick not found" -esac diff --git a/modules/send_to_channel b/modules/send_to_channel deleted file mode 100755 index 4a0470af..00000000 --- a/modules/send_to_channel +++ /dev/null @@ -1,17 +0,0 @@ -#! /bin/sh - -case "$1" in - (--help) : ;; - (*) - cd /tmp/noise - channel="$1" - shift - for client in * ; do - . $client/environment - if test "$channel" = "$chat_channel" && test "$default_command" = chat ; then - echo "/echo $*" > $client/linefeed - fi - unset chat_channel - - done -esac diff --git a/modules/sendmail b/modules/sendmail deleted file mode 100755 index 182d96e3..00000000 --- a/modules/sendmail +++ /dev/null @@ -1,55 +0,0 @@ -#!/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" -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 deleted file mode 100755 index a5058f0a..00000000 --- a/modules/shackstatus +++ /dev/null @@ -1,104 +0,0 @@ -#! /bin/bash - -main() { - case "$1" in - (--help) - echo "report status of all shack services." - ;; - (*) - test "$(dig +short localhost @10.42.0.10 )" = "127.0.0.1" && - STAT_DNS_I="läuft" || STAT_DNS_I="antwortet nicht" - test "$(dig +short shackspace.de @10.42.0.10 )" = "141.31.176.214" && - STAT_DNS_E="läuft" || STAT_DNS_E="antwortet nicht" - test "$(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}' ) - - cat <<-EOF >$NOISE_linefeed - /set pitch 10 - /espeak -v Hallo - Ich bin Krebs. - /espeak -v Heute ist `wochentag`, der `tag` --- `monat` -- `date +%Y` - /zeit - /espeak -v tcheck der systeme: - /espeak -v Energie versorgung -- aktiv - /espeak -v shackhost -- läuft - /espeak -v telnet -- läuft - /espeak -v interner - D N S -- interne - do-mejn -- $STAT_DNS_I - /espeak -v interner - D N S -- externe - do-mejn -- $STAT_DNS_E - /espeak -v externer - D N S - $STAT_DNS_X - /espeak -v Leitungsqualität - $STAT_LINE prozent. - /temp - /espeak -v krebs kompjuting bereit - EOF - ;; - esac 2>&1 -} - -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 -} - -main "$@" diff --git a/modules/sleep b/modules/sleep deleted file mode 100755 index 89712cac..00000000 --- a/modules/sleep +++ /dev/null @@ -1,10 +0,0 @@ -#! /bin/sh -case "$1" in - (--help) echo "pause for NUMBER seconds" ;; - (*) - 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 deleted file mode 100755 index 1e6fd0c5..00000000 --- a/modules/stream +++ /dev/null @@ -1,64 +0,0 @@ -#! /bin/sh -inputdir=$HOME/noise/streams -basename="`basename "$0"`" -case "$1" in - (--help) - if echo "$0 $*" | grep -q '[[:space:]]--verbose\>'; then - echo -e "\x1B[35mtype \x1B[32m/$basename off \x1B[35mto 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[35mtype \x1B[32m/$basename $shortcut \x1B[35mfor $topic\x1B[m" - done - else - echo "play an audio stream" - fi - ;; - (*) - 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<] -## Echo temperature in K. If formula is given then return that result instead. -inside_temp() { - echo "scale=2; x=`/krebs/modules/temper/temper` + 273.15; ${1-x}" | bc -} - -outside_temp() { - echo "scale=2; x=`dig +short txt outside.elwood.temp.citecs.de | - sed 's/^"DEG \([0-9]\+\.[0-9]\+\)"$/\1/' - ` + 273.15; ${1-x}" | bc -} - -espeak_inside() { - echo Die Krebs-tempera-tur beträgt $@ | to_espeak -} - -espeak_outside() { - echo Die Außen-tempera-tur beträgt $@ | to_espeak -} - -to_espeak() { - sed ' - s/\(\.[0-9]\)0\+/\1/g - s/\(\.[0-9]\)\([0-9]\)[0-9]*/ \1 \2 /; - s/^-/minus /; - s/\./ komma /; - ' | tee $NOISE_linefeed -} - -main "$@" diff --git a/modules/test b/modules/test deleted file mode 100755 index 2c0b8e0d..00000000 --- a/modules/test +++ /dev/null @@ -1,13 +0,0 @@ -#! /bin/sh - -case "$1" in - (--help) echo do some test-module related stuff ;; - (*) - - echo -n ">> " - read TEST - if [ $TEST == 'q' ]; then exit; fi - echo /wall @@ $TEST >$NOISE_linefeed - #sleep 1 - #sleep 1; echo /test >$NOISE_linefeed & -esac diff --git a/modules/twitter b/modules/twitter deleted file mode 100755 index 26982525..00000000 --- a/modules/twitter +++ /dev/null @@ -1,125 +0,0 @@ -#!/usr/bin/python -#encode=utf8 - -#print "TODO Bug Robert to implement Twitter-OAuth!" -#exit(1) -import sys - -#sys.path.append("/usr/local/lib/") - -import twitter, os, pwd - -#os.getlogin = lambda: pwd.getpwuid(os.getuid())[0] - -sys.stderr = sys.stdout - -def shorten(text): - - text = text.repl