summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorshackspace e.V <shack@shack.(none)>2010-05-02 22:46:15 +0200
committershackspace e.V <shack@shack.(none)>2010-05-02 22:46:15 +0200
commit1849640f86e84440c4920018fb9be6f5bff5bfc8 (patch)
treebf8fb5797eb8469b398bce0fb27a03a2d68894f0 /modules
initially added modules
Diffstat (limited to 'modules')
-rwxr-xr-xmodules/mpc14
-rwxr-xr-xmodules/test9
-rwxr-xr-xmodules/twitter116
-rwxr-xr-xmodules/vvs17
4 files changed, 156 insertions, 0 deletions
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