Skip to main content

大别野「黑塔」Python SDK

Project description

Herta-villa-SDK

license pypi python version Ruff

大别野「黑塔」Python SDK

特性

  • 多种服务器后端(内置 aiohttpfastapi 后端),完整异步支持
  • 完整类型注解支持
  • ...

安装

pip install herta-villa-sdk

FastAPI 后端支持:

pip install herta-villa-sdk[fastapi]

快速开始

你需要拥有一个大别野机器人。可前往大别野「机器人开发者社区」OpenVilla)申请。

from hertavilla import MessageChain, SendMessageEvent, VillaBot, run


PUB_KEY = """-----BEGIN PUBLIC KEY-----
aaa
bbb
ccc
-----END PUBLIC KEY-----
"""  # 开放平台 pub_key
# 需要注意 `-----BEGIN PUBLIC KEY-----` 前没有换行符
#  `-----END PUBLIC KEY-----` 后有一个换行符
# 目前从网页端复制下来的时候会为一串 pub_key,需要将空格转为换行

bot = VillaBot(
    "bot_id",  # 这里填写 bot_id
    "bot_secret",  # 这里填写 secret
    "/",  # bot 回调 endpoint
    PUB_KEY,  # 开放平台提供的 pub_key
)


@bot.startswith("/")  # 注册一个消息匹配器,匹配前缀为 / 的消息
async def _(event: SendMessageEvent, bot: VillaBot):
    message = event.message
    if str(message[1]) == "/hello":
        chain = MessageChain()
        chain.append("world")
        await bot.send(event.villa_id, event.room_id, chain)


run(bot)  # 运行 bot

可以向你的 bot 发送 @Bot /hello,bot 会回复 world

示例

详见 examples 文件夹

支持的 API

  • 鉴权
    • 校验用户机器人访问凭证 /checkMemberBotAccessToken
  • 大别野
    • 获取大别野信息 /getVilla
  • 用户
    • 获取用户信息 /getMember
    • 获取大别野成员列表 /getVillaMembers
    • 踢出大别野用户 /deleteVillaMember
  • 消息
    • 置顶消息 /pinMessage
    • 撤回消息 /recallMessage
    • 发送消息 /sendMessage
  • 房间
    • 创建分组 /createGroup
    • 编辑分组 /editGroup
    • 删除分组 /deleteGroup
    • 获取分组列表 /getGroupList
    • 编辑房间 /editRoom
    • 删除房间 /deleteRoom
    • 获取房间信息 /getRoom
    • 获取房间列表信息 /getVillaGroupRoomList
  • 身份组
    • 向身份组操作用户 /operateMemberToRole
    • 创建身份组 /createMemberRole
    • 编辑身份组 /editMemberRole
    • 删除身份组 /deleteMemberRole
    • 获取身份组 /getMemberRoleInfo
    • 获取大别野下所有身份组 /getVillaMemberRoles
  • 表态表情
    • 获取全量表情 /getAllEmoticons
  • 审核 /audit

支持的事件

Bug 反馈及建议

大别野 Bot 和 Herta SDK 均处于开发状态中,如遇到问题或有相关建议可通过 Issue 提出,感谢支持!

相关项目

交流

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

herta_villa_sdk-0.6.0.tar.gz (22.2 kB view details)

Uploaded Source

Built Distribution

herta_villa_sdk-0.6.0-py3-none-any.whl (29.8 kB view details)

Uploaded Python 3

File details

Details for the file herta_villa_sdk-0.6.0.tar.gz.

File metadata

  • Download URL: herta_villa_sdk-0.6.0.tar.gz
  • Upload date:
  • Size: 22.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.8.0 CPython/3.10.6

File hashes

Hashes for herta_villa_sdk-0.6.0.tar.gz
Algorithm Hash digest
SHA256 da31791f431bbeaaa81ab92007315b4c50e65f24b6ef5dd551d9445cf0e74551
MD5 afb9ded86f221555404c771807b2bea6
BLAKE2b-256 8a63588201289354a5384522a15d45bbb8c57a852f2092e37c8c479316aebb9b

See more details on using hashes here.

File details

Details for the file herta_villa_sdk-0.6.0-py3-none-any.whl.

File metadata

File hashes

Hashes for herta_villa_sdk-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 01c46cc3f16dc120cc65e486cde7df876c07979394dcf383af5086f8d715749c
MD5 ff61f0193c0ddb4c2b0bf6c3525402b5
BLAKE2b-256 04f1a3898715307187675b1e5407734134eaee07c589b3bcfd1025b97c07828f

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