def decorated_view(*args, **kwargs): channel=kwargs['channel'] bot=kwargs['bot'] bot=Bot.gql("WHERE name = :1", bot).get() if bot: kwargs['bot']=bot return func(*args, **kwargs) return redirect(url_for('qq.list_bots', channel=channel.id))
def chant(remark): retort = {"toUser": remark["fromUser"], "fromUser": remark["toUser"], "createTime": int(time.time())} channel = remark["channel"] q = Bot.gql("WHERE channel = :1 AND activated = True", channel.key) for bot in q: module = LoadBot(channel, bot) retort = { MSG_TYPE_TEXT: module.process_text, MSG_TYPE_IMAGE: module.process_image, MSG_TYPE_LOCATION: module.process_location, MSG_TYPE_LINK: module.process_link, MSG_TYPE_EVENT: module.process_event, }[remark["msgType"]](remark, retort) retort["message"] = render_template("message.xml", message=retort) logging.info(retort["message"]) return retort
def ReloadAllBots(channel, bot): # Get the list of modules from the database and load them all q = Bot.gql("WHERE channel = :1 AND activated = True", channel.key) for bot in q: ReloadBot(channel, bot)