|
|
@ -21,7 +21,7 @@ class PublicRelations(Bureau):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
The Public relations department manages the flow of information between
|
|
|
|
The Public relations department manages the flow of information between
|
|
|
|
the screenless office and the general public. It provides interfaces
|
|
|
|
the screenless office and the general public. It provides interfaces
|
|
|
|
for Twitter, Facebook and other electronic PR platforms.
|
|
|
|
for Twitter, Facebook, Mastodon and other electronic PR platforms.
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
name = "Public Relations"
|
|
|
|
name = "Public Relations"
|
|
|
@ -93,22 +93,9 @@ class PublicRelations(Bureau):
|
|
|
|
access_token = 'EAADixisn70ABADh2rEMZAYA8nGzd6ah8RFZA3URba263aCQ63ajLeTiZC5sgZCyIVSmRZBWReVsO9IuaLibX5RjW9Ja2tTZAbxgrDr1dPJzyGwcGTSV9bW1W4NigN0d9dFIH35W2fZBOkhvuLqOCDCBacIPjXPMxF7DRGyrz5lVHxTc04OlBeRX'
|
|
|
|
access_token = 'EAADixisn70ABADh2rEMZAYA8nGzd6ah8RFZA3URba263aCQ63ajLeTiZC5sgZCyIVSmRZBWReVsO9IuaLibX5RjW9Ja2tTZAbxgrDr1dPJzyGwcGTSV9bW1W4NigN0d9dFIH35W2fZBOkhvuLqOCDCBacIPjXPMxF7DRGyrz5lVHxTc04OlBeRX'
|
|
|
|
page_id = "screenless"
|
|
|
|
page_id = "screenless"
|
|
|
|
graph = facebook.GraphAPI(access_token)
|
|
|
|
graph = facebook.GraphAPI(access_token)
|
|
|
|
#graph.put_object(parent_object=page_id, connection_name='feed',
|
|
|
|
|
|
|
|
# message='testing screenless post')
|
|
|
|
|
|
|
|
print("uploading photo " + photo)
|
|
|
|
print("uploading photo " + photo)
|
|
|
|
graph.put_photo(image=open(photo, 'rb'), album_path=page_id + "/photos",
|
|
|
|
graph.put_photo(image=open(photo, 'rb'), album_path=page_id + "/photos",
|
|
|
|
message='#screenless')
|
|
|
|
message='#screenless')
|
|
|
|
#files = {"file": ("cam.jpg", open(photo, 'rb'))}
|
|
|
|
|
|
|
|
#args = {}
|
|
|
|
|
|
|
|
#args["access_token"] = access_token
|
|
|
|
|
|
|
|
#args["caption"] = "test cam"
|
|
|
|
|
|
|
|
#resp = requests.post(facebook.FACEBOOK_GRAPH_URL + graph.version + "/"\
|
|
|
|
|
|
|
|
# + "me" + "/photos",
|
|
|
|
|
|
|
|
# files=files,
|
|
|
|
|
|
|
|
# params=args,
|
|
|
|
|
|
|
|
# timeout=graph.timeout,
|
|
|
|
|
|
|
|
# proxies=graph.proxies)
|
|
|
|
|
|
|
|
#print(resp.json())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@add_command("twtimeline", "Print Recent Tweets")
|
|
|
|
@add_command("twtimeline", "Print Recent Tweets")
|
|
|
|
def tw_timeline(self, data=None):
|
|
|
|
def tw_timeline(self, data=None):
|
|
|
@ -164,11 +151,42 @@ class PublicRelations(Bureau):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Print detailed tweet info and commands for reply, like, retweet, etc.
|
|
|
|
Print detailed tweet info and commands for reply, like, retweet, etc.
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
self.log.debug("got data " + str(data))
|
|
|
|
tweet_id = self.get_tweet_id(data)
|
|
|
|
tweet_id = self.get_tweet_id(data)
|
|
|
|
|
|
|
|
self.log.debug("tweet details for id:" + tweet_id)
|
|
|
|
tweet = self.t.t.statuses.show(id=tweet_id)
|
|
|
|
tweet = self.t.t.statuses.show(id=tweet_id)
|
|
|
|
|
|
|
|
prn = printer.Usb(0x416, 0x5011, in_ep=0x81, out_ep=0x03)
|
|
|
|
|
|
|
|
prn.codepage = "cp437"
|
|
|
|
|
|
|
|
|
|
|
|
# TODO: print tweet details
|
|
|
|
prn.set(text_type="U")
|
|
|
|
pass
|
|
|
|
username = tweet["user"]["name"].encode("cp437", "ignore")
|
|
|
|
|
|
|
|
prn._raw(username)
|
|
|
|
|
|
|
|
prn.text("\r\n")
|
|
|
|
|
|
|
|
prn.set(text_type="NORMAL")
|
|
|
|
|
|
|
|
twtext = html.unescape(tweet["text"])
|
|
|
|
|
|
|
|
t_wrapped = textwrap.fill(twtext, width=48) + "\r\n"
|
|
|
|
|
|
|
|
t_enc = t_wrapped.encode("cp437", "ignore")
|
|
|
|
|
|
|
|
prn._raw(t_enc)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if "media" in tweet["entities"]:
|
|
|
|
|
|
|
|
if len(tweet["entities"]["media"]) > 0:
|
|
|
|
|
|
|
|
i_url = tweet["entities"]["media"][0]["media_url"]
|
|
|
|
|
|
|
|
filename = i_url.rsplit('/',1)[1]
|
|
|
|
|
|
|
|
filename = "/tmp/" + filename
|
|
|
|
|
|
|
|
print("fetching", i_url, filename)
|
|
|
|
|
|
|
|
urllib.request.urlretrieve(i_url, filename)
|
|
|
|
|
|
|
|
im = PIL.Image.open(filename)
|
|
|
|
|
|
|
|
if im.mode in ("L", "RGB", "P"):
|
|
|
|
|
|
|
|
im = PIL.ImageOps.equalize(im)
|
|
|
|
|
|
|
|
im.thumbnail((576, 576), PIL.Image.ANTIALIAS)
|
|
|
|
|
|
|
|
prn.image(im, impl="bitImageColumn")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tw_shortcode = self.short_tweet_id(tweet["id_str"])
|
|
|
|
|
|
|
|
prn.barcode("PRtwrt." + tw_shortcode, "CODE128", function_type="B")
|
|
|
|
|
|
|
|
prn.barcode("PRtwlk." + tw_shortcode, "CODE128", function_type="B")
|
|
|
|
|
|
|
|
prn.text("\r\n\r\n")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
prn.cut()
|
|
|
|
|
|
|
|
|
|
|
|
@add_command("twrt", "Re-Tweet")
|
|
|
|
@add_command("twrt", "Re-Tweet")
|
|
|
|
def tw_retweet(self, data):
|
|
|
|
def tw_retweet(self, data):
|
|
|
|