From 50aa02ccf1de40bc5f518d212a89c587c2b7d859 Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 26 Apr 2010 15:19:51 +0200 Subject: Rewrite of SHACK UTTERANCE 0.9 beta 1 --- modules/help | 15 +++++++++ noise | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ noise-server | 7 ++++ 3 files changed, 124 insertions(+) create mode 100755 modules/help create mode 100755 noise create mode 100755 noise-server diff --git a/modules/help b/modules/help new file mode 100755 index 00000000..303af362 --- /dev/null +++ b/modules/help @@ -0,0 +1,15 @@ +#! /bin/sh +case "$1" in + (-*) : ;; # ignore all options + ('') { for directory in `echo "$NOISE_PATH" | tr : \ ` ; do + for module in "$directory"/* ; do + echo `basename "$module"` `$module --help` + done + done + ## print all documented built-in commands + sed -rn 's:^noise_([a-z]+)\(\) \{ # (.+)?$:\1 \2:p' "$NOISE" + } | sort | sed -rn ' + $s/$// + s:^([a-z]+) (.+):type /\1 to \2:p' ;; + (*) exit 23 ;; +esac diff --git a/noise b/noise new file mode 100755 index 00000000..481f2c09 --- /dev/null +++ b/noise @@ -0,0 +1,102 @@ +#! /bin/sh + +noise_set() { # set a variable + if test "x$1" = x ; then + env | sed -rn ' + s/^noise_([[:alnum:]_]+)=(.*)$/\1 = \2/p + ' | sort + elif test "x$2" = x ; then + eval "echo \"$1 is \$noise_$1\"" + else + 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 + fi +} + +noise_quit() { # exit + echo "Good bye!" + exit +} + +fail() { + echo "FAIL: $*" + return 23 +} + +linefeed="/tmp/noise-client-$$" +trap "rm -f $linefeed" EXIT +mkfifo $linefeed +while eval `{ read && echo $REPLY ; } | tr -d \' | sed -rn " + s:^/([a-z]+)([[:space:]]+(.*))?$:command='\1'; args='\3';:p;t + s:.*:command='$noise_default_command'; args='&';:p;t + "` ; do + #echo "command: $command; args: $args" + ## modcall + for dir in `echo "$NOISE_PATH" | tr : \ ` ; do + module="$dir/$command" + if test -x "$module" ; then + shift + NOISE="$0" NOISE_linefeed="$linefeed" "$module" $args + continue 2 + fi + done + ## funcall + if type noise_$command &>/dev/null ; then + noise_$command $args + continue + fi + ## + fail unknown command "$command" +done <$linefeed & +cat<>$linefeed +echo /set default_command espeak + while read ; do + case $REPLY in + (/quit) echo /quit ; exit ;; + (*) tr \; \\n | grep . ;; + esac</dev/null ; then + noise_"$@" + : && return + fi + return 23 +} diff --git a/noise-server b/noise-server new file mode 100755 index 00000000..defe2f5b --- /dev/null +++ b/noise-server @@ -0,0 +1,7 @@ +#! /bin/sh +qname="`readlink -f "$0"`" +dirname="`dirname "$qname"`" +if test -d "$dirname/modules" ; then + export NOISE_PATH="${NOISE_PATH+$NOISE_PATH:}$dirname/modules" +fi +exec tcpserver -c 423 -t 2 -D 0.0.0.0 42380 "$dirname/noise" -- cgit v1.2.3 From db8d3910efdaf735fa51f012fb48b52e23f25c4c Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 26 Apr 2010 16:33:52 +0200 Subject: Reap child processes on EXIT --- noise | 34 ++++++++-------------------------- 1 file changed, 8 insertions(+), 26 deletions(-) diff --git a/noise b/noise index 481f2c09..fe67052c 100755 --- a/noise +++ b/noise @@ -6,7 +6,7 @@ noise_set() { # set a variable s/^noise_([[:alnum:]_]+)=(.*)$/\1 = \2/p ' | sort elif test "x$2" = x ; then - eval "echo \"$1 is \$noise_$1\"" + eval "echo \"$1 = \$noise_$1\"" else if echo "$1" | grep -q '[^[:alnum:]_]' ; then fail invalid variable name "$1" @@ -35,8 +35,13 @@ fail() { return 23 } +cleanup() { + rm -f $linefeed + kill $jobs +} + linefeed="/tmp/noise-client-$$" -trap "rm -f $linefeed" EXIT +trap cleanup EXIT mkfifo $linefeed while eval `{ read && echo $REPLY ; } | tr -d \' | sed -rn " s:^/([a-z]+)([[:space:]]+(.*))?$:command='\1'; args='\3';:p;t @@ -60,6 +65,7 @@ while eval `{ read && echo $REPLY ; } | tr -d \' | sed -rn " ## fail unknown command "$command" done <$linefeed & +jobs="${jobs+$jobs }`jobs -p`" cat</dev/null ; then - noise_"$@" - : && return - fi - return 23 -} -- cgit v1.2.3 From 3bf6c7a90c6d9141d2a5701203ba2fabe41a5c68 Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 26 Apr 2010 16:34:51 +0200 Subject: Added modules: espeak lang msg play wall zeit --- modules/espeak | 17 +++++++++++++++++ modules/lang | 22 ++++++++++++++++++++++ modules/msg | 6 ++++++ modules/play | 31 +++++++++++++++++++++++++++++++ modules/wall | 9 +++++++++ modules/zeit | 15 +++++++++++++++ 6 files changed, 100 insertions(+) create mode 100755 modules/espeak create mode 100755 modules/lang create mode 100755 modules/msg create mode 100755 modules/play create mode 100755 modules/wall create mode 100755 modules/zeit diff --git a/modules/espeak b/modules/espeak new file mode 100755 index 00000000..34c61e42 --- /dev/null +++ b/modules/espeak @@ -0,0 +1,17 @@ +#! /bin/sh +case "$1" in + (--help) echo say something with espeak ;; + (*) + p="${noise_pitch-100}" + v="${noise_lang-de}" + k="${noise_capital-0}" + a="${noise_amplitude-100}" + g="${noise_gap-1}" + echo pitch: $p + echo lang: $v + echo capital: $k + echo amplitude: $a + echo gap: $g + #echo "espeak -p \"$pitch\" -v \"$lang\" \"$*\"" >&2 + espeak -a $a -k $k -p $p -v $v -g $g "$*" & +esac diff --git a/modules/lang b/modules/lang new file mode 100755 index 00000000..07b6802e --- /dev/null +++ b/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/msg b/modules/msg new file mode 100755 index 00000000..344dd963 --- /dev/null +++ b/modules/msg @@ -0,0 +1,6 @@ +#! /bin/sh +case "$1" in + (--help) : ;; + (*) + echo "$*" +esac diff --git a/modules/play b/modules/play new file mode 100755 index 00000000..ea5e991c --- /dev/null +++ b/modules/play @@ -0,0 +1,31 @@ +#! /bin/sh +case "$1" in + (--help) + echo "play an audio file" ;; + (*) + ffs='wav mp3 ogg asf flac' + + if test -z "$*" ; then + ls ~shack/speak/sample | sed -r ' + s:\.('"`echo "$ffs" | tr \ \|`"')$: \1: + s:^:/play : + s:.*:&: + ' + else + for i in $ffs ; do + f=~shack/speak/sample/$1.$i + test -f "$f" && + case "$i" in + wav) aplay "$f" & ;; + *) mplayer "$f" & ;; + esac && break + done || cat<$client + echo /msg "$*" >$client + done +esac diff --git a/modules/zeit b/modules/zeit new file mode 100755 index 00000000..0b0537d3 --- /dev/null +++ b/modules/zeit @@ -0,0 +1,15 @@ +#! /bin/sh + +case "$1" in + (--help) + echo "say current time" ;; + (*) + exec >>$NOISE_linefeed + echo /set pitch 10 + case "$lang" in + (de|'') date +'"Es ist %k Uhr %M."' >$NOISE_linefeed ;; + (en|*-en) date +'"It is %k o clock and %M minutes"' >$NOISE_linefeed ;; + (*) echo "Error: unsupported lang = $lang" >&2 + esac + echo /set pitch ${noise_pitch-100} +esac 2>&1 -- cgit v1.2.3 From b6398b0e2388e5980cda35de487a7a37f5f3e214 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 26 Apr 2010 19:40:48 +0200 Subject: espeak: send text via stdin --- modules/espeak | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/espeak b/modules/espeak index 34c61e42..cda70fc8 100755 --- a/modules/espeak +++ b/modules/espeak @@ -13,5 +13,7 @@ case "$1" in echo amplitude: $a echo gap: $g #echo "espeak -p \"$pitch\" -v \"$lang\" \"$*\"" >&2 - espeak -a $a -k $k -p $p -v $v -g $g "$*" & + espeak -a $a -k $k -p $p -v $v -g $g< Date: Mon, 26 Apr 2010 19:41:23 +0200 Subject: play: fixed typo --- modules/play | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/play b/modules/play index ea5e991c..66295990 100755 --- a/modules/play +++ b/modules/play @@ -3,6 +3,7 @@ case "$1" in (--help) echo "play an audio file" ;; (*) + exec 2>&1 ffs='wav mp3 ogg asf flac' if test -z "$*" ; then @@ -22,7 +23,7 @@ case "$1" in done || cat< Date: Mon, 26 Apr 2010 19:41:59 +0200 Subject: noise: factorized out the reader --- noise | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/noise b/noise index fe67052c..048726f2 100755 --- a/noise +++ b/noise @@ -40,13 +40,28 @@ cleanup() { kill $jobs } + +qname="`readlink -f "$0"`" +dirname="`dirname "$qname"`" +if test -d "$dirname/modules" ; then + export NOISE_PATH="${NOISE_PATH+$NOISE_PATH:}$dirname/modules" +fi linefeed="/tmp/noise-client-$$" trap cleanup EXIT mkfifo $linefeed -while eval `{ read && echo $REPLY ; } | tr -d \' | sed -rn " - s:^/([a-z]+)([[:space:]]+(.*))?$:command='\1'; args='\3';:p;t - s:.*:command='$noise_default_command'; args='&';:p;t - "` ; do +## +## +## +readline() { + { read && echo $REPLY ; } | sed -rn " + s/['\"]//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 eval "`readline`" ; do #echo "command: $command; args: $args" ## modcall for dir in `echo "$NOISE_PATH" | tr : \ ` ; do @@ -66,18 +81,24 @@ while eval `{ read && echo $REPLY ; } | tr -d \' | sed -rn " fail unknown command "$command" done <$linefeed & jobs="${jobs+$jobs }`jobs -p`" +## +## +## cat<>$linefeed echo /set default_command espeak - while read ; do - case $REPLY in - (/quit) echo /quit ; exit ;; - (*) tr \; \\n | grep . ;; - esac< Date: Mon, 26 Apr 2010 19:43:49 +0200 Subject: Start noise as shack --- noise-as-shack | 4 ++++ noise-server | 5 +---- 2 files changed, 5 insertions(+), 4 deletions(-) create mode 100755 noise-as-shack diff --git a/noise-as-shack b/noise-as-shack new file mode 100755 index 00000000..c327bb81 --- /dev/null +++ b/noise-as-shack @@ -0,0 +1,4 @@ +#! /bin/sh +qname="`readlink -f "$0"`" +dirname="`dirname "$qname"`" +exec su - shack -c "$dirname"/noise diff --git a/noise-server b/noise-server index defe2f5b..2012bbb5 100755 --- a/noise-server +++ b/noise-server @@ -1,7 +1,4 @@ #! /bin/sh qname="`readlink -f "$0"`" dirname="`dirname "$qname"`" -if test -d "$dirname/modules" ; then - export NOISE_PATH="${NOISE_PATH+$NOISE_PATH:}$dirname/modules" -fi -exec tcpserver -c 423 -t 2 -D 0.0.0.0 42380 "$dirname/noise" +exec tcpserver -c 423 -t 2 -D 0.0.0.0 23 "$dirname/noise-as-shack" -- cgit v1.2.3 From 58cdb381ea2f134c7d68aba5a8a77eeef3bf22bc Mon Sep 17 00:00:00 2001 From: root Date: Mon, 26 Apr 2010 19:54:09 +0200 Subject: noise: added $HOME/noise/modules to $NOISE_PATH --- noise | 1 + 1 file changed, 1 insertion(+) diff --git a/noise b/noise index 048726f2..b0b5b501 100755 --- a/noise +++ b/noise @@ -45,6 +45,7 @@ qname="`readlink -f "$0"`" dirname="`dirname "$qname"`" 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 linefeed="/tmp/noise-client-$$" trap cleanup EXIT -- cgit v1.2.3 From 1247b6d9d9a911982b5eb2841193dbb1cc32c4da Mon Sep 17 00:00:00 2001 From: root Date: Mon, 26 Apr 2010 19:56:39 +0200 Subject: play: changed sample dir to $HOME/noise/samples --- modules/play | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/play b/modules/play index 66295990..dcb8749f 100755 --- a/modules/play +++ b/modules/play @@ -7,14 +7,14 @@ case "$1" in ffs='wav mp3 ogg asf flac' if test -z "$*" ; then - ls ~shack/speak/sample | sed -r ' + ls $HOME/noise/samples | sed -r ' s:\.('"`echo "$ffs" | tr \ \|`"')$: \1: s:^:/play : s:.*:&: ' else for i in $ffs ; do - f=~shack/speak/sample/$1.$i + f=$HOME/noise/samples/$1.$i test -f "$f" && case "$i" in wav) aplay "$f" & ;; @@ -24,7 +24,7 @@ case "$1" in \ Keine Audiodatei mit dem Namen $1.EXT gefunden... \ am besten gleich uploaden: -$ scp NAME shack@shack:speak/sample/ +$ scp NAME $LOGNAME@shack:noise/samples/ folgende Dateiendungen werden erkannt: $ffs EOF -- cgit v1.2.3 From 2a0c71f3e28e11b61e98b5975116c0809bc49e34 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 2 May 2010 13:07:11 +0200 Subject: help: implemented /help [MODULE ARGS...] --- modules/help | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/help b/modules/help index 303af362..48c06686 100755 --- a/modules/help +++ b/modules/help @@ -11,5 +11,14 @@ case "$1" in } | sort | sed -rn ' $s/$// s:^([a-z]+) (.+):type /\1 to \2:p' ;; - (*) exit 23 ;; + (*) + ## 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 -- cgit v1.2.3 From 667de73a8186f23df8357391cd96c3eee96eab54 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 2 May 2010 20:47:32 +0200 Subject: noise: notify ready state with "READY." --- noise | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noise b/noise index b0b5b501..36c86185 100755 --- a/noise +++ b/noise @@ -62,7 +62,7 @@ readline() { s:.*:command='$noise_default_command'; args='&';:p;t " } -while eval "`readline`" ; do +while echo "READY." && eval "`readline`" ; do #echo "command: $command; args: $args" ## modcall for dir in `echo "$NOISE_PATH" | tr : \ ` ; do -- cgit v1.2.3 From 1849640f86e84440c4920018fb9be6f5bff5bfc8 Mon Sep 17 00:00:00 2001 From: "shackspace e.V" Date: Sun, 2 May 2010 22:46:15 +0200 Subject: initially added modules --- modules/mpc | 14 +++++++ modules/test | 9 +++++ modules/twitter | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ modules/vvs | 17 +++++++++ 4 files changed, 156 insertions(+) create mode 100755 modules/mpc create mode 100755 modules/test create mode 100755 modules/twitter create mode 100755 modules/vvs diff --git a/modules/mpc b/modules/mpc new file mode 100755 index 00000000..6626532b --- /dev/null +++ b/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 + mpc $@ +esac diff --git a/modules/test b/modules/test new file mode 100755 index 00000000..30444bf7 --- /dev/null +++ b/modules/test @@ -0,0 +1,9 @@ +#! /bin/sh + +case "$1" in + (--help) echo do some test-module related stuff ;; + (*) + echo test-module called with following arguments: "$@" + ## send command for re-evaluation: + echo /espeak test >$NOISE_linefeed +esac diff --git a/modules/twitter b/modules/twitter new file mode 100755 index 00000000..e8962657 --- /dev/null +++ b/modules/twitter @@ -0,0 +1,116 @@ +#!/usr/bin/python +#encode=utf8 + +import sys, twitter + +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", "") + 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() == "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 shackspace 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 shackspace twitter timeline" + exit() + + + + +api = twitter.Api(username="shackspace", password="0b0dallaf4lla") + +#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 + if i.user.screen_name.lower() == "shackspace": + 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 = " " *( len(info)-15) + + tmp += " " + n + if len(tmp) > (len(info)-15+1): + print parse(tmp).encode("utf8") + + + + + diff --git a/modules/vvs b/modules/vvs new file mode 100755 index 00000000..fc23375f --- /dev/null +++ b/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 -- cgit v1.2.3 From 59907ceaa2211a3c1600e8febd4752dd18fe896f Mon Sep 17 00:00:00 2001 From: root Date: Tue, 4 May 2010 23:59:14 +0200 Subject: noise: accept double-quotes and extended /set New /set syntax: /set [-q|--quiet] [NAME [VALUES]] --- noise | 69 +++++++++++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 42 insertions(+), 27 deletions(-) diff --git a/noise b/noise index 36c86185..9fc7e6e2 100755 --- a/noise +++ b/noise @@ -1,28 +1,36 @@ #! /bin/sh noise_set() { # set a variable - if test "x$1" = x ; then - env | sed -rn ' - s/^noise_([[:alnum:]_]+)=(.*)$/\1 = \2/p - ' | sort - elif test "x$2" = x ; then - eval "echo \"$1 = \$noise_$1\"" - else - 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 \ + 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 \ + else + eval "export noise_$1='$2' ; $echo \ \"$1 changed from $old to $2\"" - fi - fi + fi + ;; + esac } noise_quit() { # exit @@ -54,28 +62,36 @@ mkfifo $linefeed ## ## readline() { - { read && echo $REPLY ; } | sed -rn " - s/['\"]//g + { read && echo "$REPLY" ; } | sed -rn " + s/[']//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 "READY." && eval "`readline`" ; do - #echo "command: $command; args: $args" +## +## +## +export noise_prompt="READY. +" +export noise_default_command=espeak +## +## +## +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 shift - NOISE="$0" NOISE_linefeed="$linefeed" "$module" $args + eval 'NOISE="$0" NOISE_linefeed="$linefeed" "$module"' "$args" continue 2 fi done ## funcall if type noise_$command &>/dev/null ; then - noise_$command $args + eval 'noise_$command' "$args" continue fi ## @@ -94,7 +110,6 @@ EOF ## ## exec >>$linefeed -echo /set default_command espeak while read ; do case $REPLY in (/quit) echo /quit ; exit ;; -- cgit v1.2.3 From 17be93d900c586ac34d9cab50e4b6622402a48d9 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 5 May 2010 00:02:41 +0200 Subject: noise/modules/espeak: nicer variable-printer --- modules/espeak | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/modules/espeak b/modules/espeak index cda70fc8..1f5c901d 100755 --- a/modules/espeak +++ b/modules/espeak @@ -1,4 +1,9 @@ #! /bin/sh + +print_var() { + echo "$1 = $2" +} + case "$1" in (--help) echo say something with espeak ;; (*) @@ -7,11 +12,11 @@ case "$1" in k="${noise_capital-0}" a="${noise_amplitude-100}" g="${noise_gap-1}" - echo pitch: $p - echo lang: $v - echo capital: $k - echo amplitude: $a - echo gap: $g + print_var pitch $p + print_var lang $v + print_var capital $k + 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< Date: Wed, 5 May 2010 00:04:01 +0200 Subject: noise/modules/zeit: strip zeros from %M --- modules/zeit | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/zeit b/modules/zeit index 0b0537d3..340d6fce 100755 --- a/modules/zeit +++ b/modules/zeit @@ -5,10 +5,14 @@ case "$1" in echo "say current time" ;; (*) exec >>$NOISE_linefeed + eval `date +'k=%k ; M=%M'` + M=`echo $M | sed 's/0*//'` echo /set pitch 10 case "$lang" in - (de|'') date +'"Es ist %k Uhr %M."' >$NOISE_linefeed ;; - (en|*-en) date +'"It is %k o clock and %M minutes"' >$NOISE_linefeed ;; + (de|'') echo " Es ist $k Uhr $M" >$NOISE_linefeed ;; + (en|*-en) + test -z "$M" || M="and $M minutes" + echo " It is $k o clock $M" >$NOISE_linefeed ;; (*) echo "Error: unsupported lang = $lang" >&2 esac echo /set pitch ${noise_pitch-100} -- cgit v1.2.3 From c4fcfb77c6e96b72da28740cdc9fdd326e297c87 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 5 May 2010 00:06:45 +0200 Subject: noise: bumped version to 0.9 beta 3 --- noise | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noise b/noise index 9fc7e6e2..11976f68 100755 --- a/noise +++ b/noise @@ -102,7 +102,7 @@ jobs="${jobs+$jobs }`jobs -p`" ## ## cat< Date: Wed, 5 May 2010 00:14:43 +0200 Subject: noise/modules/zeit: strip zeros moar correct :-) --- modules/zeit | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/zeit b/modules/zeit index 340d6fce..75ffc20a 100755 --- a/modules/zeit +++ b/modules/zeit @@ -5,8 +5,8 @@ case "$1" in echo "say current time" ;; (*) exec >>$NOISE_linefeed - eval `date +'k=%k ; M=%M'` - M=`echo $M | sed 's/0*//'` + k=`date +%k` + M=`date +%M|sed 's/0*//'` echo /set pitch 10 case "$lang" in (de|'') echo " Es ist $k Uhr $M" >$NOISE_linefeed ;; -- cgit v1.2.3 From de52c85164a0f98dee94d62b824dd2360cd77d54 Mon Sep 17 00:00:00 2001 From: "shackspace e.V" Date: Thu, 6 May 2010 22:36:57 +0200 Subject: initial commit number two --- modules/atwall | 11 +++++++++++ modules/join | 14 ++++++++++++++ modules/test | 10 +++++++--- modules/twitter | 10 +++++----- 4 files changed, 37 insertions(+), 8 deletions(-) create mode 100755 modules/atwall create mode 100755 modules/join diff --git a/modules/atwall b/modules/atwall new file mode 100755 index 00000000..66fca5e6 --- /dev/null +++ b/modules/atwall @@ -0,0 +1,11 @@ +#! /bin/sh + +case "$1" in + (--help) echo send text to everyone with @@ prepended ;; + (q) + echo quit chat mode + echo /set default_command espeak >$NOISE_linefeed;; + + (*) + echo /wall @@ $* >$NOISE_linefeed +esac diff --git a/modules/join b/modules/join new file mode 100755 index 00000000..af1c0117 --- /dev/null +++ b/modules/join @@ -0,0 +1,14 @@ +#! /bin/sh + +case "$1" in + (--help) echo set default_command to atwall and back ;; + (off) + echo /set default_command espeak >$NOISE_linefeed + echo "disabled chat mode (set back to espeak)" ;; + (*) + echo /set default_command atwall >$NOISE_linefeed + echo "enabled chat mode" + echo q or /chat off to go back to espeak ;; + + +esac diff --git a/modules/test b/modules/test index 30444bf7..2c0b8e0d 100755 --- a/modules/test +++ b/modules/test @@ -3,7 +3,11 @@ case "$1" in (--help) echo do some test-module related stuff ;; (*) - echo test-module called with following arguments: "$@" - ## send command for re-evaluation: - echo /espeak test >$NOISE_linefeed + + 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 index e8962657..fa4d366d 100755 --- a/modules/twitter +++ b/modules/twitter @@ -33,7 +33,7 @@ def parse(text): escape = "" if piece.startswith("@"): escape = "" - if piece[1:].lower() == "shackspace": + if piece[1:].lower() == "shackspam" or piece[1:].lower() == "shackspace": escape = "" elif piece.startswith("#"): @@ -48,16 +48,16 @@ def parse(text): return new if len(sys.argv) > 1 and sys.argv[1] == "--help": - print "read or post to the shackspace twitter timeline" + 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 shackspace twitter timeline" + print "use /twitter [your tweet] to tweet something to the shackspam twitter timeline" exit() -api = twitter.Api(username="shackspace", password="0b0dallaf4lla") +api = twitter.Api(username="shackspam", password="sh4ckit") #api.SetXTwitterHeaders("Shackspace UTTERANCE","","0.00.0.01.42") @@ -93,7 +93,7 @@ else: a.reverse() for i in a: text = i.text - if i.user.screen_name.lower() == "shackspace": + 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()) + "" -- cgit v1.2.3 From f199aff05248164cc49391de2e9785416e9902fb Mon Sep 17 00:00:00 2001 From: "shackspace e.V" Date: Thu, 6 May 2010 22:47:01 +0200 Subject: prepared /join and /part for room based chatting --- modules/atwall | 11 ----------- modules/chat | 11 +++++++++++ modules/join | 10 ++++------ modules/part | 10 ++++++++++ 4 files changed, 25 insertions(+), 17 deletions(-) delete mode 100755 modules/atwall create mode 100755 modules/chat create mode 100755 modules/part diff --git a/modules/atwall b/modules/atwall deleted file mode 100755 index 66fca5e6..00000000 --- a/modules/atwall +++ /dev/null @@ -1,11 +0,0 @@ -#! /bin/sh - -case "$1" in - (--help) echo send text to everyone with @@ prepended ;; - (q) - echo quit chat mode - echo /set default_command espeak >$NOISE_linefeed;; - - (*) - echo /wall @@ $* >$NOISE_linefeed -esac diff --git a/modules/chat b/modules/chat new file mode 100755 index 00000000..66fca5e6 --- /dev/null +++ b/modules/chat @@ -0,0 +1,11 @@ +#! /bin/sh + +case "$1" in + (--help) echo send text to everyone with @@ prepended ;; + (q) + echo quit chat mode + echo /set default_command espeak >$NOISE_linefeed;; + + (*) + echo /wall @@ $* >$NOISE_linefeed +esac diff --git a/modules/join b/modules/join index af1c0117..0e0bec2a 100755 --- a/modules/join +++ b/modules/join @@ -1,14 +1,12 @@ #! /bin/sh case "$1" in - (--help) echo set default_command to atwall and back ;; - (off) - echo /set default_command espeak >$NOISE_linefeed - echo "disabled chat mode (set back to espeak)" ;; + (--help) echo set default_command to chat and join channel ;; (*) echo /set default_command atwall >$NOISE_linefeed - echo "enabled chat mode" - echo q or /chat off to go back to espeak ;; + echo /set chat_channel $1 >$NOISE_linefeed + echo "joined channel $1" + echo /part off to go back to espeak ;; esac diff --git a/modules/part b/modules/part new file mode 100755 index 00000000..beb95163 --- /dev/null +++ b/modules/part @@ -0,0 +1,10 @@ +#! /bin/sh + +case "$1" in + (--help) echo leave chat mode ;; + (*) + echo /set default_command espeak >$NOISE_linefeed + echo "disabled chat mode (set back to espeak)" ;; + + +esac -- cgit v1.2.3 From 47361ddde830e7ce4653d33d380e4d66bed9c1b4 Mon Sep 17 00:00:00 2001 From: "shackspace e.V" Date: Thu, 6 May 2010 22:47:45 +0200 Subject: fixed join (atwall) --- modules/join | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/join b/modules/join index 0e0bec2a..2705abac 100755 --- a/modules/join +++ b/modules/join @@ -3,7 +3,7 @@ case "$1" in (--help) echo set default_command to chat and join channel ;; (*) - echo /set default_command atwall >$NOISE_linefeed + echo /set default_command chat >$NOISE_linefeed echo /set chat_channel $1 >$NOISE_linefeed echo "joined channel $1" echo /part off to go back to espeak ;; -- cgit v1.2.3 From 81344217c8a54e46d7cfc38466303d046e08e77f Mon Sep 17 00:00:00 2001 From: root Date: Fri, 7 May 2010 02:01:02 +0200 Subject: noise: write /set'ed variables to $env Additionally: - Export $TCPREMOTIP to noise and modules. - Hardwired $HOME in noise. ;-) - Read ~% as Newline. --- noise | 26 +++++++++++++++++++------- noise-as-shack | 2 +- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/noise b/noise index 11976f68..0e60bbf2 100755 --- a/noise +++ b/noise @@ -29,6 +29,12 @@ noise_set() { # set a variable 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 } @@ -44,26 +50,30 @@ fail() { } cleanup() { - rm -f $linefeed + rm -f $linefeed $env kill $jobs } qname="`readlink -f "$0"`" dirname="`dirname "$qname"`" +export HOME='/home/shack' 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 linefeed="/tmp/noise-client-$$" +env="/tmp/noise-client-$$-env" trap cleanup EXIT mkfifo $linefeed +touch $env ## ## ## readline() { { read && echo "$REPLY" ; } | sed -rn " s/[']//g + s/~%/\n/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 @@ -73,12 +83,6 @@ readline() { ## ## ## -export noise_prompt="READY. -" -export noise_default_command=espeak -## -## -## while echo -n "$noise_prompt" && eval "`readline`" ; do ## modcall for dir in `echo "$NOISE_PATH" | tr : \ ` ; do @@ -110,6 +114,14 @@ EOF ## ## exec >>$linefeed +## +## +## +echo '/set prompt "READY.~%"' +echo '/set default_command espeak' +## +## +## while read ; do case $REPLY in (/quit) echo /quit ; exit ;; diff --git a/noise-as-shack b/noise-as-shack index c327bb81..10ae3c1c 100755 --- a/noise-as-shack +++ b/noise-as-shack @@ -1,4 +1,4 @@ #! /bin/sh qname="`readlink -f "$0"`" dirname="`dirname "$qname"`" -exec su - shack -c "$dirname"/noise +exec su - shack -c "env -i TCPREMOTEIP=\"$TCPREMOTEIP\" \"$dirname/noise\"" -- cgit v1.2.3 From b9a22654b96cf5a32f227ef6991ea81176cacb50 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 7 May 2010 02:24:01 +0200 Subject: noise: use folders for connected clients Additionally export $NOISE_pid to modules. --- modules/wall | 5 ++--- noise | 11 +++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/modules/wall b/modules/wall index fa7618fe..7c32d01d 100755 --- a/modules/wall +++ b/modules/wall @@ -2,8 +2,7 @@ case "$1" in (--help) : ;; (?*) - for client in /tmp/noise-client-* ; do - #echo /msg "$*`printf '\a'`" >$client - echo /msg "$*" >$client + for linefeed in /tmp/noise/*/linefeed ; do + echo /msg "$*" >$linefeed done esac diff --git a/noise b/noise index 0e60bbf2..2b63acbe 100755 --- a/noise +++ b/noise @@ -50,8 +50,10 @@ fail() { } cleanup() { - rm -f $linefeed $env kill $jobs + rm -f $linefeed $env + rmdir /tmp/noise/$$ 2>/dev/null + rmdir /tmp/noise 2>/dev/null } @@ -62,8 +64,9 @@ 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 -linefeed="/tmp/noise-client-$$" -env="/tmp/noise-client-$$-env" +mkdir -vp /tmp/noise/$$ +linefeed="/tmp/noise/$$/linefeed" +env="/tmp/noise/$$/environment" trap cleanup EXIT mkfifo $linefeed touch $env @@ -89,7 +92,7 @@ while echo -n "$noise_prompt" && eval "`readline`" ; do module="$dir/$command" if test -x "$module" ; then shift - eval 'NOISE="$0" NOISE_linefeed="$linefeed" "$module"' "$args" + eval 'NOISE="$0" NOISE_pid="$$" NOISE_linefeed="$linefeed" "$module"' "$args" continue 2 fi done -- cgit v1.2.3 From 0b25165144fb6a6c0e63df62bf282f13465baa82 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 7 May 2010 03:45:50 +0200 Subject: renamed module msg to echo --- modules/echo | 6 ++++++ modules/msg | 6 ------ 2 files changed, 6 insertions(+), 6 deletions(-) create mode 100755 modules/echo delete mode 100755 modules/msg diff --git a/modules/echo b/modules/echo new file mode 100755 index 00000000..344dd963 --- /dev/null +++ b/modules/echo @@ -0,0 +1,6 @@ +#! /bin/sh +case "$1" in + (--help) : ;; + (*) + echo "$*" +esac diff --git a/modules/msg b/modules/msg deleted file mode 100755 index 344dd963..00000000 --- a/modules/msg +++ /dev/null @@ -1,6 +0,0 @@ -#! /bin/sh -case "$1" in - (--help) : ;; - (*) - echo "$*" -esac -- cgit v1.2.3 From f06c19d559b1dd80cc0f4adf39a78257ecf2219e Mon Sep 17 00:00:00 2001 From: "shackspace e.V" Date: Fri, 7 May 2010 04:02:27 +0200 Subject: split nick and names from chat --- modules/chat | 34 ++++++++++++++++++++++++++++------ modules/names | 21 +++++++++++++++++++++ modules/nick | 10 ++++++++++ 3 files changed, 59 insertions(+), 6 deletions(-) create mode 100755 modules/names create mode 100755 modules/nick diff --git a/modules/chat b/modules/chat index 66fca5e6..e5badc36 100755 --- a/modules/chat +++ b/modules/chat @@ -2,10 +2,32 @@ case "$1" in (--help) echo send text to everyone with @@ prepended ;; - (q) - echo quit chat mode - echo /set default_command espeak >$NOISE_linefeed;; - - (*) - echo /wall @@ $* >$NOISE_linefeed + (/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/names b/modules/names new file mode 100755 index 00000000..750917a5 --- /dev/null +++ b/modules/names @@ -0,0 +1,21 @@ +#! /bin/sh + +case "$1" in + (--help) echo send text to everyone with @@ prepended ;; + (*) + cd /tmp/noise + . $NOISE_pid/environment + 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 new file mode 100755 index 00000000..b60a7433 --- /dev/null +++ b/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 $nick is now known as $2 > $NOISE_linefeed + echo /set chat_nick $2 >$NOISE_linefeed;; +esac -- cgit v1.2.3 From 29e111bd9921c3730c751a059e449af765d551a4 Mon Sep 17 00:00:00 2001 From: "shackspace e.V" Date: Fri, 7 May 2010 04:03:59 +0200 Subject: added module send_to_channel --- modules/send_to_channel | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100755 modules/send_to_channel diff --git a/modules/send_to_channel b/modules/send_to_channel new file mode 100755 index 00000000..4a0470af --- /dev/null +++ b/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 -- cgit v1.2.3 From 0cd01b51b46f270a8232f3b525bcde06ffe58c4e Mon Sep 17 00:00:00 2001 From: root Date: Fri, 7 May 2010 04:05:52 +0200 Subject: noise: allow '#'s in input and '_' in module-names --- noise | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/noise b/noise index 2b63acbe..f979c34c 100755 --- a/noise +++ b/noise @@ -77,7 +77,8 @@ readline() { { read && echo "$REPLY" ; } | sed -rn " s/[']//g s/~%/\n/g - s:^/([a-z]+)([[:space:]]+(.*))?$:command=\1; args='\3';:p;t + s/([^\\])#/\1\\\\#/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 -- cgit v1.2.3 From 71fa84f005bb73e813a34e78dd4cb58a072b3879 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 7 May 2010 04:06:42 +0200 Subject: Added module: sleep --- modules/sleep | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100755 modules/sleep diff --git a/modules/sleep b/modules/sleep new file mode 100755 index 00000000..b8d350f7 --- /dev/null +++ b/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 + echo 'FAIL: $1 is not a number' + else + sleep "$1" + fi +esac -- cgit v1.2.3 From d8b74770d5ed5e724c9c145dbb894cbb2ec99acb Mon Sep 17 00:00:00 2001 From: root Date: Fri, 7 May 2010 04:11:00 +0200 Subject: Added module: date --- modules/date | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100755 modules/date diff --git a/modules/date b/modules/date new file mode 100755 index 00000000..8cd1b0c1 --- /dev/null +++ b/modules/date @@ -0,0 +1,6 @@ +#! /bin/sh +case "$1" in + (--help) : ;; + (*) + date --rfc-3339=s +esac -- cgit v1.2.3 From f77ad7ef9f1ebb63716a754315e878aabe2eee62 Mon Sep 17 00:00:00 2001 From: "shackspace e.V" Date: Fri, 7 May 2010 04:22:49 +0200 Subject: added additional check for default_command --- modules/names | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/names b/modules/names index 750917a5..f5922064 100755 --- a/modules/names +++ b/modules/names @@ -5,6 +5,7 @@ case "$1" in (*) 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" -- cgit v1.2.3 From cc7314993b00d4f94c5837f36a4854ba6420350e Mon Sep 17 00:00:00 2001 From: "shackspace e.V" Date: Fri, 7 May 2010 04:27:16 +0200 Subject: telling the others who parted --- modules/part | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/part b/modules/part index beb95163..d35ac501 100755 --- a/modules/part +++ b/modules/part @@ -3,6 +3,11 @@ 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)" ;; -- cgit v1.2.3 From 5664f6beafe6a7796835dc1c5be7bac4a0c4aa65 Mon Sep 17 00:00:00 2001 From: "shackspace e.V" Date: Fri, 7 May 2010 04:28:14 +0200 Subject: now telling who joined --- modules/join | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/join b/modules/join index 2705abac..68afcb66 100755 --- a/modules/join +++ b/modules/join @@ -3,10 +3,13 @@ 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 >$NOISE_linefeed - echo "joined channel $1" - echo /part off to go back to espeak ;; + echo /set chat_channel "${1-#23}" >$NOISE_linefeed + echo " joined channel ${1-#23}" + echo /part to go back to espeak ;; esac -- cgit v1.2.3 From c83842518c14a7c258e06baf9fe45a93b5d159e8 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 7 May 2010 04:28:49 +0200 Subject: zeit: use /espeak instead of $default_command --- modules/zeit | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/zeit b/modules/zeit index 75ffc20a..4c41fa10 100755 --- a/modules/zeit +++ b/modules/zeit @@ -9,10 +9,10 @@ case "$1" in M=`date +%M|sed 's/0*//'` echo /set pitch 10 case "$lang" in - (de|'') echo " Es ist $k Uhr $M" >$NOISE_linefeed ;; + (de|'') echo "/espeak Es ist $k Uhr $M" ;; (en|*-en) test -z "$M" || M="and $M minutes" - echo " It is $k o clock $M" >$NOISE_linefeed ;; + echo "/espeak It is $k o clock $M" ;; (*) echo "Error: unsupported lang = $lang" >&2 esac echo /set pitch ${noise_pitch-100} -- cgit v1.2.3 From 4830460590cf013cb79df8d04b96ebaf725db6af Mon Sep 17 00:00:00 2001 From: "shackspace e.V" Date: Fri, 7 May 2010 04:31:49 +0200 Subject: nick: fixed not telling others, fixed not working AT ALL --- modules/nick | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/nick b/modules/nick index b60a7433..5ed1e9d9 100755 --- a/modules/nick +++ b/modules/nick @@ -5,6 +5,6 @@ case "$1" in (*) . /tmp/noise/$NOISE_pid/environment nick="${chat_nick-$NOISE_pid}" - echo /send_to_channel $nick is now known as $2 > $NOISE_linefeed - echo /set chat_nick $2 >$NOISE_linefeed;; + echo /send_to_channel $chat_channel $nick is now known as $1 > $NOISE_linefeed + echo /set chat_nick $1 >$NOISE_linefeed;; esac -- cgit v1.2.3 From 6abf375996b0f28a7ebba80d9f0052c1f1394788 Mon Sep 17 00:00:00 2001 From: "shackspace e.V" Date: Fri, 7 May 2010 04:34:21 +0200 Subject: twitter: fixed the "a"-bug, fixed 81 width --- modules/twitter | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/twitter b/modules/twitter index fa4d366d..49d092fb 100755 --- a/modules/twitter +++ b/modules/twitter @@ -22,6 +22,7 @@ def shorten(text): text = text.replace(" years", "y") text = text.replace(" year", "y") text = text.replace(" ago", "") + text = text.replace("a", "1") return text @@ -93,6 +94,7 @@ else: 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: @@ -102,12 +104,12 @@ else: t = text.split(" ") tmp = "" for n in t: - if ((len(tmp) + len(n)) > 80): + if ((len(tmp) + len(n)) >= 80): print parse(tmp).encode("utf8") - tmp = " " *( len(info)-15) + tmp = " " * ilen tmp += " " + n - if len(tmp) > (len(info)-15+1): + if len(tmp) > ilen: print parse(tmp).encode("utf8") -- cgit v1.2.3 From 50be3334a221c7e7a1b20eb8f1da481d7e9e9729 Mon Sep 17 00:00:00 2001 From: "shackspace e.V" Date: Fri, 7 May 2010 04:36:26 +0200 Subject: added .gitignore for samples --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..81154dd4 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +samples -- cgit v1.2.3 From 04fa9b3513d909cf71554b01c6c7bd883e964cf4 Mon Sep 17 00:00:00 2001 From: "shackspace e.V" Date: Fri, 7 May 2010 04:42:48 +0200 Subject: added query command to whisper users --- modules/query | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 modules/query diff --git a/modules/query b/modules/query new file mode 100755 index 00000000..dd6f415a --- /dev/null +++ b/modules/query @@ -0,0 +1,20 @@ +#! /bin/sh + +case "$1" in + (--help) echo send a message to a specific user ;; + (*) + cd /tmp/noise + nick="$1" + shift + for client in * ; do + . $client/environment + if test "$nick" = "${chat_nick-$client}" ; then + echo "/echo $*" > $client/linefeed + exit + fi + unset chat_channel + + done + + echo "$nick not found" +esac -- cgit v1.2.3 From bd0a3e505cb4384101a4a044fe52a6a1ed4d5e7f Mon Sep 17 00:00:00 2001 From: "shackspace e.V" Date: Fri, 7 May 2010 04:50:48 +0200 Subject: fixed query not working AT ALL --- modules/query | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/modules/query b/modules/query index dd6f415a..ceeff8a5 100755 --- a/modules/query +++ b/modules/query @@ -4,13 +4,16 @@ case "$1" in (--help) echo send a message to a specific user ;; (*) cd /tmp/noise - nick="$1" + . $NOISE_pid/environment + nick="${chat_nick-$NOISE_pid}" + target="$1" shift for client in * ; do . $client/environment - if test "$nick" = "${chat_nick-$client}" ; then - echo "/echo $*" > $client/linefeed - exit + if test "$target" = "${chat_nick-$client}" ; then + echo "/echo <-- $nick: $*" > $client/linefeed + echo "--> $target: $*" + exit fi unset chat_channel -- cgit v1.2.3 From 8b7cd604d16b5f01128dda2927dde2c8dfe1f2dd Mon Sep 17 00:00:00 2001 From: root Date: Fri, 7 May 2010 04:50:54 +0200 Subject: noise: escape '<' and '>' in reader --- noise | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noise b/noise index f979c34c..cb4b8531 100755 --- a/noise +++ b/noise @@ -77,7 +77,7 @@ readline() { { read && echo "$REPLY" ; } | sed -rn " s/[']//g s/~%/\n/g - s/([^\\])#/\1\\\\#/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 -- cgit v1.2.3 From 36f54e3f90c0401bad7f4c59f47554e5026f754c Mon Sep 17 00:00:00 2001 From: root Date: Fri, 7 May 2010 10:02:00 +0200 Subject: bumped 23.shack to version 0.9 beta 4 --- noise | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noise b/noise index cb4b8531..375d177c 100755 --- a/noise +++ b/noise @@ -110,7 +110,7 @@ jobs="${jobs+$jobs }`jobs -p`" ## ## cat< Date: Fri, 7 May 2010 10:12:12 +0200 Subject: help: uniq, b/c we've got alot of mirrors ;-) --- modules/help | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/help b/modules/help index 48c06686..e9dba2fe 100755 --- a/modules/help +++ b/modules/help @@ -8,7 +8,7 @@ case "$1" in done ## print all documented built-in commands sed -rn 's:^noise_([a-z]+)\(\) \{ # (.+)?$:\1 \2:p' "$NOISE" - } | sort | sed -rn ' + } | sort | uniq | sed -rn ' $s/$// s:^([a-z]+) (.+):type /\1 to \2:p' ;; (*) -- cgit v1.2.3 From 2faba42f525a4c03754e87e60075a6b0ac985374 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 7 May 2010 10:50:14 +0200 Subject: Added TODO --- TODO | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 TODO diff --git a/TODO b/TODO new file mode 100644 index 00000000..f3c9b4ca --- /dev/null +++ b/TODO @@ -0,0 +1,63 @@ +#### 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 +- 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 + + +- /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] +- 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... + +#### end of file. -- cgit v1.2.3 From d548d07b4d7053d234a057be6df0c2a455db3bcc Mon Sep 17 00:00:00 2001 From: root Date: Fri, 7 May 2010 11:59:39 +0200 Subject: Updated MOTD --- noise | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/noise b/noise index 375d177c..9d4f815f 100755 --- a/noise +++ b/noise @@ -110,10 +110,32 @@ jobs="${jobs+$jobs }`jobs -p`" ## ## cat<>$linefeed ## ## ## -echo '/set prompt "READY.~%"' -echo '/set default_command espeak' +echo '/set -q default_command espeak' +echo '/set -q prompt "READY.~%"' ## ## ## -- cgit v1.2.3 From 9e24cf1941f87a294e5f9d212caac643ded27209 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 8 May 2010 02:18:52 +0200 Subject: zeit: s/1/ein/ --- modules/zeit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 -- cgit v1.2.3 From 82d487a0db225d35dd6bf4e0751508a9ab9bef9d Mon Sep 17 00:00:00 2001 From: root Date: Sat, 8 May 2010 02:19:15 +0200 Subject: Added builtin /unset --- noise | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/noise b/noise index 9d4f815f..dcef9f9e 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 -- cgit v1.2.3 From e140034c2e1841857a4978e861c943b757ac712c Mon Sep 17 00:00:00 2001 From: root Date: Sat, 8 May 2010 02:26:06 +0200 Subject: Shrinked TODO --- TODO | 4 ---- 1 file changed, 4 deletions(-) diff --git a/TODO b/TODO index f3c9b4ca..1a05048f 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 @@ -46,10 +44,8 @@ - /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] -- cgit v1.2.3 From 758be77cd81c4d9f44eae1506e5dc929df4daa3b Mon Sep 17 00:00:00 2001 From: root Date: Sat, 8 May 2010 02:57:21 +0200 Subject: wall: use /echo instead the (now dead) /msg --- modules/wall | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 -- cgit v1.2.3 From 5b8e9b8701457644199d1e4e6295a24abbe0c9e4 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 21 Jun 2010 21:26:32 +0000 Subject: noise: changed way commit is read out --- noise | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/noise b/noise index dcef9f9e..c410168c 100755 --- a/noise +++ b/noise @@ -72,7 +72,7 @@ cleanup() { rmdir /tmp/noise 2>/dev/null } - +exec 2>&1 qname="`readlink -f "$0"`" dirname="`dirname "$qname"`" export HOME='/home/shack' @@ -80,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 @@ -127,7 +127,10 @@ jobs="${jobs+$jobs }`jobs -p`" ## cat</dev/null +`...  ## Motto Of The Day\  -- cgit v1.2.3 From 3f77df40b1d127e54bab735bbc14cd57a56b78ca Mon Sep 17 00:00:00 2001 From: root Date: Sat, 25 Sep 2010 01:08:39 +0000 Subject: play: changed "file not found"-comment --- modules/play | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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<