ismaelvc

twiter_test.py

Nov 15th, 2013
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.91 KB | None | 0 0
  1. import os
  2. import time
  3. import datetime
  4. from twython import Twython, TwythonError
  5.  
  6.  
  7. def check():   
  8.     condition = "Tell me the date"
  9.    
  10.     twitter = Twython("")
  11.     print("\n")
  12.    
  13.     feed = twitter.get_user_timeline(screen_name="jarvis_788")
  14.    
  15.     f = open("LastTweet.txt","r")
  16.     data = f.read()
  17.     f.close
  18.    
  19.     if data == condition:
  20.         check()
  21.    
  22.     f = open("LastTweet.txt",'w')
  23.     f.write(condition)
  24.  
  25.    
  26.     for tweet in feed[:1]:
  27.        
  28.         if tweet["text"] == "Tell me the date":
  29.             import httplib, urllib
  30.             conn = httplib.HTTPSConnection("api.pushover.net:443")
  31.             conn.request("POST", "/1/messages.json",
  32.             urllib.urlencode({
  33.                     "token": "",
  34.                     "user": "",
  35.                     "message": "The date is "+str(datetime.date.today())+" sir",
  36.                 }), { "Content-type": "application/x-www-form-urlencoded" })
  37.             conn.getresponse()
  38.             check()
  39.            
  40.            
  41.            
  42. def main():
  43.     while True:
  44.         check()
  45.  
  46. if __name__ == '__main__':
  47.     main()
Advertisement
Add Comment
Please, Sign In to add comment