Skip to content
This repository has been archived by the owner on Aug 2, 2020. It is now read-only.

Commit

Permalink
Update CQP.lib and add new APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
stdrc committed May 31, 2017
1 parent 07f9ac8 commit 009bbb8
Show file tree
Hide file tree
Showing 9 changed files with 209 additions and 139 deletions.
1 change: 1 addition & 0 deletions CoolQHttpApi.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
<ClCompile Include="src\request_handlers.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="lib\include\cqp.h" />
<ClInclude Include="src\app.h" />
<ClInclude Include="src\base64.h" />
<ClInclude Include="src\cqcode.h" />
Expand Down
6 changes: 6 additions & 0 deletions CoolQHttpApi.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
<Filter Include="src\ini">
<UniqueIdentifier>{465f1c21-e329-4ab1-8508-7dd3322b8fe2}</UniqueIdentifier>
</Filter>
<Filter Include="lib\include">
<UniqueIdentifier>{19227b5a-b47b-473b-85b3-a38e3b6a30d6}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<None Include="io.github.richardchien.coolqhttpapi.json" />
Expand Down Expand Up @@ -103,5 +106,8 @@
<ClInclude Include="src\md5.h">
<Filter>src\encoding</Filter>
</ClInclude>
<ClInclude Include="lib\include\cqp.h">
<Filter>lib\include</Filter>
</ClInclude>
</ItemGroup>
</Project>
18 changes: 16 additions & 2 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@ Authorization: token kSLuTF2GC2Q4q4ugm3

> 需要指出的是,某些接口暂未进行错误代码的处理,此时即使发生错误,仍返回0。
`status` 字段如果是 `failed` 则表示操作失败,此时 `retcode` 有两种情况,当大于 0 时,表示是 HTTP API 插件判断出的失败(此时根本不用调用酷 Q 的函数就可以确定操作失败,比如调用 API 时没有传入必须的字段),这个目前有如下情况:
`status` 字段如果是 `failed` 则表示操作失败,此时 `retcode` 有两种情况,当大于 0 时,表示是 HTTP API 插件判断出的失败,这个目前有如下情况:

| 返回码 | 说明 |
| ------- | ---------------------------------------- |
| 100 | 默认的错误码,通常是因为没有传入必要参数,某些接口中也可能因为参数明显无效,比如传入的 QQ 号小于等于 0 |
| 100 | 默认的错误码,通常是因为没有传入必要参数,某些接口中也可能因为参数明显无效,比如传入的 QQ 号小于等于 0,此时无需调用酷 Q 函数即可确定失败 |
| ~~101~~ | ~~调用的接口路径不存在~~(这种情况现已直接通过 HTTP 状态码 404 来表示) |
| 102 | 酷 Q 函数返回的数据无效,一般是因为传入参数有效但没有权限,比如试图获取没有加入的群组的成员列表 |

另外一种情况是 `retcode` 小于 0,此时即为调用酷 Q 函数的返回码,具体含义直接参考 [Pro/开发/Error](https://d.cqp.me/Pro/%E5%BC%80%E5%8F%91/Error)

Expand Down Expand Up @@ -123,6 +124,7 @@ Authorization: token kSLuTF2GC2Q4q4ugm3
| 字段名 | 数据类型 | 默认值 | 说明 |
| --------- | ------ | ---- | ------- |
| `user_id` | number | - | 对方 QQ 号 |
| `times` | number | 1 | 赞的次数,每个好友每天最多 10 次 |

#### 响应数据

Expand Down Expand Up @@ -325,6 +327,18 @@ Authorization: token kSLuTF2GC2Q4q4ugm3
| `title_expire_time` | number | 专属头衔过期时间戳 |
| `card_changeable` | bool | 是否允许修改群名片(不确定) |

### `/get_group_member_list` 获取群成员列表

#### 参数

| 字段名 | 数据类型 | 默认值 | 说明 |
| ----- | ------- | ----- | --- |
| `group_id` | number | - | 群号 |

#### 响应数据

相应内容为 JSON 数组,每个元素的内容和上面的 `/get_group_member_info` 接口相同。

### `/get_stranger_info` 获取陌生人信息

#### 参数
Expand Down
9 changes: 5 additions & 4 deletions io.github.richardchien.coolqhttpapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"ret": 1, // 返回码,固定为1
"apiver": 9, // Api版本,本SDK为9
"name": "HTTP API", // 应用名称
"version": "1.1.2", // 应用版本
"version_id": 12, // 应用顺序版本(每次发布时至少+1)
"version": "1.1.3", // 应用版本
"version_id": 13, // 应用顺序版本(每次发布时至少+1)
"author": "Richard Chien", // 应用作者
"description": "使酷 Q 支持通过 HTTP 上报事件信息及调用接口",
"event": [// 事件列表,同一事件类型可重复定义(发布前请删除无用事件)
Expand Down Expand Up @@ -111,7 +111,7 @@
101, //发送群消息 sendGroupMsg
103, //发送讨论组消息 sendDiscussMsg
106, //发送私聊消息 sendPrivateMsg
110, //发送赞 sendLike
110, //发送赞 sendLikeV2 / sendLike
120, //置群员移除 setGroupKick
121, //置群员禁言 setGroupBan
122, //置群管理员 setGroupAdmin
Expand All @@ -125,6 +125,7 @@
131, //取陌生人信息 getStrangerInfo
140, //置讨论组退出 setDiscussLeave
150, //置好友添加请求 setFriendAddRequest
151 //置群添加请求 setGroupAddRequest
151, //置群添加请求 setGroupAddRequest
160 //取群成员列表 getGroupMemberList
]
}
Binary file modified lib/CQP.lib
Binary file not shown.
110 changes: 68 additions & 42 deletions lib/include/cqp.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
* CoolQ SDK for VC++
* Api Version 9.6
* Written by Coxxs & Thanks for the help of orzFly
*
* Modified by Richard Chien
*/

#pragma once

#define CQAPIVER 9
Expand All @@ -14,73 +17,96 @@

#define CQEVENT(ReturnType, Name, Size) __pragma(comment(linker, "/EXPORT:" #Name "=_" #Name "@" #Size)) extern "C" __declspec(dllexport) ReturnType __stdcall Name

typedef int32_t CQBOOL;
typedef int32_t cq_bool_t;

#define EVENT_IGNORE 0 //事件_忽略
#define EVENT_BLOCK 1 //事件_拦截
#define EVENT_IGNORE 0
#define EVENT_BLOCK 1

#define REQUEST_ALLOW 1 //请求_通过
#define REQUEST_DENY 2 //请求_拒绝
#define REQUEST_ALLOW 1
#define REQUEST_DENY 2

#define REQUEST_GROUPADD 1 //请求_群添加
#define REQUEST_GROUPINVITE 2 //请求_群邀请
#define REQUEST_GROUPADD 1
#define REQUEST_GROUPINVITE 2

#define CQLOG_DEBUG 0 //调试 灰色
#define CQLOG_INFO 10 //信息 黑色
#define CQLOG_INFOSUCCESS 11 //信息(成功) 紫色
#define CQLOG_INFORECV 12 //信息(接收) 蓝色
#define CQLOG_INFOSEND 13 //信息(发送) 绿色
#define CQLOG_WARNING 20 //警告 橙色
#define CQLOG_ERROR 30 //错误 红色
#define CQLOG_FATAL 40 //致命错误 深红
#define CQLOG_DEBUG 0
#define CQLOG_INFO 10
#define CQLOG_INFOSUCCESS 11
#define CQLOG_INFORECV 12
#define CQLOG_INFOSEND 13
#define CQLOG_WARNING 20
#define CQLOG_ERROR 30
#define CQLOG_FATAL 40

// Send Message
CQAPI(int32_t)
CQ_sendPrivateMsg(int32_t auth_code, int64_t qq, const char *msg);
CQAPI(int32_t)
CQ_sendPrivateMsg(int32_t AuthCode, int64_t QQID, const char *msg);
CQ_sendGroupMsg(int32_t auth_code, int64_t group_id, const char *msg);
CQAPI(int32_t)
CQ_sendDiscussMsg(int32_t auth_code, int64_t discuss_id, const char *msg);

// Send Like
CQAPI(int32_t)
CQ_sendGroupMsg(int32_t AuthCode, int64_t groupid, const char *msg);
CQ_sendLike(int32_t auth_code, int64_t qq);
CQAPI(int32_t)
CQ_sendDiscussMsg(int32_t AuthCode, int64_t discussid, const char *msg);
CQ_sendLikeV2(int32_t auth_code, int64_t qq, int32_t times);

// Group & Discuss Operation
CQAPI(int32_t)
CQ_sendLike(int32_t AuthCode, int64_t QQID);
CQ_setGroupKick(int32_t auth_code, int64_t group_id, int64_t qq, cq_bool_t reject_add_request);
CQAPI(int32_t)
CQ_setGroupKick(int32_t AuthCode, int64_t groupid, int64_t QQID, CQBOOL rejectaddrequest);
CQ_setGroupBan(int32_t auth_code, int64_t group_id, int64_t qq, int64_t duration);
CQAPI(int32_t)
CQ_setGroupBan(int32_t AuthCode, int64_t groupid, int64_t QQID, int64_t duration);
CQ_setGroupAnonymousBan(int32_t auth_code, int64_t group_id, const char *anonymous, int64_t duration);
CQAPI(int32_t)
CQ_setGroupAnonymousBan(int32_t AuthCode, int64_t groupid, const char *anonymous, int64_t duration);
CQ_setGroupWholeBan(int32_t auth_code, int64_t group_id, cq_bool_t enable);
CQAPI(int32_t)
CQ_setGroupWholeBan(int32_t AuthCode, int64_t groupid, CQBOOL enableban);
CQ_setGroupAdmin(int32_t auth_code, int64_t group_id, int64_t qq, cq_bool_t set);
CQAPI(int32_t)
CQ_setGroupAdmin(int32_t AuthCode, int64_t groupid, int64_t QQID, CQBOOL setadmin);
CQ_setGroupAnonymous(int32_t auth_code, int64_t group_id, cq_bool_t enable);
CQAPI(int32_t)
CQ_setGroupAnonymous(int32_t AuthCode, int64_t groupid, CQBOOL enableanonymous);
CQ_setGroupCard(int32_t auth_code, int64_t group_id, int64_t qq, const char *new_card);
CQAPI(int32_t)
CQ_setGroupCard(int32_t AuthCode, int64_t groupid, int64_t QQID, const char *newcard);
CQ_setGroupLeave(int32_t auth_code, int64_t group_id, cq_bool_t is_dismiss);
CQAPI(int32_t)
CQ_setGroupLeave(int32_t AuthCode, int64_t groupid, CQBOOL isdismiss);
CQ_setGroupSpecialTitle(int32_t auth_code, int64_t group_id, int64_t qq, const char *new_special_title, int64_t duration);
CQAPI(int32_t)
CQ_setGroupSpecialTitle(int32_t AuthCode, int64_t groupid, int64_t QQID, const char *newspecialtitle, int64_t duration);
CQ_setDiscussLeave(int32_t auth_code, int64_t discuss_id);

// Request Operation
CQAPI(int32_t)
CQ_setDiscussLeave(int32_t AuthCode, int64_t discussid);
CQ_setFriendAddRequest(int32_t auth_code, const char *response_flag, int32_t response_operation, const char *remark);
CQAPI(int32_t)
CQ_setFriendAddRequest(int32_t AuthCode, const char *responseflag, int32_t responseoperation, const char *remark);
CQ_setGroupAddRequest(int32_t auth_code, const char *response_flag, int32_t request_type, int32_t response_operation);
CQAPI(int32_t)
CQ_setGroupAddRequestV2(int32_t AuthCode, const char *responseflag, int32_t requesttype, int32_t responseoperation, const char *reason);
CQ_setGroupAddRequestV2(int32_t auth_code, const char *response_flag, int32_t request_type, int32_t response_operation, const char *reason);

// Get QQ Information
CQAPI(int64_t)
CQ_getLoginQQ(int32_t auth_code);
CQAPI(const char *)
CQ_getGroupMemberInfoV2(int32_t AuthCode, int64_t groupid, int64_t QQID, CQBOOL nocache);
CQ_getLoginNick(int32_t auth_code);
CQAPI(const char *)
CQ_getStrangerInfo(int32_t AuthCode, int64_t QQID, CQBOOL nocache);
CQAPI(int32_t)
CQ_addLog(int32_t AuthCode, int32_t priority, const char *category, const char *content);
CQ_getStrangerInfo(int32_t auth_code, int64_t qq, cq_bool_t no_cache);
CQAPI(const char *)
CQ_getGroupMemberList(int32_t auth_code, int64_t group_id);
CQAPI(const char *)
CQ_getGroupMemberInfoV2(int32_t auth_code, int64_t group_id, int64_t qq, cq_bool_t no_cache);

// Get CoolQ Information
CQAPI(const char *)
CQ_getCookies(int32_t AuthCode);
CQ_getCookies(int32_t auth_code);
CQAPI(int32_t)
CQ_getCsrfToken(int32_t AuthCode);
CQAPI(int64_t)
CQ_getLoginQQ(int32_t AuthCode);
CQ_getCsrfToken(int32_t auth_code);
CQAPI(const char *)
CQ_getLoginNick(int32_t AuthCode);
CQ_getAppDirectory(int32_t auth_code);
CQAPI(const char *)
CQ_getAppDirectory(int32_t AuthCode);
CQ_getRecord(int32_t auth_code, const char *file, const char *out_format);

// CoolQ Self-operation
CQAPI(int32_t)
CQ_addLog(int32_t auth_code, int32_t log_level, const char *category, const char *log_msg);
CQAPI(int32_t)
CQ_setFatal(int32_t auth_code, const char *error_info);
CQAPI(int32_t)
CQ_setFatal(int32_t AuthCode, const char *errorinfo);
CQ_setRestart(int32_t auth_code); // currently banned by CQ
2 changes: 1 addition & 1 deletion src/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
#define CQAPPID "io.github.richardchien.coolqhttpapi"
#define CQAPPINFO CQAPIVERTEXT "," CQAPPID
#define CQAPPNAME "CoolQ HTTP API Plugin"
#define CQAPPVER "v1.1.2"
#define CQAPPVER "v1.1.3"
#define CQAPPFULLNAME CQAPPNAME " " CQAPPVER
3 changes: 2 additions & 1 deletion src/request.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ enum cqhttp_retcode
{
CQHTTP_RETCODE_OK = 0,
CQHTTP_RETCODE_ERROR_DEFAULT = 100,
CQHTTP_RETCODE_NO_SUCH_API = 101 // will be converted to 404 Not Found http error
CQHTTP_RETCODE_NO_SUCH_API = 101, // will be converted to 404 Not Found http error
CQHTTP_RETCODE_INVALID_DATA = 102 // the data that CoolQ returns is invalid
};

struct cqhttp_result
Expand Down
Loading

0 comments on commit 009bbb8

Please sign in to comment.