-
Notifications
You must be signed in to change notification settings - Fork 0
/
justlk.py
43 lines (34 loc) · 1.15 KB
/
justlk.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
import tweepy
import logging
from config import create_api
import json
import time
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger()
class TListener(tweepy.StreamListener):
def __init__(self, api):
self.api = api
self.me = api.me()
def on_status(self, tweet):
logger.info(f"The tweet ids {tweet.id}")
# ignores replies and if I'm the author
if tweet.in_reply_to_status_id is not None or \
tweet.user.id == self.me.id:
return
# Liking if not liked yet
if not tweet.favorited:
try:
tweet.favorite()
time.sleep(180)
except Exception as e:
logger.error("There was a fav error", exec_info=True)
def on_error(self, status):
logger.error(status)
def main(keywords):
api = create_api()
tweets_listener = TListener(api)
stream = tweepy.Stream(api.auth, tweets_listener)
stream.filter(track=keywords, languages=["en"])
if __name__ == "__main__":
main(["#Crypto", "Ethereum", "$ETH", "DeFi", "#DeFi",
"programming", "bankless", "#NFT", "#Chainlink", "$LINK"])