예제 #1
0
    def get_app(self):
        import tornado.web
        from werobot.contrib.tornado import make_handler

        tornado_app = tornado.web.Application([
            (self.endpoint, make_handler(self.robot)),
        ],
                                              debug=True)
        return tornado_app
예제 #2
0
    def get_app(self):
        import tornado.web
        from werobot.contrib.tornado import make_handler

        tornado_app = tornado.web.Application(
            [
                (self.endpoint, make_handler(self.robot)),
            ], debug=True
        )
        return tornado_app
예제 #3
0
def test_tornado(wsgi_tester, hello_robot):
    from tornado.wsgi import WSGIAdapter
    import tornado.web
    from werobot.contrib.tornado import make_handler

    token = generate_token()
    endpoint = r'/werobot_tornado'
    hello_robot.token = token

    tornado_app = tornado.web.Application([
        (endpoint, make_handler(hello_robot)),
    ], debug=True)
    wsgi_tester(WSGIAdapter(tornado_app), token=token, endpoint=endpoint)
예제 #4
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@license : (C) Copyright 2013-2018, Easy doesnt enter into grown-up life.
@Software: PyCharm
@Project : wechatInfo
@Time : 2018/5/14 下午9:59
@Author : achilles_xushy
@contact : [email protected]
@Site : 
@File : urls.py
@desc :
"""
import handle.interface
from handle.interface import we_robot
from werobot.contrib.tornado import make_handler


urls = [
    (r'/msg', make_handler(we_robot)),
    (r'.*', handle.interface.NoneHandle)
]

p_urls = [
    (r'/get_access_token', handle.interface.GetAccessToken),
    (r'.*', handle.interface.NoneHandle),
]

if __name__ == '__main__':
    pass
예제 #5
0
# encoding: utf-8
from emailUtil import emailSender

__author__ = 'lianggao'
__date__ = '2018/6/1 上午11:08'

import datetime
from werobot import WeRoBot
from werobot.contrib.tornado import make_handler
import re

robot = WeRoBot(token="你的token")

urls = [(r'reply', make_handler(robot))]
debug_list = []
exception_list = []
info_message = []


@robot.filter('kindle')
def replyKindle(message, session):
    count = session.get("kindle_count", 0)
    email = session.get("kindle_auth_email", "")
    if email is "":
        session["kindle_count"] = count + 1
        return "输入Kindle邮箱:"
    else:
        return "请输入要找的书名:"


@robot.filter("重新绑定")
예제 #6
0
from werobot import WeRoBot
from werobot.contrib.tornado import make_handler

robot = WeRoBot(token='VectorMachine')


@robot.text
def echo(message):
    return message.content


@robot.handler
def hello(message):
    return 'Hello World!'


WxMpHandler = make_handler(robot)
예제 #7
0
 def __init__(self):
     handlers = [
         (r'/weixin/', make_handler(robot)),
     ]
     super(Application, self).__init__(handlers,
                                       **settings.log)  # 加载settings配置
예제 #8
0
        if not selected.count():
            return NO_SONG
        elif selected.count() > 1:
            return TOO_MANY_SONGS + '\n' + '\n'.join([
                '{id} {title} ({comment})'.format(**i) for i in selected])

        selected = selected.next()
        return werobot.replies.MusicReply(
            message=message,
            title='{0} ({1})'.format(selected['title'], selected['comment']),
            description=SONG_DESCRIPTION.format(selected['id'], selected['date']),
            url='{0}/{1}.mp3'.format(RESOURCE_URL, selected['id']))

    elif command in CMD_STAT:
        if args:
            return TOO_MANY_ARGS

        return STAT.format(
            int(((time.time() - start_time) / (60*60*24.))*10)/10.,
            collection.count({'status': 'checked'}),
            collection.count({'status': 'pending'}))


if __name__ == '__main__':
    application = tornado.web.Application([
        (r"/", make_handler(robot)),
    ])
    application.listen(PORT)
    tornado.ioloop.IOLoop.instance().start()
예제 #9
0
        session.add(wechat)
    session.commit()
    session.close()

    return SuccessReply()


class TemplateHandler(tornado.web.RequestHandler):
    def post(self):
        if self.request.body:
            data = json_decode(self.request.body)
            r = myrobot.client.post(
                url="https://api.weixin.qq.com/cgi-bin/message/template/send",
                data=data
            )
            self.write(r)
        else:
            self.set_status(400)
            self.write({"code": 40001, "message": "无效的data"})


application = tornado.web.Application([
    (r"/robot/", make_handler(myrobot)),
    (r"/template/", TemplateHandler)
])


if __name__ == "__main__":
    application.listen(8888)
    tornado.ioloop.IOLoop.instance().start()