-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtwitter.py
39 lines (30 loc) · 1.23 KB
/
twitter.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
import twitter_auth
import time
from datetime import datetime
def simple_tweet(param, previous_status):
api = twitter_auth.authenticate()
print(previous_status)
if (previous_status):
status = api.create_tweet(text=param, in_reply_to_tweet_id=previous_status.data['id'])
else:
status = api.create_tweet(text=param)
return status
def tweet(status, previous_status, first):
api = twitter_auth.authenticate()
if first:
status = api.update_status(status=status.param.body_text + " " + get_url(status.handle, status.status_id))
else:
status = api.update_status(
in_reply_to_status_id=previous_status.id, status=status.param.body_text + " " + get_url(status.handle, status.status_id))
return status
def end_thread(param, previous_status):
api = twitter_auth.authenticate()
status = api.update_status(in_reply_to_status_id=previous_status.id, status= param.body_text)
return status
def get_url(handle, status_id):
return "https://twitter.com/"+handle+"/status/"+str(status_id)
def tweet_hashtags(param, hashtags):
api = twitter_auth.authenticate()
status = api.update_status(param.body_text.format(h=hashtags))
return status