Example #1
0
File: wx.py Project: lazygunner/wx
# -*- coding: utf-8 -*-
from flask import Flask
from flask.ext.mongoengine import MongoEngine
from wx_flask import Weixin
from games import GuessNum
from xiaoi_api import XiaoI
import json
import datetime

app = Flask(__name__)
app.config["MONGODB_SETTINGS"] = {'DB':"wx"}
app.config["SECRET_KEY"] = "kalashinikov"
app.config["WEIXIN_TOKEN"] = ""
app.config["XIAOI_KEY"] = "aJin1z1o3rO4"
app.config["XIAOI_SECRET"] = "iaYtLxk3P3dDlQBTH61i"


db = MongoEngine(app)

weixin = Weixin(app)
app.add_url_rule('/', view_func=weixin.view_func)

xiaoi = XiaoI(app)

@weixin(u'段子')
def reply_duanzi(**kwargs):
    from model import Duanzi 
    import random
    username = kwargs.get('sender')
    sender = kwargs.get('receiver')
    message_type = kwargs.get('type')