Commits

Anonymous committed d7a52a5

Hey Follower job saves to the db

Comments (0)

Files changed (2)

twitterbot/bot.py

                 except Exception, e:
                     print 'exception in: ', handler
                     print e
-                    pass
         self.seen.add(tweet.id)
 
     def listen(self):

twitterbot/heyfollower.py

                 c.execute('create table followers(name varchar(255), extra text)')
 
     def save(self, name, extra):
+        print 'saving: ', name, extra
         with Transaction(self.db) as c:
             c.execute('insert into followers VALUES (?, ?)',
-                      name, simplejson.dumps(extra))
-
-    __set__ = save
+                      (name, simplejson.dumps(extra)))
 
     def __contains__(self, name):
         with Transaction(self.db) as c:
             rows = c.execute('select * from followers WHERE name=?', (name,))
-            return rows.rowcount
+            if rows.rowcount > 0:
+                return True
+            return False
 
-    def __get__(self, name):
-        with Transaction(self.db) as c:
-            rows = c.execute('select * from followers where name=?', (name,))
-            row = rows.fetchone()
-            if row:
-                name, extra = row
-                return simplejson.loads(extra)
-        raise IndexError()
+    # def __get__(self, name):
+    #     with Transaction(self.db) as c:
+    #         rows = c.execute('select * from followers where name=?', (name,))
+    #         row = rows.fetchone()
+    #         if row:
+    #             name, extra = row
+    #             return simplejson.loads(extra)
+    #     raise IndexError()
         
 
 class HeyFollower(object):
         for follower in followers:
             if follower.screen_name not in self.followers:
                 new.append(follower)
+                self.followers.save(follower.screen_name, follower.AsDict())
+            else:
+                print follower.screen_name
         return new
 
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.