# -*- coding: utf-8 -*-
import tweepy
import random
import re
import json
from datetime import datetime as dt
CONSUMER_KEY = '3rbqGz2b8pQC2Epe0MmRQ'
CONSUMER_SECRET = 'cCXwTKHCtEdK5J7IIVSf1qV5kg4sDmBYe85OlKsZYMM'
ACCESS_TOKEN_KEY = '192196523-OK61vckJ5CaX3WHeBBjg3SuSSPMuF7cXUofnkrvJ'
ACCESS_TOKEN_SECRET = 'bzSBSpgI9XWQkesshwptJubeHJzFqKp6wkjPR3vb6VeY7'
turai = 0
match_zyosou = 0
ac = 'komekome09'
def get_oauth():
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_TOKEN_KEY, ACCESS_TOKEN_SECRET)
return auth
class ListenUserStream(tweepy.StreamListener):
def on_status(self, status):
# rand = random.randint(1, 110)
rand = len(status.text)
print rand
global turai, match_zyosou
try:
if '(@%s)'%ac in status.text and not 'RT' in status.text:
match = re.match(r'([\S\s]+)(@%s)'%ac,status.text)
if match:
changed = match.group(1).rstrip('(')
api.update_profile(description=changed)
text = u'@%s 馬鹿野郎お前俺は%sに変えるぞお前%s'%(status.author.screen_name,changed,' ' * rand)
print text
api.update_status(text)
if ac in status.author.screen_name:
if u'つらい' in status.text or u'つらかった' in status.text or u'つらみ' in status.text \
or u'つらさ' in status.text or u'つらそう' in status.text or u'つらぽよ' in status.text:
print 'turai'
turai = turai + 1
api.update_status(u'つよくいきて(%d 回目)'%turai)
if status.author.screen_name == ac and not status.in_reply_to_status_id is None:
match_zyosou = 1
if u'女装' in status.text and not 'RT' in status.text and not match_zyosou and rand > 73:
print 'zyosou'
api.update_status(u'@%s 女装しましょう%s'%(status.author.screen_name, ' ' * rand), status.id)
if (u'乳首' in status.text or u'chikubi' in status.text or u'tikubi' in status.text or u'nipple' in status.text \
or u'chikubeam' in status.text or u'ちくび' in status.text ) and not 'RT' in status.text:
print 'tikubi'
api.update_status(u'@%s ちくビ〜ムビビビビビ〜%s'%(status.author.screen_name, ' ' * rand), status.id)
if u'whywaita' in status.author.screen_name:
print 'nyan'
my_status = api.update_status(u'@%s にゃん%s'%(status.author.screen_name, ' ' * rand), status.id)
match_zyosou = 0
except Exeption, e:
print 'error'
finally:
return True
if __name__ == '__main__':
f = open('turai.json', 'r')
turai = int(f.read())
f.close()
auth = get_oauth()
api = tweepy.API(auth)
stream = tweepy.Stream(auth, ListenUserStream(), secure=True)
try:
stream.userstream()
except:
f = open('turai.json', 'w')
f.write(str(turai))
f.close()
raise