Commit b177cbbf authored by nanahira's avatar nanahira

add confirmation

parent f9704ef7
...@@ -12,7 +12,8 @@ ...@@ -12,7 +12,8 @@
"source-map-support": "^0.5.20" "source-map-support": "^0.5.20"
}, },
"devDependencies": { "devDependencies": {
"@koishijs/plugin-adapter-onebot": "^4.0.0-beta.3", "@koishijs/plugin-adapter-onebot": "^4.0.0-beta.4",
"@koishijs/plugin-onebot": "^4.0.0-alpha.8",
"@types/node": "^16.10.3", "@types/node": "^16.10.3",
"@typescript-eslint/eslint-plugin": "^4.33.0", "@typescript-eslint/eslint-plugin": "^4.33.0",
"@typescript-eslint/parser": "^4.33.0", "@typescript-eslint/parser": "^4.33.0",
...@@ -30,7 +31,7 @@ ...@@ -30,7 +31,7 @@
}, },
"peerDependencies": { "peerDependencies": {
"@koishijs/plugin-adapter-onebot": "^4.0.0-beta.3", "@koishijs/plugin-adapter-onebot": "^4.0.0-beta.3",
"koishi": "^4.0.0-beta.4" "koishi": "^4.0.0-beta.5"
} }
}, },
"node_modules/@babel/code-frame": { "node_modules/@babel/code-frame": {
...@@ -225,16 +226,29 @@ ...@@ -225,16 +226,29 @@
} }
}, },
"node_modules/@koishijs/plugin-adapter-onebot": { "node_modules/@koishijs/plugin-adapter-onebot": {
"version": "4.0.0-beta.3", "version": "4.0.0-beta.4",
"resolved": "https://registry.npmjs.org/@koishijs/plugin-adapter-onebot/-/plugin-adapter-onebot-4.0.0-beta.3.tgz", "resolved": "https://registry.npmjs.org/@koishijs/plugin-adapter-onebot/-/plugin-adapter-onebot-4.0.0-beta.4.tgz",
"integrity": "sha512-6UWO5qBRHk95UxSfHmPkuwQuAWeLL6T9YnIMlvg9d1EzTQHJWv66FkK4EdJ7Yfs0DoLdFodZ67eLCP707oeYNA==", "integrity": "sha512-LOxkQ49CdmIqX040bTF7nyHernZXzhVrRyvQtmxZKeNeIFRWvaIg2IJb+9F7oVW/Q0a2GL69hs22rQdkJoSj3w==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"qface": "^1.2.0", "qface": "^1.2.0",
"ws": "^8.2.1" "ws": "^8.2.1"
}, },
"peerDependencies": { "peerDependencies": {
"koishi": "^4.0.0-beta.3" "koishi": "^4.0.0-beta.5"
}
},
"node_modules/@koishijs/plugin-onebot": {
"version": "4.0.0-alpha.8",
"resolved": "https://registry.npmjs.org/@koishijs/plugin-onebot/-/plugin-onebot-4.0.0-alpha.8.tgz",
"integrity": "sha512-FTVzfbwu2k9pzLtAO5Qu5jME+Lgig3iEkpvcKvd39F2ShgPoD7c33wQInAFcBku19gDG2QM9wSq/Na1eLlFCzA==",
"dev": true,
"dependencies": {
"qface": "^1.2.0",
"ws": "^8.2.1"
},
"peerDependencies": {
"koishi": "^4.0.0-alpha.9"
} }
}, },
"node_modules/@koishijs/utils": { "node_modules/@koishijs/utils": {
...@@ -4503,9 +4517,19 @@ ...@@ -4503,9 +4517,19 @@
} }
}, },
"@koishijs/plugin-adapter-onebot": { "@koishijs/plugin-adapter-onebot": {
"version": "4.0.0-beta.3", "version": "4.0.0-beta.4",
"resolved": "https://registry.npmjs.org/@koishijs/plugin-adapter-onebot/-/plugin-adapter-onebot-4.0.0-beta.3.tgz", "resolved": "https://registry.npmjs.org/@koishijs/plugin-adapter-onebot/-/plugin-adapter-onebot-4.0.0-beta.4.tgz",
"integrity": "sha512-6UWO5qBRHk95UxSfHmPkuwQuAWeLL6T9YnIMlvg9d1EzTQHJWv66FkK4EdJ7Yfs0DoLdFodZ67eLCP707oeYNA==", "integrity": "sha512-LOxkQ49CdmIqX040bTF7nyHernZXzhVrRyvQtmxZKeNeIFRWvaIg2IJb+9F7oVW/Q0a2GL69hs22rQdkJoSj3w==",
"dev": true,
"requires": {
"qface": "^1.2.0",
"ws": "^8.2.1"
}
},
"@koishijs/plugin-onebot": {
"version": "4.0.0-alpha.8",
"resolved": "https://registry.npmjs.org/@koishijs/plugin-onebot/-/plugin-onebot-4.0.0-alpha.8.tgz",
"integrity": "sha512-FTVzfbwu2k9pzLtAO5Qu5jME+Lgig3iEkpvcKvd39F2ShgPoD7c33wQInAFcBku19gDG2QM9wSq/Na1eLlFCzA==",
"dev": true, "dev": true,
"requires": { "requires": {
"qface": "^1.2.0", "qface": "^1.2.0",
......
...@@ -4,6 +4,7 @@ import type { OneBotBot } from '@koishijs/plugin-adapter-onebot/lib/bot'; ...@@ -4,6 +4,7 @@ import type { OneBotBot } from '@koishijs/plugin-adapter-onebot/lib/bot';
export interface PluginConfig { export interface PluginConfig {
commmandName?: string; commmandName?: string;
leaveMessage: string;
} }
export class MyPlugin { export class MyPlugin {
...@@ -14,6 +15,9 @@ export class MyPlugin { ...@@ -14,6 +15,9 @@ export class MyPlugin {
commmandName: Schema.string() commmandName: Schema.string()
.description('退群命令名称') .description('退群命令名称')
.default('dispose'), .default('dispose'),
leaveMessage: Schema.string()
.description('确认退群消息')
.default('确定要请我退群吗?输入 yes 以退群。'),
}); });
private async onQuit(session: Session) { private async onQuit(session: Session) {
this.ctx this.ctx
...@@ -33,6 +37,11 @@ export class MyPlugin { ...@@ -33,6 +37,11 @@ export class MyPlugin {
) { ) {
return; return;
} }
await session.send(this.config.leaveMessage);
const result = await session.prompt();
if (result !== 'yes') {
return;
}
try { try {
await bot.internal.setGroupLeave(session.guildId, false); await bot.internal.setGroupLeave(session.guildId, false);
} catch (e) { } catch (e) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment