Skip to content

Commit

Permalink
fix: 修正cli
Browse files Browse the repository at this point in the history
  • Loading branch information
sj817 committed Sep 14, 2024
1 parent 7a6ab5d commit 4214f07
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 8 deletions.
2 changes: 1 addition & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import neostandard from 'neostandard'

export default neostandard({
ignores: ['node_modules', 'temp', 'logs', 'data'],
ignores: ['node_modules', 'temp', 'logs', 'data', 'lib'],
globals: ['logger', 'NodeJS'],
ts: true,
}).map(val => {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
],
"scripts": {
".": "node lib/cli/start.js .",
"build": "tsc --project tsconfig.json && tsc-alias -p tsconfig.json && npm run fix:all",
"build": "tsc --project tsconfig.json && tsc-alias -p tsconfig.json",
"build:npm": "tsc --project tsconfig.json && tsc-alias -p tsconfig.json",
"dev": "node lib/cli/start.js dev",
"fix": "eslint lib/**/*.js --fix",
Expand Down Expand Up @@ -167,4 +167,4 @@
"access": "public",
"registry": "https://registry.npmjs.org"
}
}
}
6 changes: 3 additions & 3 deletions src/api/npm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export async function getNpmPlugins<T extends boolean> (showDetails: T): Promise
const pkg = readJson(pkgPath)
if (pkg?.karin) list.push(name)
} catch (error: any) {
logger.error(`[common] 解析 package.json 时出错:${error.stack || error.message || JSON.stringify(error)}`)
console.error(`[common] 解析 package.json 时出错:${error.stack || error.message || JSON.stringify(error)}`)
}
}

Expand All @@ -47,7 +47,7 @@ export async function getNpmPlugins<T extends boolean> (showDetails: T): Promise
if (pkg?.karin?.apps?.length) {
pkg.karin.apps.forEach((app: string) => {
if (!fs.existsSync(path.join(root, app))) {
logger.error(`[common] npm插件${files}的app目录${app}不存在 已跳过`)
console.error(`[common] npm插件${files}的app目录${app}不存在 已跳过`)
return
}

Expand All @@ -59,7 +59,7 @@ export async function getNpmPlugins<T extends boolean> (showDetails: T): Promise
})
}
} catch (error: any) {
logger.error(`[common] 获取npm插件列表时出错:${error.stack || error.message || JSON.stringify(error)}`)
console.error(`[common] 获取npm插件列表时出错:${error.stack || error.message || JSON.stringify(error)}`)
}
}

Expand Down
12 changes: 10 additions & 2 deletions src/types/element/element.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type ElementType = 'text' | 'at' | 'face' | 'bubble_face' | 'reply' | 'image' | 'video' | 'basketball' | 'dice' | 'rps' | 'poke' | 'music' | 'weather' | 'location' | 'share' | 'gift' | 'market_face' | 'forward' | 'contact' | 'json' | 'xml' | 'file' | 'markdown' | 'markdown_tpl' | 'keyboard' | 'node' | 'rows' | 'record' | 'long_msg' | 'raw'
export type ElementType = 'text' | 'at' | 'face' | 'bubble_face' | 'reply' | 'image' | 'video' | 'basketball' | 'dice' | 'rps' | 'poke' | 'music' | 'weather' | 'location' | 'share' | 'gift' | 'market_face' | 'forward' | 'contact' | 'json' | 'xml' | 'file' | 'markdown' | 'markdown_tpl' | 'keyboard' | 'node' | 'rows' | 'record' | 'long_msg' | 'raw' | 'passive_reply'

export interface Element {
/**
Expand Down Expand Up @@ -585,6 +585,14 @@ export interface LongMsgElement extends Element {
id: string
}

/**
* - 回复被动消息 键入此字段代表此条消息为被动消息
*/
export interface PassiveElement extends Element {
type: 'passive_reply'
id: string
}

/**
* 原生元素
*/
Expand All @@ -593,7 +601,7 @@ export interface RawElement extends Element {
data: any
}

export type KarinElement = TextElement | AtElement | FaceElement | BubbleFaceElement | ReplyElement | ImageElement | VideoElement | BasketballElement | DiceElement | RpsElement | PokeElement | MusicElement | WeatherElement | LocationElement | ShareElement | GiftElement | MarketFaceElement | ForwardElement | ContactElement | JsonElement | XmlElement | FileElement | ButtonElement | KeyBoardElement | RecordElement | LongMsgElement | TplMarkdownElement | RawMarkdownElement | RawElement
export type KarinElement = TextElement | AtElement | FaceElement | BubbleFaceElement | ReplyElement | ImageElement | VideoElement | BasketballElement | DiceElement | RpsElement | PokeElement | MusicElement | WeatherElement | LocationElement | ShareElement | GiftElement | MarketFaceElement | ForwardElement | ContactElement | JsonElement | XmlElement | FileElement | ButtonElement | KeyBoardElement | RecordElement | LongMsgElement | TplMarkdownElement | RawMarkdownElement | RawElement | PassiveElement

/**
* - 构建自定义转发节点 此元素仅可通过专用接口发送 不支持混合发送
Expand Down
8 changes: 8 additions & 0 deletions src/types/event/contact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,19 @@
* - 事件来源枚举
*/
export const enum Scene {
/** 群 */
Group = 'group',
/** 好友 */
Private = 'friend',
/** 频道 */
Guild = 'guild',
/** 频道私信 */
GuildPrivate = 'guild_private',
/** 临时会话 */
Nearby = 'nearby',
/** 陌生人 */
Stranger = 'stranger',
/** 临时群会话 */
StrangerFromGroup = 'stranger_from_group',
}

Expand Down
10 changes: 10 additions & 0 deletions src/utils/core/segment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -591,4 +591,14 @@ export const segment = new (class Segment {
data,
}
}

/**
* 回复被动消息
*/
passive_reply (id: string): { type: 'passive_reply', id: string } {
return {
type: 'passive_reply',
id,
}
}
})()

0 comments on commit 4214f07

Please sign in to comment.