forked from pythonfoo/Impossible-Programming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtwitter.py
More file actions
29 lines (22 loc) · 689 Bytes
/
twitter.py
File metadata and controls
29 lines (22 loc) · 689 Bytes
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
import tweepy
from twitter_keys import get_keys
keys = get_keys()
consumer_key = keys["consumer_key"]
consumer_secret = keys["consumer_secret"]
access_token = keys["access_token"]
access_token_secret = keys["access_token_secret"]
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
max_len = 140 - 6
def tweet(text):
api.update_status(text)
def tweet_job(job):
if len(job) <= max_len:
job = "[Bot] " + job
tweet(job)
print("Der Tweet wurde gesendet")
return True
else:
print("Tut mir leid, das Zeichenlimit wurde erreicht")
return False