diff options
| author | root <root@shack.(none)> | 2010-05-07 04:34:49 +0200 | 
|---|---|---|
| committer | root <root@shack.(none)> | 2010-05-07 04:34:49 +0200 | 
| commit | c47b0ac32302fdbeed13f45a82d3e8c420de8fbd (patch) | |
| tree | 528714f721df35547e67bdffcb6b1339bfa10e62 | |
| parent | c83842518c14a7c258e06baf9fe45a93b5d159e8 (diff) | |
| parent | 4830460590cf013cb79df8d04b96ebaf725db6af (diff) | |
Merge branch 'master' of /home/shack/noise
| -rwxr-xr-x | modules/chat | 33 | ||||
| -rwxr-xr-x | modules/join | 15 | ||||
| -rwxr-xr-x | modules/mpc | 14 | ||||
| -rwxr-xr-x | modules/names | 22 | ||||
| -rwxr-xr-x | modules/nick | 10 | ||||
| -rwxr-xr-x | modules/part | 15 | ||||
| -rwxr-xr-x | modules/send_to_channel | 17 | ||||
| -rwxr-xr-x | modules/test | 13 | ||||
| -rwxr-xr-x | modules/twitter | 116 | ||||
| -rwxr-xr-x | modules/vvs | 17 | 
10 files changed, 272 insertions, 0 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/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/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/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/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/test b/modules/test new file mode 100755 index 00000000..2c0b8e0d --- /dev/null +++ b/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 [33m@@[m $TEST >$NOISE_linefeed +    #sleep 1 +    #sleep 1; echo /test >$NOISE_linefeed & +esac diff --git a/modules/twitter b/modules/twitter new file mode 100755 index 00000000..fa4d366d --- /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 = "[33;4m" +			if piece[1:].lower() == "shackspam" or piece[1:].lower() == "shackspace": +				escape = "[31;4m" +				 +		elif piece.startswith("#"): +			escape = "[35m" +		elif piece.startswith("http://"): +			escape = "[36;4m" +		if escape: +			new += escape + piece + "[m " +		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(username="shackspam", password="sh4ckit") + +#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: [32;1m" + str(len(tweet)) + u"[m" + +	if len(tweet) > 140: +		print u"[31;6mYour Tweet must be shorter than 140 characters.[m\n" +		exit() +	 +	status = api.PostUpdate(tweet) +	 +	 +	 + +else:	 +	"""print "\t[31;4mshackspace tweets:[m" +	for i in api.GetUserTimeline(): +		i.text = parse(i.text) +		print ("[32m" + i.user.screen_name + "[m [34m" + i.GetRelativeCreatedAt() + "[m " + i.text).encode("utf8").replace("\n"," ") +	 +	print "\n\t[31;4mfriends tweets[m" +	""" +	a = api.GetFriendsTimeline() +	a.reverse() +	for i in a: +		text = i.text +		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"  +		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 "[31mSyntax: /vvs [ORIGIN DESTINATION][m" ; return ;; +    esac +esac  | 
