python-wechaty icon indicating copy to clipboard operation
python-wechaty copied to clipboard

Feature Request: RESTFUL API should be supported in python-wechaty

Open wj-Mcat opened this issue 3 years ago • 4 comments

Original Intention

In these days, some developers try to add more abilities to bot, eg: saving chat history, enable restapi in python-wechaty bot and sync the messages between specific rooms. The first one has been accompished, So I wanna to get second done in next days.

What does RESTFUL API look like ?

talk is cheap, show the mvp code.

from wechaty import Wechaty, WechatyPlugin

class Bot(Wechaty):
    async def register_blueprints(self, app):
        @app.route('/hello-bot')
        async def say_hello():
            pass

class MessagePlugin(WechatyPlugin):
    async def register_blueprints(self, app):
        @app.route('/send-message-to-my-baby')
        async def say_morning():
            pass

Once you register your blueprint to app, swagger-doc will be generated by default. Above code is simple but powerful. Do you think so ?

Web Frameworks

There are some great async-based web frameworks, and I will choose the popular & fast one in the design. Please give yourself suggestion: What do you choose ? and Why do you choose it ?

Frameworks:

wj-Mcat avatar Sep 28 '21 06:09 wj-Mcat

I choose FastApi and Quart.

fangjiyuan avatar Sep 28 '21 06:09 fangjiyuan

I choose FastApi and Quart.

Can you give the reason why you choose it ?

wj-Mcat avatar Sep 28 '21 06:09 wj-Mcat

I choose FastApi because it is async-friendly and can automatically generate Swagger-API.

lyleshaw avatar Sep 28 '21 06:09 lyleshaw

I choose FastApi and Quart.

Can you give the reason why you choose it ?

FastApi can make route,its usefull for me.Quart is a async-based web framework like flask.

fangjiyuan avatar Sep 28 '21 07:09 fangjiyuan