reply to tweets

workspace
Brendan Howell 7 years ago
parent d5034c7047
commit 8a0726676e

@ -87,7 +87,7 @@ class PublicRelations(Bureau):
return shortcode
@add_command("tweetpic", "Post a Document Camera Image to Twitter")
def tweet_pic(self):
def tweet_pic(self, reply_to_id=None, at_user=None):
"""
Takes a photograph using the document camera and posts it to Twitter.
"""
@ -96,9 +96,18 @@ class PublicRelations(Bureau):
with open(photo, "rb") as imagefile:
imagedata = imagefile.read()
t_up = twitter.Twitter(domain='upload.twitter.com', auth=self.auth)
id_img1 = t_up.media.upload(media=imagedata)["media_id_string"]
self.t.t.statuses.update(status="#screenless", media_ids=id_img1)
if reply_to_id:
if at_user:
status = "@" + at_user
else:
status = " "
self.t.t.statuses.update(status=status,
in_reply_to_status_id=reply_to_id,
media_ids=id_img1)
else:
self.t.t.statuses.update(status="#screenless", media_ids=id_img1)
@add_command("fbpost", "Post to Facebook")
def post_fb(self):
@ -203,6 +212,8 @@ class PublicRelations(Bureau):
prn.text("like\r\n")
prn.barcode("PRtwlk." + tw_shortcode, "CODE128", function_type="B")
prn.text("\r\n\r\n")
prn.barcode("PRtwre." + tw_shortcode, "CODE128", function_type="B")
prn.text("\r\n\r\n")
prn.cut()
@ -222,9 +233,9 @@ class PublicRelations(Bureau):
"""
shortcode, _ = data.split(".")
tweet_id = self.get_tweet_id(shortcode)
# TODO: do the actual reply
# maybe this should be an optional arg for tweet_pic?
return
tweet = self.t.t.statuses.show(id=tweet_id)
at_user = tweet["user"]["screen_name"]
self.tweet_pic(tweet_id=tweet_id, at_user=at_user)
@add_command("twlk", "Like a Tweet")
def tw_like(self, data):

Loading…
Cancel
Save