A tools for send message to company wechat.
Project description
cowechatapi
这是一个发送消息到企业微信的接口工具 仅支持在python3环境下执行,支持系统:Linux、windows其他暂未验证 消息类型支持: 文本、图片、声音、视频和文件
安装依赖
pip install requests
pip安装
pip install cowechatapi
通过调用API接口发送消息
调用企业微信API接口发送消息给指定用户 文本消息例子:
from cowechatapi.cowechat_api import CoWechatAPI
bot = CoWechatAPI(coid="your_company_id", secret="your_app_secret",agentid=1000001)
bot.send(to_user="USER_NAME", msg_type="text", content="今天天气好吗?")
文件消息例子:
from cowechatapi.cowechat_api import CoWechatAPI
bot = CoWechatAPI(coid="your_company_id", secret="your_app_secret",agentid=1000001)
bot.send(to_user="USER_NAME", msg_type="file", media_id="MEDIA_ID")
图片消息例子:
from cowechatapi.cowechat_api import CoWechatAPI
bot = CoWechatAPI(coid="your_company_id", secret="your_app_secret",agentid=1000001)
bot.send(to_user="USER_NAME", msg_type="image", media_id="MEDIA_ID")
media_id的获取方法是通过API的upload上传临时素材得到的,临时素材有效期为两天。
上传临时素材例子:
from cowechatapi.cowechat_api import CoWechatAPI
bot = CoWechatAPI(coid="your_company_id", secret="your_app_secret",agentid=1000001)
bot.upload(filetype="image", fileurl="FILE_PATH")
通过命令行方式发送消息
例子:
# 发送文本消息
python3 -m cowechat -i [your_company_id] -s [your_app_secret] -a [your_agentid] -m text -c "content" --user [USER_NAME]
# 发送图片消息
python3 -m cowechat -i [your_company_id] -s [your_app_secret] -a [your_agentid] -m image --media [media_id] --user [USER_NAME]
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
cowechatapi-0.1.5.tar.gz
(5.5 kB
view details)
Built Distribution
File details
Details for the file cowechatapi-0.1.5.tar.gz
.
File metadata
- Download URL: cowechatapi-0.1.5.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f053aabf114576ce66f609f26dbe46bbc52eeab2ef9890e0098d06b1d02a5433 |
|
MD5 | b6db4e952628b9e46f7c2fdfa24f5ad9 |
|
BLAKE2b-256 | ea9b159c5307ac66963579149a096dde011c540bc22d7ce212215952f8a74d90 |
File details
Details for the file cowechatapi-0.1.5-py3-none-any.whl
.
File metadata
- Download URL: cowechatapi-0.1.5-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e4433b3ec79d65a6afeafd9c52e06d1be81fd5b79d4dfb05a22c0f59fa837d2 |
|
MD5 | 6ec26a02c592e7cd4ef8d1499a6e2da8 |
|
BLAKE2b-256 | d7a46e46847d88f63723dfa92fed3df7845f79ab94fd5f441c012070ddc24953 |