-
Notifications
You must be signed in to change notification settings - Fork 0
/
Auto_RT.py
153 lines (113 loc) · 4.6 KB
/
Auto_RT.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
import tweepy
from random import randint
import time
def selectfollow(texte):
check=True
listeresult=[]
for i in texte:
if i!='@' and check:
chaine=''
else:
check=False
chaine+=i
if i==' ':
check=True
chaine=chaine[1:-1]
listeresult.append(chaine)
return listeresult
def tweetopif(api):
#global listetr
trendsalea=api.trends_place(23424819)[0]['trends'][randint(0,10)]['name']
query = trendsalea
max_tweets = 1000
searched_tweets = [status for status in tweepy.Cursor(api.search, q=query).items(max_tweets)]
listetr=[]
for i in searched_tweets:
if i.text[0]+i.text[1]!='RT' and i.in_reply_to_status_id==None and i.lang=='fr' and len(i.text)<114: #searched_tweets[0].id
listetr.append(i)
if len(listetr)-1>=0:
api.update_status(listetr[randint(0,len(listetr)-1)].text)
print(listetr[0].text)
#Pjactare Pepssi19 kriterre Huam52524437
#StephNulos guyonnathalie1
#Alexispouillat1 (pas très actif)
def routine(tweet):
api.retweet(tweet.id)
tweet.favorite()
#listefollow=selectfollow(tweet.text)
api.update_status("@Pjactare @Pepssi19 @kriterre @Huam52524437 @"+str(tweet.author.screen_name),in_reply_to_status_id=tweet.id)
print('ok')
#listetr[0].author.name
api.create_friendship(tweet.author.id)
#AAAAAAAAAAAAAAAAAAAAACXKSAEAAAAAEX2Ep0owNdU17Pu5vmli2e7XUwk%3DdHHfOnlLIOVZ9yC2NQ88oYwaababPLJHNQPtJkXe6OXFbjwPFr
API_KEY = "1Qn0MluibzYhK3uuvYDWHK8ty"
API_SECRET = "AsDLODJnONc3B8Gl4BCTntKRWm7uYQZyFjsU3lCvKS0Q0cP0Ez"
ACCESS_TOKEN = "1401540013125509125-bUyEDtAVUwmrvRYCf1HVknb0iGI5M2"
ACCESS_TOKEN_SECRET = "OttyzSf8fMCJa4tPGRolMklLGfIiCnAebJ5mpDDWDf1wc"
auth = tweepy.OAuthHandler(API_KEY, API_SECRET)
auth.set_access_token(ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
listerep=["Regardez-ca","Ca a l'air cool","Wahh", "Je participe"]
api = tweepy.API(auth)
# pour chercher les tendances
###api.trends_place(23424819)[0]['trends'][49]['name']
while True:
query = 'giveaway'
max_tweets = 200
verif=True
while verif:
try:
searched_tweets = [status for status in tweepy.Cursor(api.search, q=query).items(max_tweets)]
verif=False
except:
print('erreur')
time.sleep(20)
listetr=[]
##while len(listetr)<1:
## max_tweets += 10
## searched_tweets = [status for status in tweepy.Cursor(api.search, q=query).items(max_tweets)]
## listetr=[]
## for i in searched_tweets:
## if i.text[0]+i.text[1]!='RT' and i.in_reply_to_status_id!=None: #searched_tweets[0].id
## listetr.append(i)
## print('\n\n-----------------------------------------------\n'+i.text)
for i in searched_tweets:
if i.text[0]+i.text[1]!='RT' and i.in_reply_to_status_id==None: #searched_tweets[0].id
listetr.append(i)
#print('\n\n-----------------------------------------------\n'+i.text)
try:
query = 'concours'
max_tweets = 100
searched_tweets = [status for status in tweepy.Cursor(api.search, q=query).items(max_tweets)]
for i in searched_tweets:
if i.text[0]+i.text[1]!='RT' and i.in_reply_to_status_id==None: #searched_tweets[0].id
listetr.append(i)
#print('\n\n-----------------------------------------------\n'+i.text)
except:
None
try:
query = 'concours paypal'
max_tweets = 100
searched_tweets = [status for status in tweepy.Cursor(api.search, q=query).items(max_tweets)]
for i in searched_tweets:
if i.text[0]+i.text[1]!='RT' and i.in_reply_to_status_id==None: #searched_tweets[0].id
listetr.append(i)
#print('\n\n-----------------------------------------------\n'+i.text)
except:
None
for i,j in enumerate(listetr):
if i%5==0:
verif=True
while verif:
try:
tweetopif(api)
verif=False
except:
print('erreur tweet')
time.sleep(20)
try:
routine(j)
except:
None
time.sleep(20)
time.sleep(120)
#api.update_status('Test',in_reply_to_status_id=1406609822460559361)