Skip to content

Instantly share code, notes, and snippets.

@utgwkk
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save utgwkk/09cccc398a0ac20f5ee7 to your computer and use it in GitHub Desktop.
Save utgwkk/09cccc398a0ac20f5ee7 to your computer and use it in GitHub Desktop.
レイバン検出するやつ
# -*- coding: utf-8 -*-
# NOTE: use Python 3.
import tweepy
import re
import sys
CONSUMER_KEY = ''
CONSUMER_SECRET = ''
me = 'YOUR_SCREEN_NAME'
class Listener(tweepy.StreamListener):
def on_status(self,s):
try:
if 'レイバン' in s.text and '@' in s.text and not 'RT' in s.text:
api.update_status('@%s レイバンを検出しました'%(s.author.screen_name), s.id)
except Exception,e:
pass
finally:
return True
if __name__ == '__main__':
auth = tweepy.OAuthHandler(CONSUMER_KEY,CONSUMER_SECRET)
print(auth.get_authorization_url())
verifier = raw_input('PIN: ').rstrip()
try:
auth.get_access_token(verifier)
auth.set_access_token(auth.access_token.key, auth.access_token.secret)
api = tweepy.API(auth)
me = api.me().screen_name
except tweepy.TweepError:
pass
else:
stream = tweepy.Stream(auth, Listener())
stream.userstream()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment