Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Oct 15, 2020
2 parents 4ed7476 + d05d354 commit c333fa3
Show file tree
Hide file tree
Showing 40 changed files with 216 additions and 186 deletions.
4 changes: 2 additions & 2 deletions packages/adapter-cqhttp/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "koishi-adapter-cqhttp",
"description": "CQHTTP adapter for Koishi",
"version": "1.0.5",
"version": "1.0.6",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"files": [
Expand Down Expand Up @@ -31,7 +31,7 @@
"koishi"
],
"peerDependencies": {
"koishi-core": "^2.3.1"
"koishi-core": "^2.3.2"
},
"devDependencies": {
"@types/ms": "^0.7.31",
Expand Down
5 changes: 4 additions & 1 deletion packages/adapter-cqhttp/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ declare module 'koishi-core/dist/server' {
setRestart(cleanLog?: boolean, cleanCache?: boolean, cleanEvent?: boolean): Promise<void>
setGroupName(groupId: number, name: string): Promise<void>
setGroupNameAsync(groupId: number, name: string): Promise<void>
setGroupPortrait(groupId: number, file: string, cache?: boolean): Promise<void>
setGroupPortraitAsync(groupId: number, file: string, cache?: boolean): Promise<void>
getGroupMsg(messageId: number): Promise<GroupMessage>
getForwardMsg(messageId: number): Promise<ForwardMessage>
sendGroupForwardMsg(groupId: number, messages: readonly CQNode[]): Promise<void>
Expand Down Expand Up @@ -412,7 +414,8 @@ interface CQNode {
}
}

defineAsync('set_group_name', 'group_id', 'name')
defineAsync('set_group_name', 'group_id', 'group_name')
defineAsync('set_group_portrait', 'group_id', 'file', 'cache')

export function toVersion(data: VersionInfo) {
const { coolqEdition, pluginVersion, goCqhttp, version } = data
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-tomon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"koishi"
],
"peerDependencies": {
"koishi-core": "^2.3.1"
"koishi-core": "^2.3.2"
},
"devDependencies": {
"koishi-test-utils": "^5.0.2"
Expand Down
2 changes: 1 addition & 1 deletion packages/koishi-core/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "koishi-core",
"description": "Core features for Koishi",
"version": "2.3.1",
"version": "2.3.2",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"engines": {
Expand Down
3 changes: 3 additions & 0 deletions packages/koishi-core/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,9 @@ export interface EventMap {
'group_recall'(session: RawSession<'notice'>): void
'friend_recall'(session: RawSession<'notice'>): void
'notify'(session: RawSession<'notice'>): void
'notify/poke'(session: RawSession<'notice'>): void
'notify/lucky_king'(session: RawSession<'notice'>): void
'notify/honor'(session: RawSession<'notice'>): void
'request/friend'(session: RawSession<'request'>): void
'request/group/add'(session: RawSession<'request'>): void
'request/group/invite'(session: RawSession<'request'>): void
Expand Down
2 changes: 1 addition & 1 deletion packages/koishi-test-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"dependencies": {
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"koishi-core": "^2.3.1",
"koishi-core": "^2.3.2",
"koishi-utils": "^3.1.5"
},
"devDependencies": {
Expand Down
24 changes: 12 additions & 12 deletions packages/koishi/ecosystem.json
Original file line number Diff line number Diff line change
@@ -1,69 +1,69 @@
{
"koishi-adapter-cqhttp": {
"version": "1.0.5",
"version": "1.0.6",
"description": "CQHTTP adapter for Koishi"
},
"koishi-adapter-tomon": {
"version": "0.1.1",
"description": "Tomon adapter for Koishi"
},
"koishi-plugin-chess": {
"version": "2.0.0-beta.11",
"version": "2.0.0-beta.12",
"description": "Chess Plugin for Koishi"
},
"koishi-plugin-common": {
"version": "3.0.2",
"version": "3.0.3",
"description": "Common plugins for Koishi"
},
"koishi-plugin-dice": {
"version": "0.1.1",
"description": "COC / DND Tools for Koishi"
},
"koishi-plugin-eval": {
"version": "2.0.2",
"version": "2.0.3",
"description": "Execute JavaScript in Koishi"
},
"koishi-plugin-eval-addons": {
"version": "1.0.0-beta.12",
"description": "Execute JavaScript in Koishi"
},
"koishi-plugin-github": {
"version": "2.1.1",
"version": "2.1.2",
"description": "GitHub webhook plugin for Koishi"
},
"koishi-plugin-image-search": {
"version": "2.0.1",
"description": "Image searching plugin for Koishi"
},
"koishi-plugin-mongo": {
"version": "1.0.4",
"version": "1.1.0",
"description": "MongoDB support for Koishi"
},
"koishi-plugin-monitor": {
"version": "1.0.0-beta.15"
"version": "1.0.0-beta.16"
},
"koishi-plugin-mysql": {
"version": "2.0.1",
"version": "2.0.2",
"description": "MySQL support for Koishi"
},
"koishi-plugin-puppeteer": {
"version": "1.0.1",
"description": "Take Screenshots in Koishi"
},
"koishi-plugin-rss": {
"version": "1.0.1",
"version": "1.1.0",
"description": "Subscribe RSS Url for Koishi"
},
"koishi-plugin-schedule": {
"version": "2.0.3",
"version": "2.0.4",
"description": "Schedule plugin for Koishi"
},
"koishi-plugin-status": {
"version": "2.0.0-beta.16",
"version": "2.0.0-beta.17",
"description": "Show Status of Koishi"
},
"koishi-plugin-teach": {
"version": "1.1.1",
"version": "1.2.0",
"description": "Teach plugin for Koishi"
},
"koishi-plugin-tools": {
Expand Down
8 changes: 4 additions & 4 deletions packages/koishi/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "koishi",
"description": "A QQ bot framework based on CQHTTP",
"version": "2.3.1",
"version": "2.3.2",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"engines": {
Expand Down Expand Up @@ -40,9 +40,9 @@
"dependencies": {
"cac": "^6.6.1",
"kleur": "^4.1.3",
"koishi-adapter-cqhttp": "^1.0.5",
"koishi-core": "^2.3.1",
"koishi-plugin-common": "^3.0.2",
"koishi-adapter-cqhttp": "^1.0.6",
"koishi-core": "^2.3.2",
"koishi-plugin-common": "^3.0.3",
"prompts": "^2.3.2"
}
}
4 changes: 2 additions & 2 deletions packages/plugin-chess/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "koishi-plugin-chess",
"description": "Chess Plugin for Koishi",
"version": "2.0.0-beta.11",
"version": "2.0.0-beta.12",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"files": [
Expand Down Expand Up @@ -33,7 +33,7 @@
"game"
],
"peerDependencies": {
"koishi-core": "^2.3.1",
"koishi-core": "^2.3.2",
"koishi-plugin-puppeteer": "^1.0.1",
"koishi-utils": "^3.1.5"
}
Expand Down
7 changes: 6 additions & 1 deletion packages/plugin-chess/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import { Context, Group } from 'koishi-core'
import { Context, extendDatabase, Group } from 'koishi-core'
import { isInteger } from 'koishi-utils'
import { State, MoveResult, StateData } from './state'
import MysqlDatabase from 'koishi-plugin-mysql/dist/database'
import * as go from './go'
import * as gomoku from './gomoku'
import * as othello from './othello'

extendDatabase<typeof MysqlDatabase>('koishi-plugin-mysql', ({ tables }) => {
tables.group.chess = `JSON NULL DEFAULT NULL`
})

interface Rule {
placement?: 'grid' | 'cross'
create?: (this: State) => string | void
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-common/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "koishi-plugin-common",
"description": "Common plugins for Koishi",
"version": "3.0.2",
"version": "3.0.3",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"files": [
Expand Down Expand Up @@ -31,7 +31,7 @@
"plugin"
],
"peerDependencies": {
"koishi-core": "^2.3.1",
"koishi-core": "^2.3.2",
"koishi-utils": "^3.1.5"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-common/src/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ export function apply(ctx: Context) {
ctx.command('group.assign [bot]', '受理者账号', { authority: 4 })
.groupFields(['assignee'])
.adminGruop(({ session, target }, value) => {
const assignee = value ? +value : session.selfId
const assignee = value ? getTargetId(value) : session.selfId
if (!isInteger(assignee) || assignee < 0) return '参数错误。'
target.assignee = assignee
})
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-dice/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"dice"
],
"peerDependencies": {
"koishi-core": "^2.3.1",
"koishi-core": "^2.3.2",
"koishi-utils": "^3.1.5"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-eval-addons/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
"code"
],
"peerDependencies": {
"koishi-core": "^2.3.1",
"koishi-plugin-eval": "^2.0.2",
"koishi-core": "^2.3.2",
"koishi-plugin-eval": "^2.0.3",
"koishi-utils": "^3.1.5"
},
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-eval/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "koishi-plugin-eval",
"version": "2.0.2",
"version": "2.0.3",
"description": "Execute JavaScript in Koishi",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
Expand Down Expand Up @@ -37,7 +37,7 @@
"code"
],
"peerDependencies": {
"koishi-core": "^2.3.1",
"koishi-core": "^2.3.2",
"koishi-utils": "^3.1.5"
},
"devDependencies": {
Expand Down
5 changes: 3 additions & 2 deletions packages/plugin-eval/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ declare module 'koishi-core/dist/session' {

const defaultConfig: EvalConfig = {
prefix: '>',
authority: 2,
timeout: 1000,
setupFiles: {},
maxLogs: Infinity,
Expand All @@ -38,7 +39,7 @@ const logger = new Logger('eval')
export const name = 'eval'

export function apply(ctx: Context, config: Config = {}) {
const { prefix } = config = { ...defaultConfig, ...config }
const { prefix, authority } = config = { ...defaultConfig, ...config }
const { app } = ctx
const worker = new EvalWorker(app, config)
defineProperty(app, 'worker', worker)
Expand All @@ -59,7 +60,7 @@ export function apply(ctx: Context, config: Config = {}) {
.option('slient', '-s 不输出最后的结果')
.option('restart', '-r 重启子线程', { authority: 3 })
.before((session) => {
if (!session['_redirected'] && session.$user?.authority < 2) return '权限不足。'
if (!session['_redirected'] && session.$user?.authority < authority) return '权限不足。'
})

attachTraps(cmd, config, async ({ session, options, ctxOptions }, expr) => {
Expand Down
1 change: 1 addition & 0 deletions packages/plugin-eval/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const logger = new Logger('eval')

export interface MainConfig extends FieldOptions {
prefix?: string
authority?: number
timeout?: number
maxLogs?: number
resourceLimits?: ResourceLimits
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-eval/src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export class WorkerAPI {
let result: any
try {
result = await vm.run(`{
const { send, exec, user } = global[Symbol.for("${key}")];
const { send, exec, user, group } = global[Symbol.for("${key}")];
delete global[Symbol.for("${key}")];
\n${source}
}`, {
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-github/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "koishi-plugin-github",
"description": "GitHub webhook plugin for Koishi",
"version": "2.1.1",
"version": "2.1.2",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"files": [
Expand Down Expand Up @@ -36,7 +36,7 @@
"koishi-test-utils": "^5.0.2"
},
"peerDependencies": {
"koishi-core": "^2.3.1",
"koishi-core": "^2.3.2",
"koishi-plugin-puppeteer": "^1.0.1",
"koishi-utils": "^3.1.5"
},
Expand Down
11 changes: 6 additions & 5 deletions packages/plugin-github/src/events.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/* eslint-disable camelcase */

import { EventNames } from '@octokit/webhooks'
import { GetWebhookPayloadTypeFromEvent } from '@octokit/webhooks/dist-types/generated/get-webhook-payload-type-from-event'
import { EventTypesPayload } from '@octokit/webhooks/dist-types/generated/get-webhook-payload-type-from-event'

type WebhookEvent = Exclude<keyof EventTypesPayload, 'error'>

export interface EventConfig {
commitComment?: boolean | {
Expand Down Expand Up @@ -105,10 +106,10 @@ export interface EventData {
}
}

type Payload<T extends EventNames.All> = GetWebhookPayloadTypeFromEvent<T, unknown>['payload']
type EventHandler<T extends EventNames.All> = (payload: Payload<T>) => EventData
type Payload<T extends WebhookEvent> = EventTypesPayload[T]['payload']
type EventHandler<T extends WebhookEvent> = (payload: Payload<T>) => EventData

export function addListeners(on: <T extends EventNames.All>(event: T, handler: EventHandler<T>) => void) {
export function addListeners(on: <T extends WebhookEvent>(event: T, handler: EventHandler<T>) => void) {
function formatMarkdown(source: string) {
return source
.replace(/^```(.*)$/gm, '')
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-image-search/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"pixiv"
],
"peerDependencies": {
"koishi-core": "^2.3.1",
"koishi-core": "^2.3.2",
"koishi-utils": "^3.1.5"
},
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-mongo/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "koishi-plugin-mongo",
"description": "MongoDB support for Koishi",
"version": "1.0.4",
"version": "1.1.0",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"files": [
Expand Down Expand Up @@ -39,7 +39,7 @@
"@types/mongodb": "^3.5.27"
},
"peerDependencies": {
"koishi-core": "^2.3.1"
"koishi-core": "^2.3.2"
},
"dependencies": {
"mongodb": "^3.6.2"
Expand Down
Loading

0 comments on commit c333fa3

Please sign in to comment.