fork download
  1. # -*- coding: utf-8 -*-
  2. import tweepy
  3. import random
  4. import re
  5. import json
  6. from datetime import datetime as dt
  7.  
  8. CONSUMER_KEY = '3rbqGz2b8pQC2Epe0MmRQ'
  9. CONSUMER_SECRET = 'cCXwTKHCtEdK5J7IIVSf1qV5kg4sDmBYe85OlKsZYMM'
  10. ACCESS_TOKEN_KEY = '192196523-OK61vckJ5CaX3WHeBBjg3SuSSPMuF7cXUofnkrvJ'
  11. ACCESS_TOKEN_SECRET = 'bzSBSpgI9XWQkesshwptJubeHJzFqKp6wkjPR3vb6VeY7'
  12. turai = 0
  13. match_zyosou = 0
  14. ac = 'komekome09'
  15.  
  16. def get_oauth():
  17. auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
  18. auth.set_access_token(ACCESS_TOKEN_KEY, ACCESS_TOKEN_SECRET)
  19. return auth
  20.  
  21. class ListenUserStream(tweepy.StreamListener):
  22. def on_status(self, status):
  23. # rand = random.randint(1, 110)
  24. rand = len(status.text)
  25. print rand
  26. global turai, match_zyosou
  27. try:
  28. if '(@%s)'%ac in status.text and not 'RT' in status.text:
  29. match = re.match(r'([\S\s]+)(@%s)'%ac,status.text)
  30. if match:
  31. changed = match.group(1).rstrip('(')
  32. api.update_profile(description=changed)
  33. text = u'@%s 馬鹿野郎お前俺は%sに変えるぞお前%s'%(status.author.screen_name,changed,' ' * rand)
  34. print text
  35. api.update_status(text)
  36.  
  37. if ac in status.author.screen_name:
  38. if u'つらい' in status.text or u'つらかった' in status.text or u'つらみ' in status.text \
  39. or u'つらさ' in status.text or u'つらそう' in status.text or u'つらぽよ' in status.text:
  40. print 'turai'
  41. turai = turai + 1
  42. api.update_status(u'つよくいきて(%d 回目)'%turai)
  43.  
  44. if status.author.screen_name == ac and not status.in_reply_to_status_id is None:
  45. match_zyosou = 1
  46.  
  47. if u'女装' in status.text and not 'RT' in status.text and not match_zyosou and rand > 73:
  48. print 'zyosou'
  49. api.update_status(u'@%s 女装しましょう%s'%(status.author.screen_name, ' ' * rand), status.id)
  50.  
  51. if (u'乳首' in status.text or u'chikubi' in status.text or u'tikubi' in status.text or u'nipple' in status.text \
  52. or u'chikubeam' in status.text or u'ちくび' in status.text ) and not 'RT' in status.text:
  53. print 'tikubi'
  54. api.update_status(u'@%s ちくビ〜ムビビビビビ〜%s'%(status.author.screen_name, ' ' * rand), status.id)
  55.  
  56. if u'whywaita' in status.author.screen_name:
  57. print 'nyan'
  58. my_status = api.update_status(u'@%s にゃん%s'%(status.author.screen_name, ' ' * rand), status.id)
  59.  
  60. match_zyosou = 0
  61.  
  62. except Exeption, e:
  63. print 'error'
  64. finally:
  65. return True
  66.  
  67. if __name__ == '__main__':
  68. f = open('turai.json', 'r')
  69. turai = int(f.read())
  70. f.close()
  71. auth = get_oauth()
  72. api = tweepy.API(auth)
  73. stream = tweepy.Stream(auth, ListenUserStream(), secure=True)
  74. try:
  75. stream.userstream()
  76. except:
  77. f = open('turai.json', 'w')
  78. f.write(str(turai))
  79. f.close()
  80. raise
  81.  
Runtime error #stdin #stdout #stderr 0.01s 7848KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "prog.py", line 2, in <module>
ImportError: No module named tweepy