Commits

Anonymous committed dc88ff0

e

  • Participants
  • Parent commits b8bfe73

Comments (0)

Files changed (7)

+#!/usr/bin/python
+
+consumer_key= "2398039588"
+consumer_secret ="565f0cc06b7a13c9c81385d7515762b6"
+token = ["1099ce13380b22f93e7ec35a3bc2e341","c66ebfe1f95364c06f45f9e7c1267e78"]
+watchName=['rainywh269']

config.pyc

Binary file added.
- ../sdk/google_appengine/appcfg.py update .
+ ../../sdk/google_appengine/appcfg.py update .
 import unittest
 from weibopy.auth import OAuthHandler, BasicAuthHandler
 from weibopy.api import API
+from config import consumer_key,consumer_secret
 
 class Test(unittest.TestCase):
     
-    consumer_key= "2398039588"
-    consumer_secret ="565f0cc06b7a13c9c81385d7515762b6"
 
 
     def __init__(self):
             print e
             return ''
     def setToken(self, token, tokenSecret):
-        self.auth = OAuthHandler(self.consumer_key, self.consumer_secret)
+        self.auth = OAuthHandler(consumer_key, consumer_secret)
         self.auth.setToken(token, tokenSecret)
         self.api = API(self.auth)
         
         self.api = API(self.auth,source=source)
         
     def auth(self):
-        self.auth = OAuthHandler(self.consumer_key, self.consumer_secret)
+        self.auth = OAuthHandler(consumer_key, consumer_secret)
         auth_url = self.auth.get_authorization_url()
         print 'Please authorize: ' + auth_url
         verifier = raw_input('PIN: ').strip()

getTimelines.pyc

Binary file modified.
-from google.appengine.api import xmpp
-from google.appengine.ext.webapp.util import run_wsgi_app
-from google.appengine.ext import webapp
-from google.appengine.ext import db
-from weibopy.auth import OAuthHandler, BasicAuthHandler
-from weibopy.api import API
-from db_model import record 
-from getTimelines import Test
-import logging
-
-watchName='rainywh269'
-
-def addUser(user):
-    a = record()
-    a.name = user
-    a.msgid = 0
-    db.put(a)
-
-def updateMsgId(a,msgId):
-    a.msgid = msgId
-    db.put(a)
-
-def getMsg(user):
-    test = Test()
-    test.setToken("1099ce13380b22f93e7ec35a3bc2e341", "c66ebfe1f95364c06f45f9e7c1267e78")
-    logging.info(user)
-    if user.msgid <> 0:
-        result = test.user_timeline(user.name,user.msgid)
-    else:
-        result = test.user_timeline(user.name,user.msgid,True)
-    if len(result)>0:
-        for i in result:
-            status_code = xmpp.send_message("guohaochuan@gmail.com", "!"+ unicode(i.__getattribute__('screen_name'))+unicode(i.__getattribute__('text')))
-            if status_code == xmpp.NO_ERROR :
-                updateMsgId(user,int(result[0].__getattribute__('id')))
-    
-    
-def checkMsg():
-    command="SELECT * FROM record where name = '"+watchName+"'"
-    q = db.GqlQuery(command)
-    num = q.count()
-    if num<>0:
-        if num == 1:
-            getMsg(q[0])
-    elif num==0:
-        addUser(watchName)
-        checkMsg()
-
-
-class realMain(webapp.RequestHandler):
-    def get(self):
-        checkMsg()
-
-application = webapp.WSGIApplication([('/dataa', realMain),],debug=True)
-
-def main():
-    run_wsgi_app(application)
-
-if __name__ == "__main__":
-    main()  
+from google.appengine.api import xmpp
+from google.appengine.ext.webapp.util import run_wsgi_app
+from google.appengine.ext import webapp
+from google.appengine.ext import db
+from google.appengine.api import mail
+from weibopy.auth import OAuthHandler, BasicAuthHandler
+from weibopy.api import API
+from db_model import record 
+from getTimelines import Test
+from config import watchName, token
+import logging
+
+
+def addUser(user):
+    a = record()
+    a.name = user
+    a.msgid = 0
+    db.put(a)
+
+def updateMsgId(a,msgId):
+    a.msgid = msgId
+    db.put(a)
+
+def getMsg(user):
+    test = Test()
+    test.setToken(token[0],token[1])
+    if user.msgid <> 0:
+        result = test.user_timeline(user.name,user.msgid)
+    else:
+        result = test.user_timeline(user.name,user.msgid,True)
+    if len(result)>0:
+        for i in result:
+            try:
+                status_code = xmpp.send_message("guohaochuan@gmail.com", user.name+":retweet:"+unicode(i.__getattribute__('text'))+"::"+unicode(i.__getattribute__('retweeted_status').__getattribute__('text')))
+                logging.info("retweet")
+            except:
+                status_code = xmpp.send_message("guohaochuan@gmail.com", user.name+":"+unicode(i.__getattribute__('text')))
+                logging.info("original")
+
+            if status_code == xmpp.NO_ERROR :
+                updateMsgId(user,int(result[0].__getattribute__('id')))
+
+def checkMsg():
+    for name in watchName:
+        command="SELECT * FROM record where name = '"+name+"'"
+        q = db.GqlQuery(command)
+        num = q.count()
+        if num<>0:
+            if num == 1:
+                getMsg(q[0])
+        elif num==0:
+            addUser(name)
+            checkMsg()
+
+
+class realMain(webapp.RequestHandler):
+    def get(self):
+        checkMsg()
+
+application = webapp.WSGIApplication([('/dataa', realMain),],debug=True)
+
+def main():
+    run_wsgi_app(application)
+
+if __name__ == "__main__":
+    main()  

weibopy/parsers.pyc

Binary file modified.