summaryrefslogtreecommitdiffstats
path: root/god/twinter/init_stripped.py
blob: 092d239a42a528e871c22ea7a94c1ddd86d657fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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)