Skip to content

Commit

Permalink
fix(mock): add missing webhook api
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Jun 3, 2022
1 parent d86ec4d commit 7c8171e
Show file tree
Hide file tree
Showing 31 changed files with 31 additions and 39 deletions.
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,10 @@ tsconfig.temp.json
/community
/external
/addons
/public
/atri
/coverage
/legacy
/docs
/shiki
/test
/utsuho
/.yalc

todo.md
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,11 @@
"eslint-plugin-promise": "^5.2.0",
"fs-extra": "^10.1.0",
"globby": "^11.1.0",
"jest-mock": "^27.5.1",
"jest-mock": "^28.1.0",
"json5": "^2.2.1",
"kleur": "^4.1.4",
"latest-version": "^5.1.0",
"mocha": "^9.2.2",
"nock": "^13.2.4",
"open": "^8.4.0",
"ora": "^5.4.1",
"p-map": "^4.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
],
"devDependencies": {
"@koishijs/plugin-database-memory": "^1.3.0",
"@koishijs/plugin-mock": "^1.0.4",
"@koishijs/plugin-mock": "^1.0.6",
"chai": "^4.3.6",
"chai-as-promised": "^7.1.1",
"chai-shape": "^1.0.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/helpers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@
"koishi": "^4.7.2"
},
"devDependencies": {
"@koishijs/plugin-mock": "^1.0.5"
"@koishijs/plugin-mock": "^1.0.6"
}
}
2 changes: 1 addition & 1 deletion plugins/a11y/admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"koishi": "^4.7.2"
},
"devDependencies": {
"@koishijs/plugin-mock": "^1.0.5"
"@koishijs/plugin-mock": "^1.0.6"
},
"dependencies": {
"@koishijs/helpers": "^1.2.2"
Expand Down
2 changes: 1 addition & 1 deletion plugins/a11y/bind/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@
},
"devDependencies": {
"@koishijs/plugin-database-memory": "^1.3.1",
"@koishijs/plugin-mock": "^1.0.5"
"@koishijs/plugin-mock": "^1.0.6"
}
}
2 changes: 1 addition & 1 deletion plugins/a11y/callme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@
},
"devDependencies": {
"@koishijs/plugin-database-memory": "^1.3.1",
"@koishijs/plugin-mock": "^1.0.5"
"@koishijs/plugin-mock": "^1.0.6"
}
}
2 changes: 1 addition & 1 deletion plugins/a11y/commands/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"devDependencies": {
"@koishijs/client": "^3.3.3",
"@koishijs/plugin-console": "^3.3.3",
"@koishijs/plugin-mock": "^1.0.5",
"@koishijs/plugin-mock": "^1.0.6",
"@types/throttle-debounce": "^2.1.0"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion plugins/a11y/locales/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"devDependencies": {
"@koishijs/client": "^3.3.3",
"@koishijs/plugin-console": "^3.3.3",
"@koishijs/plugin-mock": "^1.0.5",
"@koishijs/plugin-mock": "^1.0.6",
"@types/throttle-debounce": "^2.1.0"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion plugins/a11y/rate-limit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"koishi": "^4.7.2"
},
"devDependencies": {
"@koishijs/plugin-mock": "^1.0.5"
"@koishijs/plugin-mock": "^1.0.6"
},
"dependencies": {
"@koishijs/helpers": "^1.2.2"
Expand Down
2 changes: 1 addition & 1 deletion plugins/a11y/schedule/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
},
"devDependencies": {
"@koishijs/plugin-database-memory": "^1.3.1",
"@koishijs/plugin-mock": "^1.0.5"
"@koishijs/plugin-mock": "^1.0.6"
},
"peerDependencies": {
"koishi": "^4.7.2"
Expand Down
2 changes: 1 addition & 1 deletion plugins/a11y/sudo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
},
"devDependencies": {
"@koishijs/plugin-database-memory": "^1.3.1",
"@koishijs/plugin-mock": "^1.0.5"
"@koishijs/plugin-mock": "^1.0.6"
},
"dependencies": {
"@koishijs/helpers": "^1.2.2"
Expand Down
2 changes: 1 addition & 1 deletion plugins/a11y/suggest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@
},
"devDependencies": {
"@koishijs/plugin-database-memory": "^1.3.1",
"@koishijs/plugin-mock": "^1.0.5"
"@koishijs/plugin-mock": "^1.0.6"
}
}
2 changes: 1 addition & 1 deletion plugins/a11y/switch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
},
"devDependencies": {
"@koishijs/plugin-database-memory": "^1.3.1",
"@koishijs/plugin-mock": "^1.0.5"
"@koishijs/plugin-mock": "^1.0.6"
},
"dependencies": {
"@koishijs/helpers": "^1.2.2"
Expand Down
2 changes: 1 addition & 1 deletion plugins/a11y/verifier/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@
"koishi": "^4.7.2"
},
"devDependencies": {
"@koishijs/plugin-mock": "^1.0.5"
"@koishijs/plugin-mock": "^1.0.6"
}
}
2 changes: 1 addition & 1 deletion plugins/adapter/discord/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"koishi": "^4.7.2"
},
"devDependencies": {
"@koishijs/plugin-mock": "^1.0.5",
"@koishijs/plugin-mock": "^1.0.6",
"@types/es-aggregate-error": "^1.0.2",
"@types/ws": "^8.5.3",
"axios": "^0.24.0"
Expand Down
2 changes: 1 addition & 1 deletion plugins/adapter/kaiheila/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"koishi": "^4.7.2"
},
"devDependencies": {
"@koishijs/plugin-mock": "^1.0.5"
"@koishijs/plugin-mock": "^1.0.6"
},
"dependencies": {
"axios": "^0.24.0",
Expand Down
4 changes: 2 additions & 2 deletions plugins/adapter/onebot/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@koishijs/plugin-adapter-onebot",
"description": "OneBot Adapter for Koishi",
"version": "4.2.6",
"version": "4.2.7",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
"files": [
Expand Down Expand Up @@ -43,7 +43,7 @@
"koishi": "^4.7.2"
},
"devDependencies": {
"@koishijs/plugin-mock": "^1.0.5",
"@koishijs/plugin-mock": "^1.0.6",
"@types/ws": "^8.5.3"
},
"dependencies": {
Expand Down
5 changes: 0 additions & 5 deletions plugins/adapter/onebot/src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,13 @@ export function renderText(source: string) {
export interface BotConfig extends Bot.BaseConfig, Quester.Config {
selfId?: string
token?: string
reportSelfMessage?: boolean
qqguildPlatform?: string
}

export const BotConfig: Schema<BotConfig> = Schema.intersect([
Schema.object({
selfId: Schema.string(),
token: Schema.string().role('secret'),
reportSelfMessage: Schema.boolean().default(false),
qqguildPlatform: Schema.string().default('qqguild'),
}),
Quester.Config,
Expand Down Expand Up @@ -237,9 +235,6 @@ export class QQGuildBot extends OneBotBot {
if (!session?.content) return []
session.messageId = '' + await this.internal.sendGuildChannelMsg(guildId, channelId, session.content)
this.app.emit(session, 'send', session)
if (!this.config.reportSelfMessage) {
this.app.emit(session, 'message', session)
}
return [session.messageId]
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/adapter/telegram/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
},
"devDependencies": {
"@types/es-aggregate-error": "^1.0.2",
"@koishijs/plugin-mock": "^1.0.5"
"@koishijs/plugin-mock": "^1.0.6"
},
"dependencies": {
"axios": "^0.24.0",
Expand Down
2 changes: 1 addition & 1 deletion plugins/common/broadcast/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@
},
"devDependencies": {
"@koishijs/plugin-database-memory": "^1.3.1",
"@koishijs/plugin-mock": "^1.0.5"
"@koishijs/plugin-mock": "^1.0.6"
}
}
2 changes: 1 addition & 1 deletion plugins/common/echo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"koishi": "^4.7.2"
},
"devDependencies": {
"@koishijs/plugin-mock": "^1.0.5"
"@koishijs/plugin-mock": "^1.0.6"
},
"dependencies": {
"@koishijs/helpers": "^1.2.2"
Expand Down
2 changes: 1 addition & 1 deletion plugins/common/feedback/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"koishi": "^4.7.2"
},
"devDependencies": {
"@koishijs/plugin-mock": "^1.0.5"
"@koishijs/plugin-mock": "^1.0.6"
},
"dependencies": {
"@koishijs/helpers": "^1.2.2"
Expand Down
2 changes: 1 addition & 1 deletion plugins/common/forward/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
},
"devDependencies": {
"@koishijs/plugin-database-memory": "^1.3.1",
"@koishijs/plugin-mock": "^1.0.5"
"@koishijs/plugin-mock": "^1.0.6"
},
"dependencies": {
"@koishijs/helpers": "^1.2.2"
Expand Down
2 changes: 1 addition & 1 deletion plugins/common/help/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
},
"devDependencies": {
"@koishijs/plugin-database-memory": "^1.3.1",
"@koishijs/plugin-mock": "^1.0.5",
"@koishijs/plugin-mock": "^1.0.6",
"@koishijs/plugin-suggest": "^1.1.0"
}
}
2 changes: 1 addition & 1 deletion plugins/common/recall/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@
"koishi": "^4.7.2"
},
"devDependencies": {
"@koishijs/plugin-mock": "^1.0.5"
"@koishijs/plugin-mock": "^1.0.6"
}
}
2 changes: 1 addition & 1 deletion plugins/common/repeater/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@
"koishi": "^4.7.2"
},
"devDependencies": {
"@koishijs/plugin-mock": "^1.0.5"
"@koishijs/plugin-mock": "^1.0.6"
}
}
2 changes: 1 addition & 1 deletion plugins/common/respondent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@
"koishi": "^4.7.2"
},
"devDependencies": {
"@koishijs/plugin-mock": "^1.0.5"
"@koishijs/plugin-mock": "^1.0.6"
}
}
2 changes: 1 addition & 1 deletion plugins/mock/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@koishijs/plugin-mock",
"description": "Test Mocker for Koishi",
"version": "1.0.5",
"version": "1.0.6",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
"files": [
Expand Down
1 change: 1 addition & 0 deletions plugins/mock/src/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export class MockAdapter extends Adapter<BotConfig> {
constructor(ctx: Context, config: MockAdapter.Config) {
super(ctx, config)
this.app = ctx.app
this.webhook = new Webhook(ctx.app)
ctx.mock = this
ctx.bots.adapters.mock = this

Expand Down
2 changes: 1 addition & 1 deletion plugins/mock/src/webhook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class Webhook {
const code = res.statusCode
const headers = res.getHeaders()
resolve({ code, body, headers })
callback?.()
if (typeof callback === 'function') callback()
return res
}
this.app._httpServer.emit('request', req, res)
Expand Down

0 comments on commit 7c8171e

Please sign in to comment.