Skip to main content

feishu chatbot api

Project description

简介

基于飞书官方文档,封装的飞书消息机器人接口。支持简单的消息格式校验,获取发送消息所需 file_key, image_key 等。

使用示例

安装

pip install -U feishu-chatbot

发送文本

client = ChatBotClient(app_id="xxx", app_secret='xxx')
user = client.get_user_id_by_email("user_email")
data = {
    "msg_type": "text",
    "content": json.dumps({"text": "测试文本"}),
    "receive_id": user["open_id"],  # or user["user_id"]
}
TextChatBot.set_client(client).set_data(data).build().send()  # receive_id 默认使用 open_id
TextChatBot.set_client(client).set_receive_id_type("user_id").set_data(data).build().send()  # receive_id 默认使用 user_id

发送视频

client = ChatBotClient(app_id="xxx", app_secret='xxx')
user = client.get_user_id_by_email("user_email")

# 上传图片和文件获取对应的 key 信息
image_key = client.get_image_key("...")
file_key = client.get_file_key("...")

data = {
    "msg_type": "media",
    "content": json.dumps({"file_key": file_key, "image_key": image_key}),
    "receive_id": user["open_id"],
}
MediaChatBot.set_client(client).set_data(data).build().send()

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

feishu_chatbot-0.0.3.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

feishu_chatbot-0.0.3-py3-none-any.whl (22.4 kB view details)

Uploaded Python 3

File details

Details for the file feishu_chatbot-0.0.3.tar.gz.

File metadata

  • Download URL: feishu_chatbot-0.0.3.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.23.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.3

File hashes

Hashes for feishu_chatbot-0.0.3.tar.gz
Algorithm Hash digest
SHA256 96d3f3ec54824e18d17a682305e8a9a065a0879caf1613c0b23343c5c778de8e
MD5 6b18841e1073ce6c792a8439bb9a6a2b
BLAKE2b-256 65ff8d4e25344f0fc310d59d0f63339a7ad9bfbf2b85fbaaaac54926f0aa39b7

See more details on using hashes here.

File details

Details for the file feishu_chatbot-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: feishu_chatbot-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 22.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.23.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.3

File hashes

Hashes for feishu_chatbot-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 72f600cd119e172d22ea3ad4a91317dc6d70d9909f3b880029f2a46fe26da916
MD5 c6216e0a029e0c24cd8ec5b0dae9a813
BLAKE2b-256 9daad0eb433237754efad4ae2efd71547de9e2746ae1fc5e3cf8d5e8ff493a90

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page