mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
Compare commits
13 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
ba413b9581 | ||
![]() |
abcec99ce0 | ||
![]() |
a7da7ab598 | ||
![]() |
5cc8a2b96e | ||
![]() |
f0d8c851d4 | ||
![]() |
828b20e0e8 | ||
![]() |
3570349fcd | ||
![]() |
ad74854e42 | ||
![]() |
15e7afed62 | ||
![]() |
bf71328650 | ||
![]() |
b3299ba1e3 | ||
![]() |
d36ea93e63 | ||
![]() |
0bd3f8f1a2 |
@@ -4,7 +4,7 @@
|
|||||||
"name": "LLOneBot",
|
"name": "LLOneBot",
|
||||||
"slug": "LLOneBot",
|
"slug": "LLOneBot",
|
||||||
"description": "实现 OneBot 11 协议,用于 QQ 机器人开发",
|
"description": "实现 OneBot 11 协议,用于 QQ 机器人开发",
|
||||||
"version": "3.31.3",
|
"version": "3.31.5",
|
||||||
"icon": "./icon.webp",
|
"icon": "./icon.webp",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
|
@@ -19,7 +19,7 @@ declare module 'cordis' {
|
|||||||
export class NTQQGroupApi extends Service {
|
export class NTQQGroupApi extends Service {
|
||||||
static inject = ['ntWindowApi']
|
static inject = ['ntWindowApi']
|
||||||
|
|
||||||
private groupMembers: Map<string, Map<string, GroupMember>> = new Map<string, Map<string, GroupMember>>()
|
public groupMembers: Map<string, Map<string, GroupMember>> = new Map<string, Map<string, GroupMember>>()
|
||||||
|
|
||||||
constructor(protected ctx: Context) {
|
constructor(protected ctx: Context) {
|
||||||
super(ctx, 'ntGroupApi', true)
|
super(ctx, 'ntGroupApi', true)
|
||||||
@@ -246,7 +246,7 @@ export class NTQQGroupApi extends Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async getGroupAtAllRemainCount(groupCode: string) {
|
async getGroupRemainAtTimes(groupCode: string) {
|
||||||
return await invoke<
|
return await invoke<
|
||||||
GeneralCallResult & {
|
GeneralCallResult & {
|
||||||
atInfo: {
|
atInfo: {
|
||||||
|
@@ -153,12 +153,7 @@ export class NTQQMsgApi extends Service {
|
|||||||
)
|
)
|
||||||
msgList = data.msgList
|
msgList = data.msgList
|
||||||
}
|
}
|
||||||
const retMsg = msgList.find(msgRecord => {
|
return msgList.find(msgRecord => msgRecord.guildId === msgId)
|
||||||
if (msgRecord.guildId === msgId) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return retMsg!
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async forwardMsg(srcPeer: Peer, destPeer: Peer, msgIds: string[]) {
|
async forwardMsg(srcPeer: Peer, destPeer: Peer, msgIds: string[]) {
|
||||||
|
@@ -3,7 +3,7 @@ import { User, UserDetailInfoByUin, UserDetailInfoByUinV2, UserDetailInfoListene
|
|||||||
import { getBuildVersion } from '@/common/utils'
|
import { getBuildVersion } from '@/common/utils'
|
||||||
import { getSession } from '@/ntqqapi/wrapper'
|
import { getSession } from '@/ntqqapi/wrapper'
|
||||||
import { RequestUtil } from '@/common/utils/request'
|
import { RequestUtil } from '@/common/utils/request'
|
||||||
import { NodeIKernelProfileService, UserDetailSource, ProfileBizType, forceFetchClientKeyRetType } from '../services'
|
import { NodeIKernelProfileService, UserDetailSource, ProfileBizType } from '../services'
|
||||||
import { NodeIKernelProfileListener } from '../listeners'
|
import { NodeIKernelProfileListener } from '../listeners'
|
||||||
import { NTEventDispatch } from '@/common/utils/eventTask'
|
import { NTEventDispatch } from '@/common/utils/eventTask'
|
||||||
import { Time } from 'cosmokit'
|
import { Time } from 'cosmokit'
|
||||||
@@ -17,7 +17,7 @@ declare module 'cordis' {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class NTQQUserApi extends Service {
|
export class NTQQUserApi extends Service {
|
||||||
static inject = ['ntFriendApi']
|
static inject = ['ntFriendApi', 'ntGroupApi']
|
||||||
|
|
||||||
constructor(protected ctx: Context) {
|
constructor(protected ctx: Context) {
|
||||||
super(ctx, 'ntUserApi', true)
|
super(ctx, 'ntUserApi', true)
|
||||||
@@ -187,16 +187,31 @@ export class NTQQUserApi extends Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async getUidByUinV1(Uin: string) {
|
async getUidByUinV1(uin: string) {
|
||||||
const session = getSession()
|
const session = getSession()
|
||||||
// 通用转换开始尝试
|
// 通用转换开始尝试
|
||||||
let uid = (await session?.getUixConvertService().getUid([Uin]))?.uidInfo.get(Uin)
|
let uid = (await session?.getUixConvertService().getUid([uin]))?.uidInfo.get(uin)
|
||||||
if (!uid) {
|
if (!uid) {
|
||||||
let unveifyUid = (await this.getUserDetailInfoByUin(Uin)).info.uid //从QQ Native 特殊转换 方法三
|
for (const membersList of this.ctx.ntGroupApi.groupMembers.values()) { //从群友列表转
|
||||||
if (unveifyUid.indexOf('*') == -1) {
|
for (const member of membersList.values()) {
|
||||||
|
if (member.uin === uin) {
|
||||||
|
uid = member.uid
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (uid) break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!uid) {
|
||||||
|
const unveifyUid = (await this.getUserDetailInfoByUin(uin)).info.uid //特殊转换
|
||||||
|
if (unveifyUid.indexOf('*') === -1) {
|
||||||
uid = unveifyUid
|
uid = unveifyUid
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!uid) {
|
||||||
|
const friends = await this.ctx.ntFriendApi.getFriends() //从好友列表转
|
||||||
|
uid = friends.find(item => item.uin === uin)?.uid
|
||||||
|
}
|
||||||
return uid
|
return uid
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,11 +236,11 @@ export class NTQQUserApi extends Service {
|
|||||||
if (unveifyUid.indexOf('*') == -1) return unveifyUid
|
if (unveifyUid.indexOf('*') == -1) return unveifyUid
|
||||||
}
|
}
|
||||||
|
|
||||||
async getUidByUin(Uin: string) {
|
async getUidByUin(uin: string) {
|
||||||
if (getBuildVersion() >= 26702) {
|
if (getBuildVersion() >= 26702) {
|
||||||
return await this.getUidByUinV2(Uin)
|
return this.getUidByUinV2(uin)
|
||||||
}
|
}
|
||||||
return await this.getUidByUinV1(Uin)
|
return this.getUidByUinV1(uin)
|
||||||
}
|
}
|
||||||
|
|
||||||
async getUserDetailInfoByUinV2(uin: string) {
|
async getUserDetailInfoByUinV2(uin: string) {
|
||||||
@@ -247,25 +262,25 @@ export class NTQQUserApi extends Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async getUserDetailInfoByUin(Uin: string) {
|
async getUserDetailInfoByUin(uin: string) {
|
||||||
return NTEventDispatch.CallNoListenerEvent
|
return NTEventDispatch.CallNoListenerEvent
|
||||||
<(Uin: string) => Promise<UserDetailInfoByUin>>(
|
<(Uin: string) => Promise<UserDetailInfoByUin>>(
|
||||||
'NodeIKernelProfileService/getUserDetailInfoByUin',
|
'NodeIKernelProfileService/getUserDetailInfoByUin',
|
||||||
5000,
|
5000,
|
||||||
Uin
|
uin
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
async getUinByUidV1(Uid: string) {
|
async getUinByUidV1(uid: string) {
|
||||||
const ret = await NTEventDispatch.CallNoListenerEvent
|
const ret = await NTEventDispatch.CallNoListenerEvent
|
||||||
<(Uin: string[]) => Promise<{ uinInfo: Map<string, string> }>>(
|
<(Uin: string[]) => Promise<{ uinInfo: Map<string, string> }>>(
|
||||||
'NodeIKernelUixConvertService/getUin',
|
'NodeIKernelUixConvertService/getUin',
|
||||||
5000,
|
5000,
|
||||||
[Uid]
|
[uid]
|
||||||
)
|
)
|
||||||
let uin = ret.uinInfo.get(Uid)
|
let uin = ret.uinInfo.get(uid)
|
||||||
if (!uin) {
|
if (!uin) {
|
||||||
uin = (await this.getUserDetailInfo(Uid)).uin //从QQ Native 转换
|
uin = (await this.getUserDetailInfo(uid)).uin //从QQ Native 转换
|
||||||
}
|
}
|
||||||
return uin
|
return uin
|
||||||
}
|
}
|
||||||
@@ -293,11 +308,11 @@ export class NTQQUserApi extends Service {
|
|||||||
return uin
|
return uin
|
||||||
}
|
}
|
||||||
|
|
||||||
async getUinByUid(Uid: string) {
|
async getUinByUid(uid: string) {
|
||||||
if (getBuildVersion() >= 26702) {
|
if (getBuildVersion() >= 26702) {
|
||||||
return (await this.getUinByUidV2(Uid))!
|
return this.getUinByUidV2(uid)
|
||||||
}
|
}
|
||||||
return await this.getUinByUidV1(Uid)
|
return this.getUinByUidV1(uid)
|
||||||
}
|
}
|
||||||
|
|
||||||
async forceFetchClientKey() {
|
async forceFetchClientKey() {
|
||||||
|
@@ -7,7 +7,7 @@ interface Payload {
|
|||||||
parent_id?: '/'
|
parent_id?: '/'
|
||||||
}
|
}
|
||||||
|
|
||||||
export class GoCQHTTPCreateGroupFileFolder extends BaseAction<Payload, null> {
|
export class CreateGroupFileFolder extends BaseAction<Payload, null> {
|
||||||
actionName = ActionName.GoCQHTTP_CreateGroupFileFolder
|
actionName = ActionName.GoCQHTTP_CreateGroupFileFolder
|
||||||
|
|
||||||
async _handle(payload: Payload) {
|
async _handle(payload: Payload) {
|
||||||
|
@@ -6,7 +6,7 @@ interface Payload {
|
|||||||
message_id: number | string
|
message_id: number | string
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class GoCQHTTPDelEssenceMsg extends BaseAction<Payload, any> {
|
export class DelEssenceMsg extends BaseAction<Payload, any> {
|
||||||
actionName = ActionName.GoCQHTTP_DelEssenceMsg;
|
actionName = ActionName.GoCQHTTP_DelEssenceMsg;
|
||||||
|
|
||||||
protected async _handle(payload: Payload): Promise<any> {
|
protected async _handle(payload: Payload): Promise<any> {
|
||||||
|
@@ -7,7 +7,7 @@ interface Payload {
|
|||||||
busid?: 102
|
busid?: 102
|
||||||
}
|
}
|
||||||
|
|
||||||
export class GoCQHTTPDelGroupFile extends BaseAction<Payload, null> {
|
export class DelGroupFile extends BaseAction<Payload, null> {
|
||||||
actionName = ActionName.GoCQHTTP_DelGroupFile
|
actionName = ActionName.GoCQHTTP_DelGroupFile
|
||||||
|
|
||||||
async _handle(payload: Payload) {
|
async _handle(payload: Payload) {
|
||||||
|
@@ -6,7 +6,7 @@ interface Payload {
|
|||||||
folder_id: string
|
folder_id: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export class GoCQHTTPDelGroupFolder extends BaseAction<Payload, null> {
|
export class DelGroupFolder extends BaseAction<Payload, null> {
|
||||||
actionName = ActionName.GoCQHTTP_DelGroupFolder
|
actionName = ActionName.GoCQHTTP_DelGroupFolder
|
||||||
|
|
||||||
async _handle(payload: Payload) {
|
async _handle(payload: Payload) {
|
||||||
|
@@ -19,7 +19,7 @@ interface FileResponse {
|
|||||||
file: string
|
file: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class GoCQHTTPDownloadFile extends BaseAction<Payload, FileResponse> {
|
export class DownloadFile extends BaseAction<Payload, FileResponse> {
|
||||||
actionName = ActionName.GoCQHTTP_DownloadFile
|
actionName = ActionName.GoCQHTTP_DownloadFile
|
||||||
|
|
||||||
protected async _handle(payload: Payload): Promise<FileResponse> {
|
protected async _handle(payload: Payload): Promise<FileResponse> {
|
||||||
|
@@ -13,7 +13,7 @@ interface Response {
|
|||||||
messages: (OB11Message & { content: OB11MessageData })[]
|
messages: (OB11Message & { content: OB11MessageData })[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export class GoCQHTTGetForwardMsgAction extends BaseAction<Payload, Response> {
|
export class GetForwardMsg extends BaseAction<Payload, Response> {
|
||||||
actionName = ActionName.GoCQHTTP_GetForwardMsg
|
actionName = ActionName.GoCQHTTP_GetForwardMsg
|
||||||
protected async _handle(payload: Payload): Promise<any> {
|
protected async _handle(payload: Payload): Promise<any> {
|
||||||
const msgId = payload.id || payload.message_id
|
const msgId = payload.id || payload.message_id
|
||||||
|
25
src/onebot11/action/go-cqhttp/GetGroupAtAllRemain.ts
Normal file
25
src/onebot11/action/go-cqhttp/GetGroupAtAllRemain.ts
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import BaseAction from '../BaseAction'
|
||||||
|
import { ActionName } from '../types'
|
||||||
|
|
||||||
|
interface Payload {
|
||||||
|
group_id: number | string
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Response {
|
||||||
|
can_at_all: boolean
|
||||||
|
remain_at_all_count_for_group: number
|
||||||
|
remain_at_all_count_for_uin: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export class GetGroupAtAllRemain extends BaseAction<Payload, Response> {
|
||||||
|
actionName = ActionName.GoCQHTTP_GetGroupAtAllRemain
|
||||||
|
|
||||||
|
async _handle(payload: Payload) {
|
||||||
|
const data = await this.ctx.ntGroupApi.getGroupRemainAtTimes(payload.group_id.toString())
|
||||||
|
return {
|
||||||
|
can_at_all: data.atInfo.canAtAll,
|
||||||
|
remain_at_all_count_for_group: data.atInfo.RemainAtAllCountForGroup,
|
||||||
|
remain_at_all_count_for_uin: data.atInfo.RemainAtAllCountForUin
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -17,7 +17,7 @@ interface Response {
|
|||||||
messages: OB11Message[]
|
messages: OB11Message[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class GoCQHTTPGetGroupMsgHistory extends BaseAction<Payload, Response> {
|
export class GetGroupMsgHistory extends BaseAction<Payload, Response> {
|
||||||
actionName = ActionName.GoCQHTTP_GetGroupMsgHistory
|
actionName = ActionName.GoCQHTTP_GetGroupMsgHistory
|
||||||
|
|
||||||
protected async _handle(payload: Payload): Promise<Response> {
|
protected async _handle(payload: Payload): Promise<Response> {
|
||||||
|
@@ -24,7 +24,7 @@ interface Response {
|
|||||||
}[]
|
}[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export class GoCQHTTPGetGroupSystemMsg extends BaseAction<void, Response> {
|
export class GetGroupSystemMsg extends BaseAction<void, Response> {
|
||||||
actionName = ActionName.GoCQHTTP_GetGroupSystemMsg
|
actionName = ActionName.GoCQHTTP_GetGroupSystemMsg
|
||||||
|
|
||||||
async _handle(payload: void) {
|
async _handle(payload: void) {
|
||||||
|
@@ -10,7 +10,7 @@ interface Payload {
|
|||||||
user_id: number | string
|
user_id: number | string
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class GoCQHTTPGetStrangerInfo extends BaseAction<Payload, OB11User> {
|
export class GetStrangerInfo extends BaseAction<Payload, OB11User> {
|
||||||
actionName = ActionName.GoCQHTTP_GetStrangerInfo
|
actionName = ActionName.GoCQHTTP_GetStrangerInfo
|
||||||
|
|
||||||
protected async _handle(payload: Payload): Promise<OB11User> {
|
protected async _handle(payload: Payload): Promise<OB11User> {
|
||||||
|
@@ -5,7 +5,7 @@ interface Payload {
|
|||||||
message_id: number
|
message_id: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class GoCQHTTPMarkMsgAsRead extends BaseAction<Payload, null> {
|
export class MarkMsgAsRead extends BaseAction<Payload, null> {
|
||||||
actionName = ActionName.GoCQHTTP_MarkMsgAsRead
|
actionName = ActionName.GoCQHTTP_MarkMsgAsRead
|
||||||
|
|
||||||
protected async _handle(payload: Payload): Promise<null> {
|
protected async _handle(payload: Payload): Promise<null> {
|
@@ -7,7 +7,7 @@ interface Payload {
|
|||||||
operation: QuickOperation
|
operation: QuickOperation
|
||||||
}
|
}
|
||||||
|
|
||||||
export class GoCQHTTHandleQuickOperation extends BaseAction<Payload, null> {
|
export class HandleQuickOperation extends BaseAction<Payload, null> {
|
||||||
actionName = ActionName.GoCQHTTP_HandleQuickOperation
|
actionName = ActionName.GoCQHTTP_HandleQuickOperation
|
||||||
protected async _handle(payload: Payload): Promise<null> {
|
protected async _handle(payload: Payload): Promise<null> {
|
||||||
handleQuickOperation(this.ctx, payload.context, payload.operation).catch(e => this.ctx.logger.error(e))
|
handleQuickOperation(this.ctx, payload.context, payload.operation).catch(e => this.ctx.logger.error(e))
|
||||||
|
@@ -3,7 +3,7 @@ import { OB11PostSendMsg } from '../../types'
|
|||||||
import { ActionName } from '../types'
|
import { ActionName } from '../types'
|
||||||
import { convertMessage2List } from '../../helper/createMessage'
|
import { convertMessage2List } from '../../helper/createMessage'
|
||||||
|
|
||||||
export class GoCQHTTPSendForwardMsg extends SendMsg {
|
export class SendForwardMsg extends SendMsg {
|
||||||
actionName = ActionName.GoCQHTTP_SendForwardMsg
|
actionName = ActionName.GoCQHTTP_SendForwardMsg
|
||||||
|
|
||||||
protected async check(payload: OB11PostSendMsg) {
|
protected async check(payload: OB11PostSendMsg) {
|
||||||
@@ -12,10 +12,10 @@ export class GoCQHTTPSendForwardMsg extends SendMsg {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class GoCQHTTPSendPrivateForwardMsg extends GoCQHTTPSendForwardMsg {
|
export class SendPrivateForwardMsg extends SendForwardMsg {
|
||||||
actionName = ActionName.GoCQHTTP_SendPrivateForwardMsg
|
actionName = ActionName.GoCQHTTP_SendPrivateForwardMsg
|
||||||
}
|
}
|
||||||
|
|
||||||
export class GoCQHTTPSendGroupForwardMsg extends GoCQHTTPSendForwardMsg {
|
export class SendGroupForwardMsg extends SendForwardMsg {
|
||||||
actionName = ActionName.GoCQHTTP_SendGroupForwardMsg
|
actionName = ActionName.GoCQHTTP_SendGroupForwardMsg
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,7 @@ interface Payload {
|
|||||||
message_id: number | string
|
message_id: number | string
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class GoCQHTTPSetEssenceMsg extends BaseAction<Payload, any> {
|
export class SetEssenceMsg extends BaseAction<Payload, any> {
|
||||||
actionName = ActionName.GoCQHTTP_SetEssenceMsg;
|
actionName = ActionName.GoCQHTTP_SetEssenceMsg;
|
||||||
|
|
||||||
protected async _handle(payload: Payload): Promise<any> {
|
protected async _handle(payload: Payload): Promise<any> {
|
||||||
|
@@ -16,7 +16,7 @@ interface Payload {
|
|||||||
folder_id?: string
|
folder_id?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export class GoCQHTTPUploadGroupFile extends BaseAction<Payload, null> {
|
export class UploadGroupFile extends BaseAction<Payload, null> {
|
||||||
actionName = ActionName.GoCQHTTP_UploadGroupFile
|
actionName = ActionName.GoCQHTTP_UploadGroupFile
|
||||||
|
|
||||||
protected async _handle(payload: Payload): Promise<null> {
|
protected async _handle(payload: Payload): Promise<null> {
|
||||||
@@ -37,7 +37,7 @@ export class GoCQHTTPUploadGroupFile extends BaseAction<Payload, null> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class GoCQHTTPUploadPrivateFile extends BaseAction<Payload, null> {
|
export class UploadPrivateFile extends BaseAction<Payload, null> {
|
||||||
actionName = ActionName.GoCQHTTP_UploadPrivateFile
|
actionName = ActionName.GoCQHTTP_UploadPrivateFile
|
||||||
|
|
||||||
async getPeer(payload: Payload): Promise<Peer> {
|
async getPeer(payload: Payload): Promise<Peer> {
|
||||||
|
@@ -16,11 +16,11 @@ import CanSendRecord from './system/CanSendRecord'
|
|||||||
import CanSendImage from './system/CanSendImage'
|
import CanSendImage from './system/CanSendImage'
|
||||||
import GetStatus from './system/GetStatus'
|
import GetStatus from './system/GetStatus'
|
||||||
import {
|
import {
|
||||||
GoCQHTTPSendForwardMsg,
|
SendForwardMsg,
|
||||||
GoCQHTTPSendGroupForwardMsg,
|
SendGroupForwardMsg,
|
||||||
GoCQHTTPSendPrivateForwardMsg,
|
SendPrivateForwardMsg,
|
||||||
} from './go-cqhttp/SendForwardMsg'
|
} from './go-cqhttp/SendForwardMsg'
|
||||||
import GoCQHTTPGetStrangerInfo from './go-cqhttp/GetStrangerInfo'
|
import { GetStrangerInfo } from './go-cqhttp/GetStrangerInfo'
|
||||||
import SendLike from './user/SendLike'
|
import SendLike from './user/SendLike'
|
||||||
import SetGroupAddRequest from './group/SetGroupAddRequest'
|
import SetGroupAddRequest from './group/SetGroupAddRequest'
|
||||||
import SetGroupLeave from './group/SetGroupLeave'
|
import SetGroupLeave from './group/SetGroupLeave'
|
||||||
@@ -35,29 +35,30 @@ import SetGroupAdmin from './group/SetGroupAdmin'
|
|||||||
import SetGroupCard from './group/SetGroupCard'
|
import SetGroupCard from './group/SetGroupCard'
|
||||||
import GetImage from './file/GetImage'
|
import GetImage from './file/GetImage'
|
||||||
import GetRecord from './file/GetRecord'
|
import GetRecord from './file/GetRecord'
|
||||||
import GoCQHTTPMarkMsgAsRead from './msg/MarkMsgAsRead'
|
import { MarkMsgAsRead } from './go-cqhttp/MarkMsgAsRead'
|
||||||
import CleanCache from './system/CleanCache'
|
import CleanCache from './system/CleanCache'
|
||||||
import { GoCQHTTPUploadGroupFile, GoCQHTTPUploadPrivateFile } from './go-cqhttp/UploadFile'
|
import { UploadGroupFile, UploadPrivateFile } from './go-cqhttp/UploadFile'
|
||||||
import { GetConfigAction, SetConfigAction } from './llonebot/Config'
|
import { GetConfigAction, SetConfigAction } from './llonebot/Config'
|
||||||
import GetGroupAddRequest from './llonebot/GetGroupAddRequest'
|
import GetGroupAddRequest from './llonebot/GetGroupAddRequest'
|
||||||
import SetQQAvatar from './llonebot/SetQQAvatar'
|
import SetQQAvatar from './llonebot/SetQQAvatar'
|
||||||
import GoCQHTTPDownloadFile from './go-cqhttp/DownloadFile'
|
import { DownloadFile } from './go-cqhttp/DownloadFile'
|
||||||
import GoCQHTTPGetGroupMsgHistory from './go-cqhttp/GetGroupMsgHistory'
|
import { GetGroupMsgHistory } from './go-cqhttp/GetGroupMsgHistory'
|
||||||
import GetFile from './file/GetFile'
|
import GetFile from './file/GetFile'
|
||||||
import { GoCQHTTGetForwardMsgAction } from './go-cqhttp/GetForwardMsg'
|
import { GetForwardMsg } from './go-cqhttp/GetForwardMsg'
|
||||||
import { GetCookies } from './user/GetCookie'
|
import { GetCookies } from './user/GetCookie'
|
||||||
import { SetMsgEmojiLike } from './msg/SetMsgEmojiLike'
|
import { SetMsgEmojiLike } from './msg/SetMsgEmojiLike'
|
||||||
import { ForwardFriendSingleMsg, ForwardGroupSingleMsg } from './msg/ForwardSingleMsg'
|
import { ForwardFriendSingleMsg, ForwardGroupSingleMsg } from './msg/ForwardSingleMsg'
|
||||||
import { GetGroupEssence } from './group/GetGroupEssence'
|
import { GetGroupEssence } from './group/GetGroupEssence'
|
||||||
import { GetGroupHonorInfo } from './group/GetGroupHonorInfo'
|
import { GetGroupHonorInfo } from './group/GetGroupHonorInfo'
|
||||||
import { GoCQHTTHandleQuickOperation } from './go-cqhttp/QuickOperation'
|
import { HandleQuickOperation } from './go-cqhttp/QuickOperation'
|
||||||
import GoCQHTTPSetEssenceMsg from './go-cqhttp/SetEssenceMsg'
|
import { SetEssenceMsg } from './go-cqhttp/SetEssenceMsg'
|
||||||
import GoCQHTTPDelEssenceMsg from './go-cqhttp/DelEssenceMsg'
|
import { DelEssenceMsg } from './go-cqhttp/DelEssenceMsg'
|
||||||
import GetEvent from './llonebot/GetEvent'
|
import GetEvent from './llonebot/GetEvent'
|
||||||
import { GoCQHTTPDelGroupFile } from './go-cqhttp/DelGroupFile'
|
import { DelGroupFile } from './go-cqhttp/DelGroupFile'
|
||||||
import { GoCQHTTPGetGroupSystemMsg } from './go-cqhttp/GetGroupSystemMsg'
|
import { GetGroupSystemMsg } from './go-cqhttp/GetGroupSystemMsg'
|
||||||
import { GoCQHTTPCreateGroupFileFolder } from './go-cqhttp/CreateGroupFileFolder'
|
import { CreateGroupFileFolder } from './go-cqhttp/CreateGroupFileFolder'
|
||||||
import { GoCQHTTPDelGroupFolder } from './go-cqhttp/DelGroupFolder'
|
import { DelGroupFolder } from './go-cqhttp/DelGroupFolder'
|
||||||
|
import { GetGroupAtAllRemain } from './go-cqhttp/GetGroupAtAllRemain'
|
||||||
|
|
||||||
export function initActionMap(adapter: Adapter) {
|
export function initActionMap(adapter: Adapter) {
|
||||||
const actionHandlers = [
|
const actionHandlers = [
|
||||||
@@ -105,24 +106,25 @@ export function initActionMap(adapter: Adapter) {
|
|||||||
//以下为go-cqhttp api
|
//以下为go-cqhttp api
|
||||||
new GetGroupEssence(adapter),
|
new GetGroupEssence(adapter),
|
||||||
new GetGroupHonorInfo(adapter),
|
new GetGroupHonorInfo(adapter),
|
||||||
new GoCQHTTPSendForwardMsg(adapter),
|
new SendForwardMsg(adapter),
|
||||||
new GoCQHTTPSendGroupForwardMsg(adapter),
|
new SendGroupForwardMsg(adapter),
|
||||||
new GoCQHTTPSendPrivateForwardMsg(adapter),
|
new SendPrivateForwardMsg(adapter),
|
||||||
new GoCQHTTPGetStrangerInfo(adapter),
|
new GetStrangerInfo(adapter),
|
||||||
new GoCQHTTPDownloadFile(adapter),
|
new DownloadFile(adapter),
|
||||||
new GetGuildList(adapter),
|
new GetGuildList(adapter),
|
||||||
new GoCQHTTPMarkMsgAsRead(adapter),
|
new MarkMsgAsRead(adapter),
|
||||||
new GoCQHTTPUploadGroupFile(adapter),
|
new UploadGroupFile(adapter),
|
||||||
new GoCQHTTPUploadPrivateFile(adapter),
|
new UploadPrivateFile(adapter),
|
||||||
new GoCQHTTPGetGroupMsgHistory(adapter),
|
new GetGroupMsgHistory(adapter),
|
||||||
new GoCQHTTGetForwardMsgAction(adapter),
|
new GetForwardMsg(adapter),
|
||||||
new GoCQHTTHandleQuickOperation(adapter),
|
new HandleQuickOperation(adapter),
|
||||||
new GoCQHTTPSetEssenceMsg(adapter),
|
new SetEssenceMsg(adapter),
|
||||||
new GoCQHTTPDelEssenceMsg(adapter),
|
new DelEssenceMsg(adapter),
|
||||||
new GoCQHTTPDelGroupFile(adapter),
|
new DelGroupFile(adapter),
|
||||||
new GoCQHTTPGetGroupSystemMsg(adapter),
|
new GetGroupSystemMsg(adapter),
|
||||||
new GoCQHTTPCreateGroupFileFolder(adapter),
|
new CreateGroupFileFolder(adapter),
|
||||||
new GoCQHTTPDelGroupFolder(adapter)
|
new DelGroupFolder(adapter),
|
||||||
|
new GetGroupAtAllRemain(adapter)
|
||||||
]
|
]
|
||||||
const actionMap = new Map<string, BaseAction<any, any>>()
|
const actionMap = new Map<string, BaseAction<any, any>>()
|
||||||
for (const action of actionHandlers) {
|
for (const action of actionHandlers) {
|
||||||
|
@@ -11,13 +11,17 @@ class DeleteMsg extends BaseAction<Payload, void> {
|
|||||||
|
|
||||||
protected async _handle(payload: Payload) {
|
protected async _handle(payload: Payload) {
|
||||||
if (!payload.message_id) {
|
if (!payload.message_id) {
|
||||||
throw Error('message_id不能为空')
|
throw new Error('参数message_id不能为空')
|
||||||
}
|
}
|
||||||
const msg = await MessageUnique.getMsgIdAndPeerByShortId(+payload.message_id)
|
const msg = await MessageUnique.getMsgIdAndPeerByShortId(+payload.message_id)
|
||||||
if (!msg) {
|
if (!msg) {
|
||||||
throw `消息${payload.message_id}不存在`
|
throw new Error(`消息${payload.message_id}不存在`)
|
||||||
|
}
|
||||||
|
const data = await this.ctx.ntMsgApi.recallMsg(msg.Peer, [msg.MsgId])
|
||||||
|
if (data.result !== 0) {
|
||||||
|
this.ctx.logger.error('delete_msg', payload.message_id, data)
|
||||||
|
throw new Error(`消息撤回失败`)
|
||||||
}
|
}
|
||||||
await this.ctx.ntMsgApi.recallMsg(msg.Peer, [msg.MsgId])
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -48,16 +48,16 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((contextMode === ContextMode.Private || contextMode === ContextMode.Normal) && payload.user_id) {
|
if ((contextMode === ContextMode.Private || contextMode === ContextMode.Normal) && payload.user_id) {
|
||||||
const Uid = await this.ctx.ntUserApi.getUidByUin(payload.user_id.toString())
|
const uid = await this.ctx.ntUserApi.getUidByUin(payload.user_id.toString())
|
||||||
const isBuddy = await this.ctx.ntFriendApi.isBuddy(Uid!)
|
if (!uid) throw new Error('无法获取用户信息')
|
||||||
//console.log("[调试代码] UIN:", payload.user_id, " UID:", Uid, " IsBuddy:", isBuddy)
|
const isBuddy = await this.ctx.ntFriendApi.isBuddy(uid)
|
||||||
return {
|
return {
|
||||||
chatType: isBuddy ? ChatType.friend : ChatType.temp,
|
chatType: isBuddy ? ChatType.friend : ChatType.temp,
|
||||||
peerUid: Uid!,
|
peerUid: uid,
|
||||||
guildId: payload.group_id?.toString() || '' //临时主动发起时需要传入群号
|
guildId: isBuddy ? '' : payload.group_id?.toString() || ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw '请指定 group_id 或 user_id'
|
throw new Error('请指定 group_id 或 user_id')
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async check(payload: OB11PostSendMsg): Promise<BaseCheckResult> {
|
protected async check(payload: OB11PostSendMsg): Promise<BaseCheckResult> {
|
||||||
@@ -160,6 +160,9 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const returnMsg = await sendMsg(this.ctx, peer, sendElements, deleteAfterSentFiles)
|
const returnMsg = await sendMsg(this.ctx, peer, sendElements, deleteAfterSentFiles)
|
||||||
|
if (!returnMsg) {
|
||||||
|
throw new Error('消息发送失败')
|
||||||
|
}
|
||||||
return { message_id: returnMsg.msgShortId! }
|
return { message_id: returnMsg.msgShortId! }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,9 +254,12 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
|
|||||||
// log("分割后的转发节点", sendElementsSplit)
|
// log("分割后的转发节点", sendElementsSplit)
|
||||||
for (const eles of sendElementsSplit) {
|
for (const eles of sendElementsSplit) {
|
||||||
const nodeMsg = await sendMsg(this.ctx, selfPeer, eles, [], true)
|
const nodeMsg = await sendMsg(this.ctx, selfPeer, eles, [], true)
|
||||||
|
if (!nodeMsg) {
|
||||||
|
this.ctx.logger.warn('转发节点生成失败', eles)
|
||||||
|
continue
|
||||||
|
}
|
||||||
nodeMsgIds.push(nodeMsg.msgId)
|
nodeMsgIds.push(nodeMsg.msgId)
|
||||||
await this.ctx.sleep(400)
|
await this.ctx.sleep(400)
|
||||||
this.ctx.logger.info('转发节点生成成功', nodeMsg.msgId)
|
|
||||||
}
|
}
|
||||||
deleteAfterSentFiles.map((f) => fs.unlink(f, () => {
|
deleteAfterSentFiles.map((f) => fs.unlink(f, () => {
|
||||||
}))
|
}))
|
||||||
|
@@ -76,5 +76,6 @@ export enum ActionName {
|
|||||||
GoCQHTTP_DelGroupFile = 'delete_group_file',
|
GoCQHTTP_DelGroupFile = 'delete_group_file',
|
||||||
GoCQHTTP_GetGroupSystemMsg = 'get_group_system_msg',
|
GoCQHTTP_GetGroupSystemMsg = 'get_group_system_msg',
|
||||||
GoCQHTTP_CreateGroupFileFolder = 'create_group_file_folder',
|
GoCQHTTP_CreateGroupFileFolder = 'create_group_file_folder',
|
||||||
GoCQHTTP_DelGroupFolder = 'delete_group_folder'
|
GoCQHTTP_DelGroupFolder = 'delete_group_folder',
|
||||||
|
GoCQHTTP_GetGroupAtAllRemain = 'get_group_at_all_remain'
|
||||||
}
|
}
|
||||||
|
@@ -54,7 +54,7 @@ export async function createSendElements(
|
|||||||
let isAdmin: boolean = true
|
let isAdmin: boolean = true
|
||||||
if (groupCode) {
|
if (groupCode) {
|
||||||
try {
|
try {
|
||||||
remainAtAllCount = (await ctx.ntGroupApi.getGroupAtAllRemainCount(groupCode)).atInfo
|
remainAtAllCount = (await ctx.ntGroupApi.getGroupRemainAtTimes(groupCode)).atInfo
|
||||||
.RemainAtAllCountForUin
|
.RemainAtAllCountForUin
|
||||||
ctx.logger.info(`群${groupCode}剩余at全体次数`, remainAtAllCount)
|
ctx.logger.info(`群${groupCode}剩余at全体次数`, remainAtAllCount)
|
||||||
const self = await ctx.ntGroupApi.getGroupMember(groupCode, selfInfo.uin)
|
const self = await ctx.ntGroupApi.getGroupMember(groupCode, selfInfo.uin)
|
||||||
@@ -270,8 +270,10 @@ export async function sendMsg(
|
|||||||
const timeout = 10000 + (totalSize / 1024 / 256 * 1000) // 10s Basic Timeout + PredictTime( For File 512kb/s )
|
const timeout = 10000 + (totalSize / 1024 / 256 * 1000) // 10s Basic Timeout + PredictTime( For File 512kb/s )
|
||||||
//log('设置消息超时时间', timeout)
|
//log('设置消息超时时间', timeout)
|
||||||
const returnMsg = await ctx.ntMsgApi.sendMsg(peer, sendElements, waitComplete, timeout)
|
const returnMsg = await ctx.ntMsgApi.sendMsg(peer, sendElements, waitComplete, timeout)
|
||||||
|
if (returnMsg) {
|
||||||
returnMsg.msgShortId = MessageUnique.createMsg(peer, returnMsg.msgId)
|
returnMsg.msgShortId = MessageUnique.createMsg(peer, returnMsg.msgId)
|
||||||
ctx.logger.info('消息发送', returnMsg.msgShortId)
|
ctx.logger.info('消息发送', returnMsg.msgShortId)
|
||||||
deleteAfterSentFiles.map(path => fsPromise.unlink(path))
|
deleteAfterSentFiles.map(path => fsPromise.unlink(path))
|
||||||
return returnMsg
|
return returnMsg
|
||||||
}
|
}
|
||||||
|
}
|
@@ -1 +1 @@
|
|||||||
export const version = '3.31.3'
|
export const version = '3.31.5'
|
||||||
|
Reference in New Issue
Block a user