diff --git a/package.json b/package.json index c160c10..625241b 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,6 @@ "dependencies": { "@koishijs/plugin-adapter-dingtalk": "^2.2.1", "@koishijs/plugin-adapter-discord": "^4.2.2", - "@koishijs/plugin-adapter-onebot": "^6.0.2", "@koishijs/plugin-adapter-satori": "^1.0.8", "@koishijs/plugin-admin": "^1.4.0", "@koishijs/plugin-analytics": "^2.0.6", @@ -50,6 +49,7 @@ "fexios": "^1.5.0", "json5": "^2.2.3", "koishi": "^4.16.8", + "koishi-plugin-adapter-onebot": "^6.5.0", "koishi-plugin-adapter-red": "^2.9.7", "koishi-plugin-adapter-villa": "^0.7.0", "koishi-plugin-assets-s3": "^1.2.5", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 58dd771..39927c7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,9 +11,6 @@ dependencies: '@koishijs/plugin-adapter-discord': specifier: ^4.2.2 version: 4.2.2(@satorijs/satori@3.5.3)(koishi@4.16.8) - '@koishijs/plugin-adapter-onebot': - specifier: ^6.0.2 - version: 6.0.2(@satorijs/satori@3.5.3)(koishi@4.16.8) '@koishijs/plugin-adapter-satori': specifier: ^1.0.8 version: 1.0.8(@satorijs/satori@3.5.3)(koishi@4.16.8) @@ -80,6 +77,9 @@ dependencies: koishi: specifier: ^4.16.8 version: 4.16.8 + koishi-plugin-adapter-onebot: + specifier: ^6.5.0 + version: 6.5.0(koishi@4.16.8) koishi-plugin-adapter-red: specifier: ^2.9.7 version: 2.9.7(koishi@4.16.8) @@ -1303,17 +1303,6 @@ packages: - '@satorijs/satori' dev: false - /@koishijs/plugin-adapter-onebot@6.0.2(@satorijs/satori@3.5.3)(koishi@4.16.8): - resolution: {integrity: sha512-YOvPux+Tdo1xTMrSa5umWn1Yxx0LoFUi4FcTS30KS7DF4FQTBzDMQvo18On6g+nkv996yh+seHfrAk2Jv30r3Q==} - peerDependencies: - koishi: ^4.14.6 - dependencies: - '@satorijs/adapter-onebot': 6.0.2(@satorijs/satori@3.5.3) - koishi: 4.16.8 - transitivePeerDependencies: - - '@satorijs/satori' - dev: false - /@koishijs/plugin-adapter-satori@1.0.8(@satorijs/satori@3.5.3)(koishi@4.16.8): resolution: {integrity: sha512-weKNQEWuW6oqNL4ZBEsoglv/0McWDPMVG9QjAgZv/wNnzZLG02svTvOKSYzcl/oYy6ybfwTycWQAKnAozXLYLw==} peerDependencies: @@ -1787,15 +1776,6 @@ packages: form-data: 4.0.0 dev: false - /@satorijs/adapter-onebot@6.0.2(@satorijs/satori@3.5.3): - resolution: {integrity: sha512-rECvmghlzkyhu6o+Sy3NVDQ59az3M0DxxYzngmEhTiyoia81fP71xGNURBw+Z6ALBNpUEsh4IKHg1Gq38jq5mQ==} - peerDependencies: - '@satorijs/satori': ^3.0.0-rc.0 - dependencies: - '@satorijs/satori': 3.5.3 - qface: 1.4.1 - dev: false - /@satorijs/adapter-satori@1.0.8(@satorijs/satori@3.5.3): resolution: {integrity: sha512-GyA0vUAv3MdVdLGwQH6bqhSzeTx1lT9/KQm/2M89/d4ju6y5zaGmYbLQrOEKtVj1MWlQRcRe//5nfjSKfQb/xQ==} peerDependencies: @@ -3949,6 +3929,15 @@ packages: - supports-color dev: false + /koishi-plugin-adapter-onebot@6.5.0(koishi@4.16.8): + resolution: {integrity: sha512-8Mk6oCsd78tcFZTErGJ0Eqboj5AnJjW8B0SEyZb7bKUJFg5s6nZ24OvJc+h2yj3WYE6uSNCVQnBzeQCSo+CHlg==} + peerDependencies: + koishi: ^4.17.1 + dependencies: + koishi: 4.16.8 + qface: 1.4.1 + dev: false + /koishi-plugin-adapter-red@2.9.7(koishi@4.16.8): resolution: {integrity: sha512-0HV+xfyWUypuUl5J7zyMY2qk17vO0HIPlcLoctWGTmvvirgZ6vIvxkl09il8G0oTMlxRVJ06KOSJOXFB46sXbw==} peerDependencies: diff --git a/src/index.ts b/src/index.ts index 451461b..b8f6656 100644 --- a/src/index.ts +++ b/src/index.ts @@ -47,8 +47,6 @@ import PluginYoudao from '~/youdao' import AdapterDingtalk from '@koishijs/plugin-adapter-dingtalk' import AdapterDiscord from '@koishijs/plugin-adapter-discord' -// import AdapterOnebot from '@koishijs/plugin-adapter-onebot' -// import AdapterSatori from '@koishijs/plugin-adapter-satori' import * as PluginAdmin from '@koishijs/plugin-admin' import PluginAnalytics from '@koishijs/plugin-analytics' import PluginAuth from '@koishijs/plugin-auth' @@ -68,6 +66,7 @@ import * as PluginSandbox from '@koishijs/plugin-sandbox' import PluginServer from '@koishijs/plugin-server' import * as PluginStatus from '@koishijs/plugin-status' +import AdapterOnebot from 'koishi-plugin-adapter-onebot' import AdapterRed from 'koishi-plugin-adapter-red' import AdapterVilla from 'koishi-plugin-adapter-villa' import PluginAssetsS3 from 'koishi-plugin-assets-s3' @@ -126,18 +125,18 @@ app.plugin(PluginMongo, { /** 安装适配器 */ app.plugin(function PluginCollectionAdapters(ctx) { // QQ - // ctx.plugin(AdapterOnebot, { - // protocol: env.ONEBOT_PROTOCOL, - // selfId: env.ONEBOT_SELFID, - // endpoint: env.ONEBOT_ENDPOINT, - // }) - ctx.plugin(AdapterRed, { - endpoint: env.CHRONOCAT_RED_ENDPOINT, - token: env.CHRONOCAT_TOKEN, + ctx.plugin(AdapterOnebot, { + protocol: env.ONEBOT_PROTOCOL, selfId: env.ONEBOT_SELFID?.trim(), - path: '/assets/red', - selfUrl: env.KOISHI_SELF_URL, + endpoint: env.ONEBOT_ENDPOINT, }) + // ctx.plugin(AdapterRed, { + // endpoint: env.CHRONOCAT_RED_ENDPOINT, + // token: env.CHRONOCAT_TOKEN, + // selfId: env.ONEBOT_SELFID?.trim(), + // path: '/assets/red', + // selfUrl: env.KOISHI_SELF_URL, + // }) // ctx.plugin(AdapterSatori, { // endpoint: env.CHRONOCAT_SATORI_ENDPOINT, // token: env.CHRONOCAT_TOKEN, diff --git a/src/plugins/dice.ts b/src/plugins/dice.ts index f0e0a0e..b9607ec 100644 --- a/src/plugins/dice.ts +++ b/src/plugins/dice.ts @@ -242,8 +242,12 @@ export default class PluginDice extends BasePlugin { const total = results.reduce((a, b) => a + b.final, 0) const lines: string[] = [] - // 特殊情况:硬币 - if (length === 1 && results[0].dice.points === 2) { + // 特殊情况:硬币(有且仅有一个 1d2) + if ( + length === 1 && + results[0].dice.counts === 1 && + results[0].dice.points === 2 + ) { const coinResultText = results[0].final === CoinSide.FRONT ? this.MSG.coinFront diff --git a/src/plugins/mute.ts b/src/plugins/mute.ts index fc83ac6..7bfeb8d 100644 --- a/src/plugins/mute.ts +++ b/src/plugins/mute.ts @@ -12,7 +12,7 @@ export default class PluginMute extends BasePlugin { constructor(public ctx: Context) { super(ctx, {}, 'mute') - ctx = ctx.platform('red').channel() + ctx = ctx.platform('red', 'onebot').channel() ctx .command('channel.mute', '', { authority: 3 }) .option('set-user', '-u ') diff --git a/src/plugins/openai/index.tsx b/src/plugins/openai/index.tsx index 27929b8..4b0bcb1 100644 --- a/src/plugins/openai/index.tsx +++ b/src/plugins/openai/index.tsx @@ -479,7 +479,7 @@ export default class PluginOpenAi extends BasePlugin { } addRecord(session: Session) { - const content = session.content + const content = session.elements?.join('') || '' if (content.includes('[chat-summary]')) { return } diff --git a/start.ps1 b/start.ps1 index cad67eb..76f6280 100644 --- a/start.ps1 +++ b/start.ps1 @@ -7,6 +7,11 @@ param( $env:KOISHI_ROOT_DIR = $PSScriptRoot +# 将代码页配置为 UTF-8 +$OutputEncoding = [System.Text.UTF8Encoding]::new() +[Console]::InputEncoding = $OutputEncoding +[Console]::OutputEncoding = $OutputEncoding + # 主循环 function Main() { $env:KOISHI_FIRST_START_TIME = GetNowInISO8601 @@ -92,7 +97,6 @@ function ResetLog() { Remove-Item $CMDLOG_FILE -ErrorAction SilentlyContinue } function RunAndLog($command) { - $time = Get-Date -Format "yyyy-MM-dd HH:mm:ss" WriteLogLine "> $command" $result = Invoke-Expression -Command $command $result = AddIndentation $result 2 @@ -100,7 +104,7 @@ function RunAndLog($command) { $result | Out-File -FilePath $CMDLOG_FILE -Append } function WriteLogLine($line) { - $time = Get-Date -Format "yyyy-MM-dd HH:mm:ss" + $time = GetNowInISO8601 $line = "[$time] $line" Write-Host $line $line | Out-File -FilePath $CMDLOG_FILE -Append