Skip to content

Commit

Permalink
chore: migrate to onebot
Browse files Browse the repository at this point in the history
  • Loading branch information
dragon-fish committed Mar 5, 2024
1 parent cead2b4 commit 718cc8c
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 42 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
35 changes: 12 additions & 23 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 11 additions & 12 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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'
Expand Down Expand Up @@ -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,
Expand Down
8 changes: 6 additions & 2 deletions src/plugins/dice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/mute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', '<duration:number>', { authority: 3 })
.option('set-user', '-u <user:user>')
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/openai/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
8 changes: 6 additions & 2 deletions start.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -92,15 +97,14 @@ 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
Write-Host $result
$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
Expand Down

0 comments on commit 718cc8c

Please sign in to comment.