-
-
Save algotrader-dotcom/d69cc5ecf37b7e1da5a4857c33393d8c to your computer and use it in GitHub Desktop.
Monitors @cvenew and sends me a message on Telegram if a keyword triggers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tweepy import StreamListener | |
from tweepy import Stream | |
import tweepy | |
import json | |
import telebot | |
import requests | |
CONSUMER_KEY = 'XXXXXXXXXXXXXXXXXXXXXXX' | |
CONSUMER_SECRET = 'XXXXXXXXXXXXXXXXXXXXXXX' | |
ACCESS_KEY = 'XXXXXXXXXXXXXXXXXXXXXXX' | |
ACCESS_SECRET = 'XXXXXXXXXXXXXXXXXXXXXXX' | |
API_TOKEN = 'XXXXXXXXXXXXXXXXXXXXXXX' | |
MY_NUMBER = 1337 | |
bot = telebot.TeleBot(API_TOKEN) | |
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET) | |
auth.set_access_token(ACCESS_KEY, ACCESS_SECRET) | |
api = tweepy.API(auth) | |
keywords = ['mozilla', 'office'] | |
def match(string): | |
for keyword in keywords: | |
if keyword in string: | |
return True | |
return False | |
class StdOutListener(StreamListener): | |
def on_status(self, status): | |
message = status.text.lower() | |
if match(message): | |
bot.send_message(MY_NUMBER, message) | |
def on_error(self, status): | |
pass | |
if __name__ == '__main__': | |
listener = StdOutListener() | |
twitterStream = Stream(auth, listener) | |
# https://twitter.com/cvenew | |
twitterStream.filter(follow=['821806287461740544']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment