forked from metafy-social/python-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.py
More file actions
29 lines (24 loc) · 1.05 KB
/
Copy pathcode.py
File metadata and controls
29 lines (24 loc) · 1.05 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
from twython import Twython
from twython import TwythonStreamer
import configparser
class MyStreamer(TwythonStreamer):
# Overwriting function
def on_success(self, data):
if 'text' in data:
username = data['user']['screen_name']
tweet_id = data['id']
# Liking the tweet found
st.create_favorite(id=tweet_id)
# Retweeting the tweet with msg
st.update_status(status=f'Nice Tweet @{username}', in_reply_to_status_id=tweet_id)
print(f"https://twitter.com/{username}/status/{str(tweet_id)}")
config = configparser.ConfigParser()
config.read('config.ini')
api_key = config['keys']['api_key']
api_secret_key = config['keys']['api_secret_key']
access_token = config['keys']['access_token']
access_secret_token = config['keys']['access_secret_token']
api = MyStreamer(api_key, api_secret_key, access_token, access_secret_token)
st = Twython(api_key, api_secret_key, access_token, access_secret_token)
keyword = input("Enter keyword to track: ")
api.statuses.filter(track=keyword)