Skip to main content

Python SDK for Feishu / Lark

Project description


authors:

  • Zhiyuan Chen date: 2022-05-04

OpenFeishu

OpenFeishu 是一个飞书开放平台的 Python SDK,提供了飞书开放平台的接口封装,方便开发者使用飞书开放平台的接口。

使用

发送消息

from feishu import variables, send_message

variables.app_id = 'app_id'
variables.app_secret = 'app_secret'

send_message('hello, world!', 'chat_id')

调用 ChatGPT 回复用户消息

from feishu import variables, send_message, get_gpt_completions

variables.app_id = 'app_id'
variables.app_secret = 'app_secret'
variables.openai_key = 'openai_key'

content = get_gpt_completions([dict(role='user', content='Hi, How are you?')])
send_message(content, "message_id")

飞书机器人

from feishu.robot import han

variables.app_id = 'app_id'
variables.app_secret = 'app_secret'
variables.openai_key = 'openai_key'

def handle_event(request: NestedDict) -> dict:
    if not isinstance(request, NestedDict):
        request = NestedDict(request)
    event = request.get("event")
    event["id"] = request.get("header", {}).get("event_id")
    event["type"] = request.get("header", {}).get("event_type")
    if event["type"] == "im.message.receive_v1":
        return handle_chat(env, request)

安装

从 PyPI 安装最新的稳定版本:

pip install open-feishu

从源代码安装最新版本:

pip install git+https://github.com/ZhiyuanChen/open-feishu.git

许可证

SPDX-License-Identifier: AGPL-3.0-or-later

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

open_feishu-0.0.5.tar.gz (6.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

open_feishu-0.0.5-py3-none-any.whl (61.9 kB view details)

Uploaded Python 3

File details

Details for the file open_feishu-0.0.5.tar.gz.

File metadata

  • Download URL: open_feishu-0.0.5.tar.gz
  • Upload date:
  • Size: 6.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for open_feishu-0.0.5.tar.gz
Algorithm Hash digest
SHA256 42e67c350a21dc5e219adafa9a5f87a91af9195ba1e1a20f7305568800ed9768
MD5 9af802e9abcad379a8c407d414d73881
BLAKE2b-256 730b0ffea8a404d05214077abd15cc0b41aef75db3eec2f2aee6fb7474f435c5

See more details on using hashes here.

File details

Details for the file open_feishu-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: open_feishu-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 61.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for open_feishu-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 a4fce67c747052e1f2bc7cc5257ad914d1e49cb3f7d66d42f4b8b755efaaaf5c
MD5 abd63b5513096a9a09eef8601153a40e
BLAKE2b-256 5b980b9889ea97afd56477ff930e71a78b2906280f31a63b045ca53e2fb6c0a4

See more details on using hashes here.

Supported by

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