API 总览
萌喵插件 SDK 全部主程序接口的职责分类、权限规则与调用约定。
在 plugin_install(api) 开头调用 api_init(api) 后,即可直接调用 plugin.h 提供的所有同名接口函数。
通用调用规则
- 工作线程调用:所有涉及网络请求的接口都会等待服务器回应,请在插件自己的工作线程中调用,不要阻塞消息或事件回调。
- 权限控制:受权限控制的接口其权限名与函数名一致;用户可在客户端插件页逐项开关,权限关闭时调用失败。
- 版本兼容:客户端未提供某项接口时,返回
bool的接口返回false,返回指针的接口返回NULL,free_*不执行操作。 - 资源交还:所有返回结构体指针或堆字符串(如红包 / 身份验证 JSON)的接口,无论成功还是失败,用完后都必须调用对应的
free_*函数交还;借用字符串(data_dir())除外。
按职责分类
| 领域 | 分组 | 包含接口 |
|---|---|---|
| 账号相关 | 账号管理 | list_accounts、get_bot_info、add_account、edit_account、offline_account、remove_account、set_nickname |
| 账号相关 | 登录验证 | list_protocols、list_devices、has_login_cache、login_cache、login_password、submit_captcha、send_sms、submit_sms |
| 账号相关 | 身份验证 | submit_identity_captcha、submit_identity_phone、confirm_identity_sms |
| 账号相关 | 凭据类 | get_client_key、get_skey、get_pskey |
| 好友相关 | 消息类 | send_friend_message、recall_friend_message |
| 好友相关 | 媒体类 | upload_friend_image、upload_friend_flash_image、upload_friend_video、upload_friend_voice |
| 好友相关 | 功能类 | list_friends、handle_friend_request、set_friend_remark、set_friend_block、set_friend_special_care、set_friend_msg_notify、delete_friend、get_summary_card、like_summary_card |
| 群聊相关 | 消息类 | send_group_message、recall_group_message、get_forward_message、upload_forward_message |
| 群聊相关 | 媒体类 | upload_group_image、upload_group_video、upload_group_voice |
| 群聊相关 | 红包类 | pre_grab_red_packet、grab_red_packet |
| 群聊相关 | 功能类 | list_groups、get_group_info、handle_group_request、rename_group、set_group_remark、set_group_msg_mask、set_group_member_name、set_group_special_title、set_group_admin、mute_group_member、sign_group、leave_group |
| 工具 | 工具类 | data_dir、write_log |