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 (limited to 'modules') 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 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 (limited to 'modules') 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 (limited to 'modules') 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(-) (limited to 'modules') 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 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 (limited to 'modules') 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 (limited to 'modules') 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 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(+) (limited to 'modules') 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(+) (limited to 'modules') 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(-) (limited to 'modules') 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 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(-) (limited to 'modules') 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 [cgit] Unable to lock slot /tmp/cgit/92300000.lock: Permission denied (13)