mirror of
https://github.com/metafy-social/python-scripts.git
synced 2024-11-24 04:21:12 +00:00
30 lines
1.0 KiB
Python
30 lines
1.0 KiB
Python
|
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)
|