mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
feat: some go-cqhttp feature
This commit is contained in:
parent
ebea755731
commit
7664e746b4
12
README.md
12
README.md
@ -36,6 +36,7 @@ LiteLoaderQQNT的OneBot11协议插件
|
|||||||
- [x] 上报好友、群消息撤回
|
- [x] 上报好友、群消息撤回
|
||||||
|
|
||||||
消息格式支持:
|
消息格式支持:
|
||||||
|
- [x] cq码
|
||||||
- [x] 文字
|
- [x] 文字
|
||||||
- [x] 表情
|
- [x] 表情
|
||||||
- [x] 图片
|
- [x] 图片
|
||||||
@ -64,6 +65,10 @@ LiteLoaderQQNT的OneBot11协议插件
|
|||||||
- [x] can_send_image
|
- [x] can_send_image
|
||||||
- [x] can_send_record
|
- [x] can_send_record
|
||||||
|
|
||||||
|
支持的go-cqhtp api:
|
||||||
|
- [x] send_private_forward_msg
|
||||||
|
- [x] send_group_forward_msg
|
||||||
|
|
||||||
## 示例
|
## 示例
|
||||||
|
|
||||||

|

|
||||||
@ -91,13 +96,6 @@ LiteLoaderQQNT的OneBot11协议插件
|
|||||||
</details>
|
</details>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
<details>
|
|
||||||
<summary>不支持cq码</summary>
|
|
||||||
<br/>
|
|
||||||
cq码已经过时了,没有支持的打算(主要是我不用这玩意儿,加上我懒)
|
|
||||||
</details>
|
|
||||||
<br/>
|
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary>QQ变得很卡</summary>
|
<summary>QQ变得很卡</summary>
|
||||||
<br/>
|
<br/>
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
"name": "LLOneBot",
|
"name": "LLOneBot",
|
||||||
"slug": "LLOneBot",
|
"slug": "LLOneBot",
|
||||||
"description": "LiteLoaderQQNT的OneBotApi",
|
"description": "LiteLoaderQQNT的OneBotApi",
|
||||||
"version": "3.4.0",
|
"version": "3.5.0",
|
||||||
"thumbnail": "./icon.png",
|
"thumbnail": "./icon.png",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
|
@ -87,4 +87,4 @@ export function getUidByUin(uin: string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const version = "v3.4.0"
|
export const version = "v3.5.0"
|
||||||
|
@ -16,6 +16,7 @@ import {OB11FriendRecallNoticeEvent} from "../onebot11/event/notice/OB11FriendRe
|
|||||||
import {OB11GroupRecallNoticeEvent} from "../onebot11/event/notice/OB11GroupRecallNoticeEvent";
|
import {OB11GroupRecallNoticeEvent} from "../onebot11/event/notice/OB11GroupRecallNoticeEvent";
|
||||||
import {postEvent} from "../onebot11/server/postevent";
|
import {postEvent} from "../onebot11/server/postevent";
|
||||||
import {ob11ReverseWebsockets} from "../onebot11/server/ws/ReverseWebsocket";
|
import {ob11ReverseWebsockets} from "../onebot11/server/ws/ReverseWebsocket";
|
||||||
|
import {EventType} from "../onebot11/event/OB11BaseEvent";
|
||||||
|
|
||||||
|
|
||||||
let running = false;
|
let running = false;
|
||||||
@ -94,7 +95,8 @@ function onLoad() {
|
|||||||
if (debug) {
|
if (debug) {
|
||||||
msg.raw = message;
|
msg.raw = message;
|
||||||
}
|
}
|
||||||
if (msg.user_id.toString() == selfInfo.uin && !reportSelfMessage) {
|
const isSelfMsg = msg.user_id.toString() == selfInfo.uin
|
||||||
|
if (isSelfMsg && !reportSelfMessage) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
postEvent(msg);
|
postEvent(msg);
|
||||||
|
@ -150,7 +150,10 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
|
|||||||
let nodeId = messageNode.data.id;
|
let nodeId = messageNode.data.id;
|
||||||
// 有nodeId表示一个子转发消息卡片
|
// 有nodeId表示一个子转发消息卡片
|
||||||
if (nodeId) {
|
if (nodeId) {
|
||||||
nodeIds.push(nodeId)
|
let nodeMsg = getHistoryMsgByShortId(nodeId);
|
||||||
|
if (nodeMsg){
|
||||||
|
nodeIds.push(nodeMsg.msgId);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// 自定义的消息
|
// 自定义的消息
|
||||||
// 提取消息段,发给自己生成消息id
|
// 提取消息段,发给自己生成消息id
|
||||||
|
@ -11,6 +11,7 @@ import {AtType, ChatType, Group, GroupMember, IMAGE_HTTP_HOST, RawMessage, SelfI
|
|||||||
import {getFriend, getGroupMember, getHistoryMsgBySeq, selfInfo} from '../common/data';
|
import {getFriend, getGroupMember, getHistoryMsgBySeq, selfInfo} from '../common/data';
|
||||||
import {file2base64, getConfigUtil, log} from "../common/utils";
|
import {file2base64, getConfigUtil, log} from "../common/utils";
|
||||||
import {NTQQApi} from "../ntqqapi/ntcall";
|
import {NTQQApi} from "../ntqqapi/ntcall";
|
||||||
|
import {EventType} from "./event/OB11BaseEvent";
|
||||||
|
|
||||||
|
|
||||||
export class OB11Constructor {
|
export class OB11Constructor {
|
||||||
@ -34,10 +35,10 @@ export class OB11Constructor {
|
|||||||
font: 14,
|
font: 14,
|
||||||
sub_type: "friend",
|
sub_type: "friend",
|
||||||
message: [],
|
message: [],
|
||||||
post_type: "message",
|
post_type: selfInfo.uin == msg.senderUin ? EventType.MESSAGE_SENT : EventType.MESSAGE,
|
||||||
}
|
}
|
||||||
if (msg.chatType == ChatType.group) {
|
if (msg.chatType == ChatType.group) {
|
||||||
resMsg.sub_type = "normal"
|
resMsg.sub_type = "normal" // 这里go-cqhttp是group,而onebot11标准是normal, 蛋疼
|
||||||
resMsg.group_id = parseInt(msg.peerUin)
|
resMsg.group_id = parseInt(msg.peerUin)
|
||||||
const member = await getGroupMember(msg.peerUin, msg.senderUin);
|
const member = await getGroupMember(msg.peerUin, msg.senderUin);
|
||||||
if (member) {
|
if (member) {
|
||||||
@ -80,7 +81,14 @@ export class OB11Constructor {
|
|||||||
}
|
}
|
||||||
} else if (element.textElement) {
|
} else if (element.textElement) {
|
||||||
message_data["type"] = "text"
|
message_data["type"] = "text"
|
||||||
resMsg.raw_message += message_data["data"]["text"] = element.textElement.content
|
let text= element.textElement.content
|
||||||
|
if (!text.trim()){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
message_data["data"]["text"] = text
|
||||||
|
if (text){
|
||||||
|
resMsg.raw_message += text
|
||||||
|
}
|
||||||
} else if (element.picElement) {
|
} else if (element.picElement) {
|
||||||
message_data["type"] = "image"
|
message_data["type"] = "image"
|
||||||
message_data["data"]["file_id"] = element.picElement.fileUuid
|
message_data["data"]["file_id"] = element.picElement.fileUuid
|
||||||
@ -139,6 +147,7 @@ export class OB11Constructor {
|
|||||||
resMsg.message.push(message_data);
|
resMsg.message.push(message_data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
resMsg.raw_message = resMsg.raw_message.trim();
|
||||||
return resMsg;
|
return resMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,8 @@ export enum EventType {
|
|||||||
META = "meta_event",
|
META = "meta_event",
|
||||||
REQUEST = "request",
|
REQUEST = "request",
|
||||||
NOTICE = "notice",
|
NOTICE = "notice",
|
||||||
MESSAGE = "message"
|
MESSAGE = "message",
|
||||||
|
MESSAGE_SENT = "message_sent",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ export function wsReply(wsClient: websocket.WebSocket, data: OB11Response | Post
|
|||||||
delete packet["echo"];
|
delete packet["echo"];
|
||||||
}
|
}
|
||||||
wsClient.send(JSON.stringify(packet))
|
wsClient.send(JSON.stringify(packet))
|
||||||
log("ws 消息上报", wsClient.url, data)
|
log("ws 消息上报", wsClient.url || "", data)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log("websocket 回复失败", e)
|
log("websocket 回复失败", e)
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import {AtType, RawMessage} from "../ntqqapi/types";
|
import {AtType, RawMessage} from "../ntqqapi/types";
|
||||||
|
import {EventType} from "./event/OB11BaseEvent";
|
||||||
|
|
||||||
export interface OB11User {
|
export interface OB11User {
|
||||||
user_id: number;
|
user_id: number;
|
||||||
@ -67,7 +68,7 @@ export interface OB11Message {
|
|||||||
message: OB11MessageData[],
|
message: OB11MessageData[],
|
||||||
raw_message: string,
|
raw_message: string,
|
||||||
font: number,
|
font: number,
|
||||||
post_type?: "message",
|
post_type?: EventType,
|
||||||
raw?: RawMessage
|
raw?: RawMessage
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user