summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authortv <tv@also>2010-05-07 04:52:10 +0200
committertv <tv@also>2010-05-07 04:52:10 +0200
commitee937603bb8ad9b18d03113bee4759811748d337 (patch)
treeea4cff25143181f66053d2e4367deea656d62388 /modules
parent75d12a3ba0c0a2bc9adaeb6660757d8dfdff6f1e (diff)
parente164088a38e067b4456cf131a260e3cdd90d0fb3 (diff)
Merge ssh://shack/~/noise
Diffstat (limited to 'modules')
-rwxr-xr-xmodules/chat33
-rwxr-xr-xmodules/date6
-rwxr-xr-xmodules/echo (renamed from modules/msg)0
-rwxr-xr-xmodules/join15
-rwxr-xr-xmodules/names22
-rwxr-xr-xmodules/nick10
-rwxr-xr-xmodules/part15
-rwxr-xr-xmodules/query23
-rwxr-xr-xmodules/send_to_channel17
-rwxr-xr-xmodules/sleep10
-rwxr-xr-xmodules/test10
-rwxr-xr-xmodules/twitter18
-rwxr-xr-xmodules/wall5
-rwxr-xr-xmodules/zeit4
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 "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
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 " joined channel ${1-#23}"
+ 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 "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..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 ${*-no reason}" > $NOISE_linefeed
+
+ echo /set default_command espeak >$NOISE_linefeed
+ echo "disabled chat mode (set back to espeak)" ;;
+
+
+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 'FAIL: $1 is not a number'
+ 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 @@ $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 = ""
- if piece[1:].lower() == "shackspace":
+ if piece[1:].lower() == "shackspam" or piece[1:].lower() == "shackspace":
escape = ""
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 = "" + i.user.screen_name + " " + shorten(i.GetRelativeCreatedAt()) + ""
else:
info = "" + i.user.screen_name + " " + shorten(i.GetRelativeCreatedAt()) + ""
@@ -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 "Error: unsupported lang = $lang" >&2
esac
echo /set pitch ${noise_pitch-100}