summaryrefslogtreecommitdiffstats
path: root/god/twinter
diff options
context:
space:
mode:
authorroot <root@monitoring.shack>2012-09-13 23:39:42 +0000
committerroot <root@monitoring.shack>2012-09-13 23:39:42 +0000
commitd5d39fc3d56b021b642ee6e1d5625524ebbc4d99 (patch)
treed5bd5a82e5f1beeb53a4904677c23fd5e5052e38 /god/twinter
parenta401be4bc5e393d35a220d0e9b33482794d66597 (diff)
initial commit
Diffstat (limited to 'god/twinter')
-rw-r--r--god/twinter/init_stripped.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/god/twinter/init_stripped.py b/god/twinter/init_stripped.py
new file mode 100644
index 00000000..092d239a
--- /dev/null
+++ b/god/twinter/init_stripped.py
@@ -0,0 +1,38 @@
+#!/usr/bin/env python
+import os.path
+import sys
+import tweepy
+from socket import *
+CONSUMER_KEY = ''
+CONSUMER_SECRET = ''
+ACCESS_KEY= ''
+ACCESS_SECRET = ''
+printer = ""
+
+auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
+auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)
+api = tweepy.API(auth)
+mention = api.mentions()[0]
+mention_stripped = mention.text.replace("@shacktwinter","").lstrip().rstrip().replace(" "," ")[:32]
+f = open(os.path.dirname(os.path.abspath(sys.argv[0]))+"/msg_file","r+")
+last = f.read()
+#sys.exit(23)
+if last == mention_stripped:
+ print "received old message"
+ sys.exit(23)
+else:
+ print "received new message: %s" % mention_stripped
+
+ s = socket(AF_INET, SOCK_STREAM)
+ send_message = \
+ '\x1b%%-12345X@PJL JOB\n@PJL RDYMSG DISPLAY="%s"\n@PJL EOJ\n\x1b%%-12345X' % (mention_stripped, )
+ s.connect((printer, 9100))
+ s.send(send_message)
+ s.close()
+ f.seek(0)
+ f.truncate(0)
+ f.write(mention_stripped)
+ f.close()
+ if not mention.user.following:
+ mention.user.follow()
+ api.update_status("@%s i appreciate your message '%s' for twinter! Ready Message updated." %(mention.user.screen_name,mention_stripped.upper()),in_reply_to_status_id=mention.id)