Exemple #1
0
 def decorated_view(*args, **kwargs):
     channel=kwargs['channel']
     channel=Channel.gql("WHERE id = :1", channel).get()
     if channel:
         kwargs['channel']=channel
         return func(*args, **kwargs)
     return redirect(url_for('qq.list_channels'))
Exemple #2
0
def populate():
    q=Channel.gql("WHERE id=:1", 'koan')
    channel=q.get()
    code="""
__author__ = 'peter'

from application import settings
import logging

MSG_TYPE_TEXT = u'text'
MSG_TYPE_LOCATION = u'location'
MSG_TYPE_IMAGE = u'image'

def process_text(remark, retort):
    if remark['content']:
        retort['content']='Bot Spawned!'
        retort['msgType']=MSG_TYPE_TEXT
        retort['funcFlag']=0
    return retort

def process_location(remark, retort):
    return retort

def process_image(remark, retort):
    return retort
    """
    bot=Bot(name=u'spawn', code=code, channel=channel.key)
    bot.put()
    return 'populated.'
Exemple #3
0
 def decorated_view(*args, **kwargs):
     signature=request.args.get('signature')
     timestamp=request.args.get('timestamp')
     nonce=request.args.get('nonce')
     echostr=request.args.get('echostr')
     channel=kwargs['channel']
     q=Channel.gql("WHERE id = :1", channel)
     c=q.get()
     if c:
         kwargs['channel']=c
         token=c.token
         if sha1(''.join(sorted([token, timestamp, nonce]))).hexdigest()==signature:
             if request.method=='GET':
                 return echostr
             else:
                 return func(*args, **kwargs)
     return func(*args, **kwargs)