-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
107 lines (88 loc) · 2.53 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# -*- coding: utf-8 -*-
import os,sys
reload(sys)
sys.setdefaultencoding('utf-8')
import unicodedata
from flask import Flask
from flask.ext.werobot import WeRoBot
from werobot.client import Client
app = Flask(__name__)
robot = WeRoBot(app, token = "waiter1109", rule = '/test')
mywxid = "wx088f6d071740acfc"
mywxsecret = "524a1ebcc15b4e4f27c66f02f071c5ff"
@robot.subscribe
def echo(message):
return '你好! 欢迎关注逸筠提琴!'
@robot.unsubscribe
def echo(message):
return '舍不得跟你分开'
import re
@robot.filter(re.compile('^[a-zA-Z]+'))
def echo(message):
from werobot.reply import TextReply
from interface import youdao
fanyi= youdao(message.content)
reply = TextReply(message=message, content=''+fanyi)
return reply
@robot.filter(re.compile(u'.*音乐.*'))
def echo(message):
return [
"微信你不懂爱",
"龚琳娜最新力作",
"http://weixin.com/budongai.mp3",
]
@robot.text
def echo(message):
from werobot.reply import TextReply
from interface import turling
robotrep = turling(message.content)
#robotrep = turling('你好')
reply = TextReply(message=message, content=robotrep)
return reply
@robot.image
def echo(message):
from werobot.reply import ArticlesReply, Article
from interface import face
reply = ArticlesReply(message=message)
article = Article(
title = "智能测试心理年龄",
description = face(message.img),
img = message.img,
url = "http://mp.weixin.qq.com/s?__biz=MzIwNjE2Mjg5NA==&mid=402671317&idx=1&sn=5abcb6337a32d66248cfd06504c29401#rd"
)
reply.add_article(article)
return reply
#client = Client(mywxid, mywxsecret)
#client.create_menu({
# "button":[
# {
# "type":"click",
# "name":"今日歌曲",
# "key":"V1001_TODAY_MUSIC"
# },
# {
# "type":"click",
# "name":"歌手简介",
# "key":"V1001_TODAY_SINGER"
# },
# {
# "name":"菜单",
# "sub_button":[
# {
# "type":"view",
# "name":"搜索",
# "url":"http://www.soso.com/"
# },
# {
# "type":"view",
# "name":"视频",
# "url":"http://v.qq.com/"
# },
# {
# "type":"click",
# "name":"赞一下我们",
# "key":"V1001_GOOD"
# }
# ]
# }
# ]})