forked from arvid220u/invandringsbot
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcontent.py
98 lines (74 loc) · 2.28 KB
/
content.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
from twython import Twython
import apikeys
import time
import random
import setup
import follow
def construct_tweet(template):
tweet = ""
for item in template:
#print tweet
#print str(item)
if isinstance(item, list):
tweet = tweet + str(random.choice(item))
else:
tweet = tweet + str(item)
return tweet
def do_rt(twitter, user):
done = False
#twitter = twythonaccess.authorize()
try:
if follow.do_follow(twitter, user, False):
time.sleep(30 + (5 * random.random()))
timeline = twitter.get_user_timeline(screen_name=user, exclude_replies=True, count=5)
if len(timeline) > 0:
tweet = timeline[0]
#print tweet
if tweet['retweeted'] is False:
twitter.retweet(id=tweet['id'])
print "retweeted"
return True
except Exception, e:
print "Exception in content.do_rt()"
#print e
time.sleep(60*16)
print "continuing..."
return False
def try_rt(twitter):
accounts = list(setup.accounts_to_rt)
random.shuffle(accounts)
flag = True;
while flag and (len(accounts) > 0):
user = accounts.pop()
print user
flag = do_rt(twitter, user)
flag = not flag
return not flag
def timeline_content(twitter):
coin = random.random()
print "coin is " + str(coin)
result = (coin <= setup.percent_rt) #75% chance true
if result:
result = try_rt(twitter)
if not result:
return (construct_tweet(random.choice(setup.templates)))
return None
#def main():
#do_follow('101FearlessLife', True)
# follow NFL PJNET_Team
# to rt: AllGreatAgain CuteEmergency AChristLife EmrgencyKittens Vol_Football Titans okcthunder UpTheThunder
#iterator = follow.get_users(twitter)
#print iterator.next()
#print iterator.next()
#print iterator.next()
#follow.do_follow(twitter, iterator.next())
#time.sleep(30)
#follow.do_follow(twitter, iterator.next())
#do_rt('Titans')
#print str(construct_tweet(random.choice(setup.templates)))
#print random.shuffle(setup.accounts_to_rt)
#try_rt()
#timeline_content()
#print setup.accounts_to_rt
#if __name__ == "__main__":
#main()