This repository was archived by the owner on Apr 1, 2026. It is now read-only.
forked from kurozael/twitter-contest-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
56 lines (37 loc) · 1.2 KB
/
Copy pathmain.py
File metadata and controls
56 lines (37 loc) · 1.2 KB
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
from TwitterAPI import TwitterAPI
import threading
import time
consumer_key = "YOUR CONSUMER KEY"
consumer_secret = "YOUR CONSUMER SECRET"
access_token_key = "YOUR ACCESS TOKEN KEY"
access_token_secret = "YOUR ACCESS TOKEN SECRET"
api = TwitterAPI(consumer_key, consumer_secret, access_token_key, access_token_secret)
post_list = list()
last_twitter_id = 0
def UpdateQueue():
u = threading.Timer(5.0, UpdateQueue)
u.daemon = True;
u.start()
print("=== CHECKING RETWEET QUEUE ===")
if len(post_list) > 0:
post = post_list[0]
print("Retweeting: " + str(post))
api.request('statuses/retweet/:' + str(post))
post_list.pop(0)
def ScanForContests():
t = threading.Timer(10.0, ScanForContests)
t.daemon = True;
t.start()
global last_twitter_id
print("=== SCANNING FOR NEW CONTESTS ===")
r = api.request('search/tweets', {'q':'RT to win', 'since_id':last_twitter_id})
for item in r:
if item['retweet_count'] > 0:
if (item['id'] > last_twitter_id):
last_twitter_id = item['id']
post_list.append(item['id'])
print(item)
ScanForContests()
UpdateQueue()
while (True):
time.sleep(1)