昵称中允许数字
[gaetalk.git] / counter.py
blobc9459a3214e26107dac4df24b9dd5540da13d45b
1 #!/usr/bin/env python2
2 # vim:fileencoding=utf-8
4 from google.appengine.api import xmpp
5 from google.appengine.api import memcache
6 import datetime
8 old_send_presence = xmpp.send_presence
9 old_send_message = xmpp.send_message
11 def count(type):
12 name = '%s_%s' % (type, datetime.datetime.now().strftime('%Y-%m-%d_%H'))
13 memcache.incr(name, initial_value=0)
15 def send_presence(*args, **kwargs):
16 count('presence')
17 old_send_presence(*args, **kwargs)
19 def send_message(*args, **kwargs):
20 count('message')
21 old_send_message(*args, **kwargs)
23 xmpp.send_presence = send_presence
24 xmpp.send_message = send_message