Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/juvenn/notifixlight
Browse files Browse the repository at this point in the history
  • Loading branch information
julien51 committed Jan 6, 2010
2 parents d1f78a4 + 982f3ea commit 7eefeb1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
6 changes: 6 additions & 0 deletions index.yaml
@@ -1,5 +1,11 @@
indexes:

- kind: Subscription
properties:
- name: jid
- name: created_at
direction: desc

# AUTOGENERATED

# This index.yaml is automatically updated whenever the dev_appserver
Expand Down
25 changes: 22 additions & 3 deletions main.py
Expand Up @@ -41,8 +41,8 @@ def superfeedr(mode, subscription):
##
# The subscription model that matches a feed and a jid.
class Subscription(db.Model):
feed = db.TextProperty(required=True)
jid = db.TextProperty(required=True)
feed = db.LinkProperty(required=True)
jid = db.StringProperty(required=True)
created_at = db.DateTimeProperty(required=True, auto_now_add=True)

##
Expand Down Expand Up @@ -117,6 +117,21 @@ def unsubscribe_command(self, message=None):
subscription.delete() # saves the subscription
message.reply("Well done! You're not subscribed anymore to " + message.arg)

##
# List subscriptions
def ls_command(self, message=None):
message = xmpp.Message(self.request.POST)
subscriber = message.sender.rpartition("/")[0]
query = Subscription.all().filter("jid =",subscriber).order("-created_at")
subscriptions = query.fetch(10)
if not subscriptions:
message.reply("Seems you subscribed nothing yet. Type\n /subscribe http://superfeedr.com/dummy.xml\nto play around.")
else:
message.reply("Your recent subscriptions:\n")
feed_list = [s.feed for s in subscriptions]
message.reply("\n".join(feed_list))
message.reply(message.body)

##
# Asking for help
def hello_command(self, message=None):
Expand All @@ -128,7 +143,11 @@ def hello_command(self, message=None):
# Asking for help
def help_command(self, message=None):
message = xmpp.Message(self.request.POST)
message.reply("That's easy, just type /subscribe <url> or /unsubscribe <url>")
message.reply("It's not even alpha ready, but you could play with following commands:\n\n")
message.reply("/hello\n say hello to 2010\n\n")
message.reply("/subscribe <url>\n/unsubscribe <url>\n subscribe or unsubscribe to a feed\n\n")
message.reply("/ls\n list recent 10 subscriptions\n\n")
message.reply("/help\n print these commands info\n\n")
message.reply(message.body)

##
Expand Down

0 comments on commit 7eefeb1

Please sign in to comment.