You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.5 KiB
Python
51 lines
1.5 KiB
Python
import twitter
|
|
|
|
from bureau import Bureau, add_command, add_api
|
|
|
|
|
|
class MailRoom(Bureau):
|
|
"""
|
|
The Mail Room handles (electronic) post for the other Bureaus of
|
|
the Screenless Office.
|
|
"""
|
|
|
|
name = "Mail Room"
|
|
prefix = "PS"
|
|
version = 0
|
|
|
|
def __init__(self):
|
|
Bureau.__init__(self)
|
|
|
|
@add_command("fax", "Send a Document Camera Image via Email")
|
|
def fax(self, to_id):
|
|
"""
|
|
Takes a photograph using the document camera and sends it in an E-mail.
|
|
"""
|
|
callback = self.prefix + "fax."
|
|
args = {"to_id": to_id}
|
|
self.send("PXphoto.", {"callback": callback, "cb_args": args})
|
|
|
|
@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:
|
|
imagedata = imagefile.read()
|
|
t_up = twitter.Twitter(domain='upload.twitter.com', auth=auth)
|
|
id_img1 = str(t_up.media.upload(media=imagedata)["media_id"])
|
|
t.statuses.update(status="PTT ★", media_ids=id_img1)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
pr = PublicRelations()
|
|
pr.run()
|