Giter VIP home page Giter VIP logo

gentlecp / corpwechatbot Goto Github PK

View Code? Open in Web Editor NEW
268.0 4.0 49.0 31.93 MB

企业微信的python封装接口,简易上手,开箱即用,一行代码实现消息推送。A more convenient python wrapper interface of corpwechat(wework, wecom) official API, use only one line of code to send your messages to your corpwechat(wework, wecom) .

Home Page: https://corpwechatbot.gentlecp.com

License: GNU General Public License v3.0

Python 100.00%
wechat message-sending bot notifications wework wecom python api

corpwechatbot's Introduction

GentleCP

🖐️Hi,there. I'm GentleCP, a student from the University of China Academy of Sciences, welcome to my Github profile.

GentleCP's github stats

corpwechatbot's People

Contributors

gentlecp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

corpwechatbot's Issues

【ERROR】 发送失败!,原因:not allow operate another agent with this accesstoken.

位于

https://github.com/GentleCP/corpwechat-bot/blob/29d396dc13b82243a3960b33a83ba4c4aea87d23/corpwechatbot/app.py

的源码

CUR_PATH = Path(__file__)
TOKEN_PATH = CUR_PATH.parent.joinpath('token.txt')  # 存储在本项目根目录下

缓存了token,但是根据企业微信的api的报错来看,not allow operate another agent with this accesstoken,针对不同的自建第三方应用,需要不同的token,这里缓存的token应该对此作出调整。

复现步骤,创建两个不同的自建应用。

分别使用不同的应用的corpsecret和agentid创建AppMsgSender实例,用不同的AppMsgSender推送消息到客户端。

群机器人

群机器人发送 运行没有返回错误 但是消息也没法出去

touser为空列表

send_text()方法的touser参数为空列表[]时,程序的行为应该是不发送通知。但是实际情况是它会向所有人发送通知,其行为类似@all

电脑上开了clash代理,然后就会报错

我的clash可以正常访问外网和墙内,但不知道为啥就是corpwechatbot报错,以下是报错信息,
Traceback (most recent call last):
File "urllib3\connectionpool.py", line 696, in urlopen
File "urllib3\connectionpool.py", line 964, in prepare_proxy
File "urllib3\connection.py", line 359, in connect
File "urllib3\connection.py", line 496, in connect_tls_proxy
File "urllib3\util\ssl
.py", line 432, in ssl_wrap_socket
File "urllib3\util\ssl
.py", line 474, in _ssl_wrap_socket_impl
File "ssl.py", line 500, in wrap_socket
File "ssl.py", line 1040, in _create
File "ssl.py", line 1309, in do_handshake
OSError: [Errno 0] Error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "requests\adapters.py", line 439, in send
File "urllib3\connectionpool.py", line 755, in urlopen
File "urllib3\util\retry.py", line 573, in increment
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='qyapi.weixin.qq.com', port=443): Max retries exceeded with url: /cgi-bin/gettoken?corpid=*&corpsecret= (Caused by ProxyError('Cannot connect to proxy.', OSError(0, 'Error')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "任务计划w.py", line 16, in
File "corpwechatbot\app.py", line 57, in init
File "corpwechatbot\app.py", line 62, in __fresh_msg_send_api
File "corpwechatbot\app.py", line 107, in get_assess_token
File "corpwechatbot\app.py", line 111, in __get_access_token
File "requests\api.py", line 76, in get
File "requests\api.py", line 61, in request
File "requests\sessions.py", line 542, in request
File "requests\sessions.py", line 655, in send
File "requests\adapters.py", line 510, in send
requests.exceptions.ProxyError: HTTPSConnectionPool(host='qyapi.weixin.qq.com', port=443): Max retries exceeded with url: /cgi-bin/gettoken?corpid=&corpsecret= (Caused by ProxyError('Cannot connect to proxy.', OSError(0, 'Error')))

感谢大佬的分享

请问可以出一个和腾讯云开发的定时器联动的教程吗? 萌新想搞一个定时回复,不会配置0.0

用于回调消息的示例代码web.py运行出错

源代码取自:https://gist.github.com/GentleCP
源代码未做任何修改,但是Crypto.Cipher模块pycrypto已经无法安装了,百度后使用的替代品pycryptodome(安装方式 pip install pycryptodome)
部署到腾讯云上后可以正常运行,但是每次收发消息都会报错:

ERROR: Exception in ASGI application
Traceback (most recent call last):
File "/usr/local/python3/lib/python3.8/site-packages/uvicorn/protocols/http/h11_impl.py", line 373, in run_asgi
result = await app(self.scope, self.receive, self.send)
File "/usr/local/python3/lib/python3.8/site-packages/uvicorn/middleware/proxy_headers.py", line 75, in call
return await self.app(scope, receive, send)
File "/usr/local/python3/lib/python3.8/site-packages/fastapi/applications.py", line 208, in call
await super().call(scope, receive, send)
File "/usr/local/python3/lib/python3.8/site-packages/starlette/applications.py", line 112, in call
await self.middleware_stack(scope, receive, send)
File "/usr/local/python3/lib/python3.8/site-packages/starlette/middleware/errors.py", line 181, in call
raise exc from None
File "/usr/local/python3/lib/python3.8/site-packages/starlette/middleware/errors.py", line 159, in call
await self.app(scope, receive, _send)
File "/usr/local/python3/lib/python3.8/site-packages/starlette/exceptions.py", line 82, in call
raise exc from None
File "/usr/local/python3/lib/python3.8/site-packages/starlette/exceptions.py", line 71, in call
await self.app(scope, receive, sender)
File "/usr/local/python3/lib/python3.8/site-packages/starlette/routing.py", line 580, in call
await route.handle(scope, receive, send)
File "/usr/local/python3/lib/python3.8/site-packages/starlette/routing.py", line 241, in handle
await self.app(scope, receive, send)
File "/usr/local/python3/lib/python3.8/site-packages/starlette/routing.py", line 52, in app
response = await func(request)
File "/usr/local/python3/lib/python3.8/site-packages/fastapi/routing.py", line 226, in app
raw_response = await run_endpoint_function(
File "/usr/local/python3/lib/python3.8/site-packages/fastapi/routing.py", line 159, in run_endpoint_function
return await dependant.call(**values)
File "/home/zk/mycode/wx_web/web.py", line 112, in recv
ret, send_msg = wxcpt.EncryptMsg(sReplyMsg=sRespData, sNonce=nonce)
UnboundLocalError: local variable 'sRespData' referenced before assignment

centos运行时发送markdown报Filename too long

  self.corp_wechat_app.send_markdown(m)
  File "/usr/local/lib/python3.10/site-packages/corpwechatbot/app.py", line 379, in send_markdown
    if md_path.is_file():
  File "/usr/local/lib/python3.10/pathlib.py", line 1322, in is_file
    return S_ISREG(self.stat().st_mode)
  File "/usr/local/lib/python3.10/pathlib.py", line 1097, in stat
    return self._accessor.stat(self, follow_symlinks=follow_symlinks)
OSError: [Errno 36] Filename too long: '

看了一下代码,把发送的内容构建一个Path判断是否是文件,导致os抛出文件名过长,作者这里是否可以加个内容长度判断

有没有计划出搭建服务端的功能?

首先非常感谢您分享这么好用的项目!以前用server酱,消息展示不够直观,一直不满意,直到偶尔间看到这个项目,简直太棒了!
我的应用场景是多台机器运行自动化脚本,用来监控异常发出通知,但现在是每台机器都要部署 有点麻烦,如果是可以搭建服务端,只需要在一台机器部署 可以方便很多。可是搭建服务端这块自己不懂,fastapi看了两天没学会……

access_token和token

根据api请求的access_token和在管理后台接收消息里配置的token是不是同一个啊?不是同一个它们有什么关系?

access_token missing

image
之前用您的包好好的,结果我在新服务器上配置的时候,就出现了这样的问题,查阅了网上很多说明都没有得到解决,请问我该怎么办?而且配置好您的包之后,需要自己添加一个token.txt文件,我很迷茫,我应该把token.txt文件放在哪?而且文件里的内容我改填写什么?

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.