-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
42 lines (33 loc) · 1.23 KB
/
main.py
File metadata and controls
42 lines (33 loc) · 1.23 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
import keys
import tweepy
import json
import requests
import time
from functions import *
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
def check_id_in_file(id):
with open('replied_tweets.txt' , 'r') as read_obj:
for line in read_obj:
if(id in line):
return True
return False
def main():
mentions = api.mentions_timeline()
myFile = open('replied_tweets.txt' , 'a')
for mention in mentions:
mention_id = str(mention.id)
if(('#whatpokemonami' in mention.text) and (check_id_in_file(mention_id) == False)):
myFile.write(str(mention.id))
myFile.write("\n")
pokemon = get_pokemon(mention.text)
tweet_status = ("@" + mention.user.screen_name + " " + "Based on your birthday you are: \n" + "NAME: "
+ pokemon['name'] + "\nPOKEDEX ENTRY: " + str(pokemon['index']) + "\nTYPES: " + pokemon['type'])
file = "pokemon.png"
status = api.update_with_media(file, tweet_status)
print("Replied to @" + mention.user.screen_name + "\n")
while True:
main()
print("Waiting for Tweet")
time.sleep(5)