-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tweet_old.py
39 lines (33 loc) · 1.15 KB
/
Tweet_old.py
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
39
import tweepy, time, os
consumer_token = "AbvWXhLW9dLt7pOcqGyWAqkcN"
consumer_secret = "pxsXjJqQdlOH7HUmwdPy9q3EJiYDImKikDnmRD2bU655zGPe44"
auth = tweepy.OAuthHandler(consumer_token, consumer_secret)
print "succesfully openend twiiter"
with open("pic/config", "r") as f:
if not f.read() == "":
f.seek(0)
if f.readline()[0] == "#":
f.seek(0)
key = f.readline()[1:]
secret = f.readline()[1:]
auth.set_access_token(key, secret)
api = tweepy.API(auth)
while True:
f = open("pic/tweet", "r")
lines = f.readlines()
f.close()
f = open("../pic/tweet", "w")
for line in lines:
if line[0] == "$":
print "tweeted file: " + line[1:]
fn = os.path.abspath("../pic/" + line[1:-1])
print fn
try:
api.update_with_media(fn, status="Someone walked throuth the door at " + line[1:])
os.remove("../pic/" + line[1:])
except OSError, tweepy.error.TweepError:
print "file to tweet not found"
f.write(line)
else:
f.write(line[1:])
f.close()