mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
@@ -4,7 +4,7 @@
|
||||
"name": "LLOneBot",
|
||||
"slug": "LLOneBot",
|
||||
"description": "实现 OneBot 11 协议,用于 QQ 机器人开发",
|
||||
"version": "3.31.7",
|
||||
"version": "3.31.8",
|
||||
"icon": "./icon.webp",
|
||||
"authors": [
|
||||
{
|
||||
|
@@ -3,7 +3,6 @@ import ffmpeg from 'fluent-ffmpeg'
|
||||
import fsPromise from 'node:fs/promises'
|
||||
import { decode, encode, getDuration, getWavFileInfo, isWav, isSilk, EncodeResult } from 'silk-wasm'
|
||||
import { TEMP_DIR } from '../globalVars'
|
||||
import { getConfigUtil } from '../config'
|
||||
import { randomUUID } from 'node:crypto'
|
||||
import { Readable } from 'node:stream'
|
||||
import { Context } from 'cordis'
|
||||
@@ -38,7 +37,7 @@ function convert(ctx: Context, input: Input, options: FFmpegOptions, outputPath?
|
||||
if (options.output) {
|
||||
command = command.outputOptions(options.output)
|
||||
}
|
||||
const ffmpegPath = getConfigUtil().getConfig().ffmpeg
|
||||
const ffmpegPath: string | undefined = ctx.config.ffmpeg
|
||||
if (ffmpegPath) {
|
||||
command = command.setFfmpegPath(ffmpegPath)
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
@@ -175,6 +175,9 @@ function onLoad() {
|
||||
debug: config.debug!,
|
||||
reportSelfMessage: config.reportSelfMessage!,
|
||||
msgCacheExpire: config.msgCacheExpire!,
|
||||
musicSignUrl: config.musicSignUrl,
|
||||
enableLocalFile2Url: config.enableLocalFile2Url!,
|
||||
ffmpeg: config.ffmpeg,
|
||||
})
|
||||
ctx.start()
|
||||
ipcMain.on(CHANNEL_SET_CONFIG_CONFIRMED, (event, config: LLOBConfig) => {
|
||||
|
@@ -52,6 +52,9 @@ class Core extends Service {
|
||||
MessageUnique.init(selfInfo.uin)
|
||||
this.registerListener()
|
||||
this.ctx.logger.info(`LLOneBot/${version}`)
|
||||
this.ctx.on('llonebot/config-updated', input => {
|
||||
Object.assign(this.config, input)
|
||||
})
|
||||
}
|
||||
|
||||
private registerListener() {
|
||||
|
@@ -147,7 +147,7 @@ export namespace SendElementEntities {
|
||||
filePath,
|
||||
}
|
||||
try {
|
||||
videoInfo = await getVideoInfo(path)
|
||||
videoInfo = await getVideoInfo(ctx, path)
|
||||
ctx.logger.info('视频信息', videoInfo)
|
||||
} catch (e) {
|
||||
ctx.logger.info('获取视频信息失败', e)
|
||||
|
@@ -1,6 +1,5 @@
|
||||
import BaseAction from '../BaseAction'
|
||||
import fsPromise from 'node:fs/promises'
|
||||
import { getConfigUtil } from '@/common/config'
|
||||
import { ActionName } from '../types'
|
||||
import { Peer, ElementType } from '@/ntqqapi/types'
|
||||
import { MessageUnique } from '@/common/utils/messageUnique'
|
||||
@@ -20,7 +19,7 @@ export interface GetFileResponse {
|
||||
export abstract class GetFileBase extends BaseAction<GetFilePayload, GetFileResponse> {
|
||||
// forked from https://github.com/NapNeko/NapCatQQ/blob/6f6b258f22d7563f15d84e7172c4d4cbb547f47e/src/onebot11/action/file/GetFile.ts#L44
|
||||
protected async _handle(payload: GetFilePayload): Promise<GetFileResponse> {
|
||||
const { enableLocalFile2Url } = getConfigUtil().getConfig()
|
||||
const { enableLocalFile2Url } = this.adapter.config
|
||||
|
||||
let fileCache = await MessageUnique.getFileCacheById(String(payload.file))
|
||||
if (!fileCache?.length) {
|
||||
|
@@ -1,7 +1,6 @@
|
||||
import { GetFileBase, GetFilePayload, GetFileResponse } from './GetFile'
|
||||
import { ActionName } from '../types'
|
||||
import { decodeSilk } from '@/common/utils/audio'
|
||||
import { getConfigUtil } from '@/common/config'
|
||||
import path from 'node:path'
|
||||
import fs from 'node:fs'
|
||||
|
||||
@@ -17,7 +16,7 @@ export default class GetRecord extends GetFileBase {
|
||||
res.file = await decodeSilk(this.ctx, res.file!, payload.out_format)
|
||||
res.file_name = path.basename(res.file)
|
||||
res.file_size = fs.statSync(res.file).size.toString()
|
||||
if (getConfigUtil().getConfig().enableLocalFile2Url) {
|
||||
if (this.adapter.config.enableLocalFile2Url) {
|
||||
res.base64 = fs.readFileSync(res.file, 'base64')
|
||||
}
|
||||
return res
|
||||
|
@@ -13,10 +13,9 @@ import {
|
||||
OB11MessageNode,
|
||||
OB11PostSendMsg,
|
||||
} from '../../types'
|
||||
import fs from 'node:fs'
|
||||
import BaseAction from '../BaseAction'
|
||||
import { ActionName, BaseCheckResult } from '../types'
|
||||
import fs from 'node:fs'
|
||||
import { getConfigUtil } from '@/common/config'
|
||||
import { CustomMusicSignPostData, IdMusicSignPostData, MusicSign, MusicSignPostData } from '@/common/utils/sign'
|
||||
import { Peer } from '@/ntqqapi/types/msg'
|
||||
import { MessageUnique } from '@/common/utils/messageUnique'
|
||||
@@ -76,7 +75,7 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnData> {
|
||||
else if (this.getSpecialMsgNum(messages, OB11MessageDataType.music)) {
|
||||
const music = messages[0] as OB11MessageMusic
|
||||
if (music) {
|
||||
const { musicSignUrl } = getConfigUtil().getConfig()
|
||||
const { musicSignUrl } = this.adapter.config
|
||||
if (!musicSignUrl) {
|
||||
throw '音乐签名地址未配置'
|
||||
}
|
||||
|
@@ -342,10 +342,13 @@ class OneBot11Adapter extends Service {
|
||||
Object.assign(this.config, {
|
||||
...config.ob11,
|
||||
heartInterval: config.heartInterval,
|
||||
token: config.token!,
|
||||
debug: config.debug!,
|
||||
reportSelfMessage: config.reportSelfMessage!,
|
||||
msgCacheExpire: config.msgCacheExpire!,
|
||||
token: config.token,
|
||||
debug: config.debug,
|
||||
reportSelfMessage: config.reportSelfMessage,
|
||||
msgCacheExpire: config.msgCacheExpire,
|
||||
musicSignUrl: config.musicSignUrl,
|
||||
enableLocalFile2Url: config.enableLocalFile2Url,
|
||||
ffmpeg: config.ffmpeg
|
||||
})
|
||||
}
|
||||
|
||||
@@ -417,6 +420,9 @@ namespace OneBot11Adapter {
|
||||
debug: boolean
|
||||
reportSelfMessage: boolean
|
||||
msgCacheExpire: number
|
||||
musicSignUrl?: string
|
||||
enableLocalFile2Url: boolean
|
||||
ffmpeg?: string
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import fastXmlParser from 'fast-xml-parser'
|
||||
import { XMLParser } from 'fast-xml-parser'
|
||||
import {
|
||||
OB11Group,
|
||||
OB11GroupMember,
|
||||
@@ -32,7 +32,6 @@ import { OB11GroupBanEvent } from './event/notice/OB11GroupBanEvent'
|
||||
import { OB11GroupUploadNoticeEvent } from './event/notice/OB11GroupUploadNoticeEvent'
|
||||
import { OB11GroupNoticeEvent } from './event/notice/OB11GroupNoticeEvent'
|
||||
import { calcQQLevel } from '../common/utils/misc'
|
||||
import { getConfigUtil } from '../common/config'
|
||||
import { OB11GroupTitleEvent } from './event/notice/OB11GroupTitleEvent'
|
||||
import { OB11GroupCardEvent } from './event/notice/OB11GroupCardEvent'
|
||||
import { OB11GroupDecreaseEvent } from './event/notice/OB11GroupDecreaseEvent'
|
||||
@@ -47,14 +46,14 @@ import { omit, isNullable, pick } from 'cosmokit'
|
||||
import { Context } from 'cordis'
|
||||
import { selfInfo } from '@/common/globalVars'
|
||||
import { pathToFileURL } from 'node:url'
|
||||
import OneBot11Adapter from './adapter'
|
||||
|
||||
export namespace OB11Entities {
|
||||
export async function message(ctx: Context, msg: RawMessage): Promise<OB11Message> {
|
||||
let config = getConfigUtil().getConfig()
|
||||
const {
|
||||
debug,
|
||||
ob11: { messagePostFormat },
|
||||
} = config
|
||||
messagePostFormat,
|
||||
} = ctx.config as OneBot11Adapter.Config
|
||||
const selfUin = selfInfo.uin
|
||||
const resMsg: OB11Message = {
|
||||
self_id: parseInt(selfUin),
|
||||
@@ -96,10 +95,10 @@ export namespace OB11Entities {
|
||||
resMsg.sub_type = 'group'
|
||||
const ret = await ctx.ntMsgApi.getTempChatInfo(ChatType2.KCHATTYPETEMPC2CFROMGROUP, msg.senderUid)
|
||||
if (ret?.result === 0) {
|
||||
resMsg.group_id = parseInt(ret.tmpChatInfo!.groupCode)
|
||||
resMsg.sender.nickname = ret.tmpChatInfo!.fromNick
|
||||
resMsg.temp_source = Number(ret.tmpChatInfo?.groupCode)
|
||||
resMsg.sender.nickname = ret.tmpChatInfo?.fromNick!
|
||||
} else {
|
||||
resMsg.group_id = 284840486 //兜底数据
|
||||
resMsg.temp_source = 284840486 //兜底数据
|
||||
resMsg.sender.nickname = '临时会话'
|
||||
}
|
||||
}
|
||||
@@ -515,7 +514,7 @@ export namespace OB11Entities {
|
||||
// <url jp= \"\" msgseq=\"74711\" col=\"3\" txt=\"消息:\"/>
|
||||
// <face type=\"1\" id=\"76\"> </face>
|
||||
// </gtip>",
|
||||
const emojiLikeData = new fastXmlParser.XMLParser({
|
||||
const emojiLikeData = new XMLParser({
|
||||
ignoreAttributes: false,
|
||||
attributeNamePrefix: '',
|
||||
}).parse(xmlElement.content)
|
||||
|
@@ -93,6 +93,7 @@ export interface OB11Message {
|
||||
font: number
|
||||
post_type?: EventType
|
||||
raw?: RawMessage
|
||||
temp_source?: number
|
||||
}
|
||||
|
||||
export interface OB11ForwardMessage extends OB11Message {
|
||||
|
@@ -1 +1 @@
|
||||
export const version = '3.31.7'
|
||||
export const version = '3.31.8'
|
||||
|
Reference in New Issue
Block a user