|
|
@ -2,6 +2,8 @@ import twitter
|
|
|
|
|
|
|
|
|
|
|
|
from bureau import Bureau, add_command, add_api
|
|
|
|
from bureau import Bureau, add_command, add_api
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TWrapper():
|
|
|
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class PublicRelations(Bureau):
|
|
|
|
class PublicRelations(Bureau):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
@ -16,33 +18,45 @@ class PublicRelations(Bureau):
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
def __init__(self):
|
|
|
|
Bureau.__init__(self)
|
|
|
|
Bureau.__init__(self)
|
|
|
|
|
|
|
|
self.auth = twitter.OAuth(
|
|
|
|
|
|
|
|
"423391766-bhjHwzD1eJfxB9s7ZvmeHReNVJM0d93kJ8KSrHEZ",
|
|
|
|
|
|
|
|
"qSvSYMs4lpSKbZtiuOjB1Gon5rzye8whvadcOdDpFocwa",
|
|
|
|
|
|
|
|
"arI4UCnfMeKZwAnyvJJIHVnUN",
|
|
|
|
|
|
|
|
"agrtzvh3eqSNlZpmPJZ0otclqSUjLKI3JrqugCPrp1Ch9dqsTl")
|
|
|
|
|
|
|
|
self.t = TWrapper()
|
|
|
|
|
|
|
|
self.t.t = twitter.Twitter(auth=self.auth)
|
|
|
|
|
|
|
|
|
|
|
|
@add_command("tweetpic", "Post a Document Camera Image to Twitter")
|
|
|
|
@add_command("tweetpic", "Post a Document Camera Image to Twitter")
|
|
|
|
def tweet_pic(self):
|
|
|
|
def tweet_pic(self):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Takes a photograph using the document camera and posts it to Twitter.
|
|
|
|
Takes a photograph using the document camera and posts it to Twitter.
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
callback = self.prefix + "tweetpic_cb."
|
|
|
|
photo = self.send("PX", "photo")["photo"]
|
|
|
|
self.send("PXphoto.", {"callback": callback})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@add_api("tweetpic_cb", "callback for tweet_pic")
|
|
|
|
|
|
|
|
def tweetpic_cb(self, data):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
This does the actual uploading of the picture.
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
photo = data["photo"]
|
|
|
|
|
|
|
|
auth = twitter.OAuth(
|
|
|
|
|
|
|
|
"423391766-bhjHwzD1eJfxB9s7ZvmeHReNVJM0d93kJ8KSrHEZ",
|
|
|
|
|
|
|
|
"qSvSYMs4lpSKbZtiuOjB1Gon5rzye8whvadcOdDpFocwa",
|
|
|
|
|
|
|
|
"arI4UCnfMeKZwAnyvJJIHVnUN",
|
|
|
|
|
|
|
|
"agrtzvh3eqSNlZpmPJZ0otclqSUjLKI3JrqugCPrp1Ch9dqsTl")
|
|
|
|
|
|
|
|
t = twitter.Twitter(auth=auth)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
with open(photo, "rb") as imagefile:
|
|
|
|
with open(photo, "rb") as imagefile:
|
|
|
|
imagedata = imagefile.read()
|
|
|
|
imagedata = imagefile.read()
|
|
|
|
t_up = twitter.Twitter(domain='upload.twitter.com', auth=auth)
|
|
|
|
t_up = twitter.Twitter(domain='upload.twitter.com', auth=self.auth)
|
|
|
|
id_img1 = str(t_up.media.upload(media=imagedata)["media_id"])
|
|
|
|
id_img1 = str(t_up.media.upload(media=imagedata)["media_id"])
|
|
|
|
t.statuses.update(status="PTT ★", media_ids=id_img1)
|
|
|
|
self.t.t.statuses.update(status="#screenlessoffice ", media_ids=id_img1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@add_command("twtimeline", "Print Recent Tweets")
|
|
|
|
|
|
|
|
def tw_timeline(self, data=None):
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
Print some recent tweets from your home timeline. Default is 10.
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
if data:
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
count = data["count"]
|
|
|
|
|
|
|
|
except KeyError as err:
|
|
|
|
|
|
|
|
print("You need to specify how many tweets you want!")
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
count = 10
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tweets = self.t.t.statuses.home_timeline(count=count)
|
|
|
|
|
|
|
|
out = ""
|
|
|
|
|
|
|
|
for t in tweets:
|
|
|
|
|
|
|
|
out += t["user"]["name"] + " : " + t["text"] + "\r\n\r\n"
|
|
|
|
|
|
|
|
self.print_small(out)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
if __name__ == "__main__":
|
|
|
|