diff options
Diffstat (limited to 'modules')
-rwxr-xr-x | modules/chat | 33 | ||||
-rwxr-xr-x | modules/date | 6 | ||||
-rwxr-xr-x | modules/echo (renamed from modules/msg) | 0 | ||||
-rwxr-xr-x | modules/join | 15 | ||||
-rwxr-xr-x | modules/names | 22 | ||||
-rwxr-xr-x | modules/nick | 10 | ||||
-rwxr-xr-x | modules/part | 15 | ||||
-rwxr-xr-x | modules/query | 23 | ||||
-rwxr-xr-x | modules/send_to_channel | 17 | ||||
-rwxr-xr-x | modules/sleep | 10 | ||||
-rwxr-xr-x | modules/test | 10 | ||||
-rwxr-xr-x | modules/twitter | 18 | ||||
-rwxr-xr-x | modules/wall | 5 | ||||
-rwxr-xr-x | modules/zeit | 4 |
14 files changed, 172 insertions, 16 deletions
diff --git a/modules/chat b/modules/chat new file mode 100755 index 00000000..e5badc36 --- /dev/null +++ b/modules/chat @@ -0,0 +1,33 @@ +#! /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 "[34mUsers in channel [4m$channel[m" + for client in * ; do + . $client/environment + chat_nick="${chat_nick-$client}" + if test "$channel" = "$chat_channel" && test "$default_command" = chat ; then + echo "[33m$chat_nick[m" + 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 [33m$nick:[m $*" > $NOISE_linefeed + + + #echo /wall [33m@@[m $* >$NOISE_linefeed +esac 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 diff --git a/modules/msg b/modules/echo index 344dd963..344dd963 100755 --- a/modules/msg +++ b/modules/echo diff --git a/modules/join b/modules/join new file mode 100755 index 00000000..68afcb66 --- /dev/null +++ b/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 "[32m joined channel ${1-#23}[m" + echo /part to go back to espeak ;; + + +esac diff --git a/modules/names b/modules/names new file mode 100755 index 00000000..f5922064 --- /dev/null +++ b/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 "[34mUsers in channel [4m$channel[m" + for client in * ; do + . $client/environment + chat_nick="${chat_nick-$client}" + if test "$channel" = "$chat_channel" && test "$default_command" = chat ; then + echo "[33m$chat_nick[m" + 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..5ed1e9d9 --- /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 $chat_channel $nick is now known as $1 > $NOISE_linefeed + echo /set chat_nick $1 >$NOISE_linefeed;; +esac diff --git a/modules/part b/modules/part new file mode 100755 index 00000000..d35ac501 --- /dev/null +++ b/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 [4m${*-no reason}[m" > $NOISE_linefeed + + echo /set default_command espeak >$NOISE_linefeed + echo "[32mdisabled chat mode (set back to espeak)[m" ;; + + +esac diff --git a/modules/query b/modules/query new file mode 100755 index 00000000..ceeff8a5 --- /dev/null +++ b/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/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 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 '[31;1mFAIL: $1 is not a number[m' + else + sleep "$1" + fi +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 [33m@@[m $TEST >$NOISE_linefeed + #sleep 1 + #sleep 1; echo /test >$NOISE_linefeed & esac diff --git a/modules/twitter b/modules/twitter index e8962657..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 @@ -33,7 +34,7 @@ def parse(text): escape = "" if piece.startswith("@"): escape = "[33;4m" - if piece[1:].lower() == "shackspace": + if piece[1:].lower() == "shackspam" or piece[1:].lower() == "shackspace": escape = "[31;4m" elif piece.startswith("#"): @@ -48,16 +49,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 +94,8 @@ else: a.reverse() for i in a: text = i.text - if i.user.screen_name.lower() == "shackspace": + 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 = "[32;4m" + i.user.screen_name + "[m [34m" + shorten(i.GetRelativeCreatedAt()) + "[m" else: info = "[32m" + i.user.screen_name + "[m [34m" + shorten(i.GetRelativeCreatedAt()) + "[m" @@ -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") 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/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 "[31mError: unsupported [4mlang[0;31m = $lang[m" >&2 esac echo /set pitch ${noise_pitch-100} |