Giter Site home page Giter Site logo

fastapi-wework-robot's Introduction

FastAPI-WeWork-Robot

基于FastAPI创建的、使用企业微信交互的机器人系统

起因

我从去年想要拥有一个TODOlist开始,一步步的拓展这个想法:从单纯的列出任务,到任务到期提醒...一点点的有其他新的想法。

关于推送方式,我最早是希望通过发送邮件,然后通过微信企业邮的邮件提醒达到推送效果,而后发现了server酱,又开始使用这种方式实现微信推送,期间又接触了某个可以白嫖的短信api,但是免费一个帐号大概400条(配置还很麻烦),最终因为学校的企业微信最近推送了好几条消息...意识到企业微信是目前最适合的推送方式。

当然,单纯了做了任务提醒的功能后,发现企业微信的api还挺好玩的,于是一点点看文档写了其他一些小功能(参考func.py文件)

配置及使用

requirements:fastapi,uvicorn

企业微信配置

首先,请配置config.py文件按要求填写:

# sToken和sEncodingAESKey来自于企业微信创建的应用
# sCorpID为企业微信号

sToken = ""
sEncodingAESKey = ""
sCorpID = ""

中间件配置

如果想手动设置中间件(默认为不限制访问),请参考FastAPI文档设置main.py文件中的如下代码

app.add_middleware(
    CORSMiddleware,
    allow_origins=['*'],
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)

使用

请先启动main.py程序

然后按照企业微信的要求完成URL验证。

而后即可正常使用。

自定义功能

如果您需要自定义企业微信被动回复功能,可以对func.py文件中的handle_msg函数进行修改。

handle_msg有两个参数

  • to_user_id: str # 用户名
  • recived_msg: str # 用户发送的信息

返回值即为被动回复的消息内容

反馈&联系我

本项目基于企业微信官方python库进行修改。

如果有其他问题,可以通过如下方式联系我

fastapi-wework-robot's People

Contributors

lyleshaw avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.