-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.py
107 lines (89 loc) · 3.82 KB
/
main.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
import Tech_Extractor as tech
import Anime_Extractor as anime
import Game_Extractor as game
import Coding_Extractor as code
import tweepy as tw
from os import environ
import time
time_to_execute = ['01:00', '02:00', '03:00', '04:00', '05:00', '06:00',
'07:00', '08:00', '09:00', '10:00', '11:00', '12:00',
'13:00', '14:00', '15:00', '16:00', '17:00', '18:00',
'19:00', '20:00', '21:00', '22:00', '23:00', '00:00']
while True:
current_time = time.strftime("%H:%M")
if current_time in time_to_execute:
print(f"\nAt {current_time}")
final = code.give_me_news() # [[main_url, title, author]]
consumer_key = environ['consumer_key_coding']
consumer_secret = environ['consumer_secret_coding']
access_key = environ['access_key_coding']
access_secret = environ['access_secret_coding']
auth = tw.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_key, access_secret)
api = tw.API(auth, wait_on_rate_limit=True)
if len(final) > 10:
i = 0
for ele in final[:5]:
try:
api.update_status(status=f"{ele[1]} \n\t\t -{ele[2]} \n{ele[0]}")
time.sleep(15)
i += 1
except:
final.remove(ele)
print(f"{len(final)} Coding News Tweeted")
del final
final = game.give_me_news() # [[main_url, image_url, title, author, content]]
consumer_key = environ['consumer_key_gaming']
consumer_secret = environ['consumer_secret_gaming']
access_key = environ['access_key_gaming']
access_secret = environ['access_secret_gaming']
auth = tw.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_key, access_secret)
api = tw.API(auth, wait_on_rate_limit=True)
i = 0
for ele in final:
try:
api.update_status(status=f"{ele[2]} \n\t\t -{ele[3]} \n{ele[0]}")
time.sleep(15)
i += 1
except:
final.remove(ele)
print(f"{i} Gaming News Tweeted")
del final
final = tech.give_me_news() # [[main_url, image_url, title, author, content]]
consumer_key = environ['consumer_key_tech']
consumer_secret = environ['consumer_secret_tech']
access_key = environ['access_key_tech']
access_secret = environ['access_secret_tech']
auth = tw.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_key, access_secret)
api = tw.API(auth, wait_on_rate_limit=True)
i = 0
for ele in final:
try:
api.update_status(status=f"{ele[2]}\n\t\t -{ele[3]}\n{ele[0]}")
time.sleep(15)
i += 1
except:
final.remove(ele)
print(f"{i} Technology News Tweeted")
del final
final = anime.give_me_news() # [[main_url, image_url, title, author, content]]
consumer_key = environ['consumer_key_anime']
consumer_secret = environ['consumer_secret_anime']
access_key = environ['access_key_anime']
access_secret = environ['access_secret_anime']
auth = tw.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_key, access_secret)
api = tw.API(auth, wait_on_rate_limit=True)
i = 0
for ele in final:
try:
api.update_status(status=f"{ele[2]} \n\t\t -{ele[3]} \n{ele[0]}")
time.sleep(15)
i += 1
except:
final.remove(ele)
print(f"{i} Anime News Tweeted")
del final
time.sleep(60)