Closed sandymanu closed 2 years ago
You just need to make a list like
key_words=['Football']
And make https://github.com/dracarys18/TweetBot/blob/c788fcbf34d112e085977e98f4304ec129a4b625/tweet_scrape.py#L79
as
stream_tweet.filter(follow=account_list,track=key_words)
This bot needs to be rewritten to use the latest tweepy version I will implement it then
So I tried this change. I created a file keywords.py and imported it. In the file I defined a list like
key_words=['abc','def']
Then in the tweet scrape code I did as suggested.
account_list = self.get_tweet_acid(userslist) key_words = self.get_tweet_acid(keywords) stream_tweet = tp.Stream(api,listener,tweet_mode='extended') stream_tweet.filter(follow=account_list,track=key_words)
It didn't help. It was sending every single tweet that account tweets.
If the number of keywords was longer (around 75 keywords), then the program was not able to run and throws "the user account is suspended" and some errors along that
Hmm weird maybe issue from the API itself as I said I implement properly when I rewrite the bot
So I tried this change. I created a file keywords.py and imported it. In the file I defined a list like
key_words=['abc','def']
Then in the tweet scrape code I did as suggested.
account_list = self.get_tweet_acid(userslist) key_words = self.get_tweet_acid(keywords) stream_tweet = tp.Stream(api,listener,tweet_mode='extended') stream_tweet.filter(follow=account_list,track=key_words)
It didn't help. It was sending every single tweet that account tweets.
If the number of keywords was longer (around 75 keywords), then the program was not able to run and throws "the user account is suspended" and some errors along that
Also you are doing it very wrong
key_words = self.get_tweet_acid(keywords)
get_tweet_acid
gives the account ID of the mentioned username just make a list as key_words
and pass it to stream_tweeet.filter(track = key_words)
get_tweet_acid
gives the account ID of the mentioned username just make a list askey_words
and pass it tostream_tweeet.filter(track = key_words)
Ah, okay. Will re-try.
This way, it works, but not the expected output. It's putting out any tweet in twitter that has that keyword. The thing I was looking for was, if a tweet from a particular account has any of the keywords, then send it to telegram.
stream_tweet.filter(follow=account_list,track=key_words)
This one sends any tweet in twitter with the particular keyword.
That's weird I will implement it myself later on. But for the moment you can do something like
key_words = ['a','b','c']
if any(word in tg_text for word in key_words)
Before this line
Implemented in https://github.com/dracarys18/TweetBot/commit/3cef660c98e2de727614453daecbe4a943cc69ae
Needs few testing
Tested and works well
Hi,
This one worked great for me and has been useful for me. However the account I want tweets from posts a lot of junk and I want tweets with a specific keyword to be sent to my telegram channel.
How do I go about it ? I want to specify some 50 odd keywords and if the new tweet has any of those keywords, then I want that tweet to be sent to telegram, rather than every new tweet of the account.