-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
313 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,139 @@ | ||
import { Context, Tsu } from 'kotori-bot' | ||
|
||
// TODO: update | ||
import { type Context, Tsu, Messages, type SessionMsg } from 'kotori-bot' | ||
|
||
const biliSchema = Tsu.Object({ | ||
data: Tsu.Object({ | ||
id: Tsu.String(), | ||
name: Tsu.String(), | ||
title: Tsu.String(), | ||
cover: Tsu.String(), | ||
description: Tsu.String(), | ||
sort: Tsu.String(), | ||
time: Tsu.Number(), | ||
view: Tsu.Number(), | ||
coin: Tsu.Number(), | ||
like: Tsu.Number(), | ||
collect: Tsu.Number() | ||
View: Tsu.Object({ | ||
bvid: Tsu.String(), | ||
aid: Tsu.Number(), | ||
tname: Tsu.String(), | ||
title: Tsu.String(), | ||
pic: Tsu.String(), | ||
desc: Tsu.String(), | ||
ctime: Tsu.Number(), | ||
owner: Tsu.Object({ | ||
name: Tsu.String(), | ||
mid: Tsu.Number() | ||
}), | ||
stat: Tsu.Object({ | ||
view: Tsu.Any(), | ||
reply: Tsu.Any(), | ||
favorite: Tsu.Any(), | ||
coin: Tsu.Any(), | ||
share: Tsu.Any(), | ||
like: Tsu.Any() | ||
}) | ||
}) | ||
}).optional() | ||
}) | ||
|
||
const bilier1Schema = Tsu.Object({ | ||
const biliArSchema = Tsu.Object({ | ||
data: Tsu.Object({ | ||
following: Tsu.Number(), | ||
follower: Tsu.Number() | ||
mid: Tsu.Number(), | ||
author_name: Tsu.String(), | ||
title: Tsu.String(), | ||
origin_image_urls: Tsu.String().optional(), | ||
stats: Tsu.Object({ | ||
view: Tsu.Any(), | ||
reply: Tsu.Any(), | ||
favorite: Tsu.Any(), | ||
coin: Tsu.Any(), | ||
share: Tsu.Any(), | ||
like: Tsu.Any() | ||
}) | ||
}).optional() | ||
}) | ||
|
||
const bilier2Schema = Tsu.Object({ | ||
data: Tsu.Object({ | ||
name: Tsu.String(), | ||
level: Tsu.Number(), | ||
sex: Tsu.String(), | ||
description: Tsu.String(), | ||
avatar: Tsu.String() | ||
}).optional() | ||
}) | ||
// const bilier1Schema = Tsu.Object({ | ||
// data: Tsu.Object({ | ||
// following: Tsu.Number(), | ||
// follower: Tsu.Number() | ||
// }).optional() | ||
// }) | ||
|
||
// const bilier2Schema = Tsu.Object({ | ||
// data: Tsu.Object({ | ||
// name: Tsu.String(), | ||
// level: Tsu.Number(), | ||
// sex: Tsu.String(), | ||
// description: Tsu.String(), | ||
// avatar: Tsu.String() | ||
// }).optional() | ||
// }) | ||
|
||
export const lang = [__dirname, '../locales'] | ||
|
||
export function main(ctx: Context) { | ||
ctx.command('bili <bvid> - bilibili.descr.bili').action(async (data, session) => { | ||
const res = biliSchema.parse(await ctx.http.get('https://tenapi.cn/bv/', { id: data.args[0] })) | ||
if (!res.data) return ['bilibili.msg.bili.fail', { input: data.args[0] }] | ||
return [ | ||
'bilibili.msg.bili', | ||
{ | ||
...res.data, | ||
time: session.i18n.time(res.data.time), | ||
image: session.el.image(res.data.cover) | ||
} | ||
] | ||
async function getVideo(id: string, session: SessionMsg) { | ||
const params = id.startsWith('av') ? { avid: id } : { bvid: id } | ||
const res = biliSchema.parse( | ||
await ctx.http.get('https://api.bilibili.com/x/web-interface/view/detail', params as { bvid: string }) | ||
) | ||
if (!res.data) return '没有找到相关视频' | ||
const { View: v } = res.data | ||
session.quick([ | ||
'BV 号:{0}\nAV 号:{1}\n分区名称:{2}\n视频标题:{3}\n视频简介:{4}\n发布时间:{5}\n播放量:{6}\n点赞量:{7}\n收藏量:{8}\n投币量:{9}\n评论量:{10}\n分享量:{11}\nUP 主名字:{12}\nUP 主 UID:{13}', | ||
[ | ||
v.bvid, | ||
v.aid, | ||
v.tname, | ||
v.title, | ||
v.desc, | ||
new Date(v.ctime * 1000).toLocaleString(), | ||
v.stat.view, | ||
v.stat.like, | ||
v.stat.favorite, | ||
v.stat.coin, | ||
v.stat.reply, | ||
v.stat.share, | ||
v.owner.name, | ||
v.owner.mid | ||
] | ||
]) | ||
return Messages.image(v.pic) | ||
} | ||
|
||
ctx.command('bili <id> - 查询 B站 视频信息').action(async ({ args: [id] }, session) => { | ||
return getVideo(id, session) | ||
}) | ||
|
||
ctx.command('bilier <uid> - bilibili.descr.bilier').action(async (data, session) => { | ||
const res = Object.assign( | ||
bilier1Schema.parse(await ctx.http.get('https://tenapi.cn/bilibilifo/', { uid: data.args[0] })).data || {}, | ||
bilier2Schema.parse(await ctx.http.get('https://tenapi.cn/bilibili/', { uid: data.args[0] })).data | ||
) | ||
if (!res) return ['bilibili.msg.bilier.fail', { input: data.args[0] }] | ||
return [ | ||
'bilibili.msg.bilier', | ||
{ | ||
...res, | ||
image: session.el.image(res.avatar) | ||
} | ||
] | ||
ctx.command('bili-ar <cid> - 查询 B站 专栏信息').action(async ({ args: [id] }, session) => { | ||
const params = { id: id.startsWith('cv') ? id.slice(2) : id } | ||
const res = biliArSchema.parse(await ctx.http.get('https://api.bilibili.com/x/article/viewinfo', params)) | ||
if (!res.data) return '没有找到相关文章' | ||
const { data: d } = res | ||
session.quick([ | ||
'CV 号:{0}\n专栏标题:{1}\nUP 主名字:{2}\n播放量:{3}\n点赞量:{4}\n收藏量:{5}\n投币量:{6}\n评论量:{7}\n分享量:{8}', | ||
[ | ||
d.mid, | ||
d.title, | ||
d.author_name, | ||
d.stats.view, | ||
d.stats.like, | ||
d.stats.favorite, | ||
d.stats.coin, | ||
d.stats.reply, | ||
d.stats.share | ||
] | ||
]) | ||
return d.origin_image_urls ? Messages.image(d.origin_image_urls) : '' | ||
}) | ||
|
||
ctx.regexp(/^(bv|BV)([A-Z,a-z,0-9]){8,12}$/, (result, session) => { | ||
session.quick(getVideo(result[0], session)) | ||
}) | ||
|
||
// ctx.command('bilier <uid> - bilibili.descr.bilier').action(async (data, session) => { | ||
// const res = Object.assign( | ||
// bilier1Schema.parse(await ctx.http.get('https://tenapi.cn/bilibilifo/', { uid: data.args[0] })).data || {}, | ||
// bilier2Schema.parse(await ctx.http.get('https://tenapi.cn/bilibili/', { uid: data.args[0] })).data | ||
// ) | ||
// if (!res) return ['bilibili.msg.bilier.fail', { input: data.args[0] }] | ||
// return [ | ||
// 'bilibili.msg.bilier', | ||
// { | ||
// ...res, | ||
// image: session.el.image(res.avatar) | ||
// } | ||
// ] | ||
// }) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,8 +14,5 @@ | |
"meta": { | ||
"language": ["en_US", "ja_JP", "zh_TW", "zh_CN"] | ||
} | ||
}, | ||
"dependencies": { | ||
"lua-in-js": "^2.2.4" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,19 @@ | ||
{ | ||
"name": "@kotori-bot/root", | ||
"description": "ChatBot Framework", | ||
"version": "1.5.4", | ||
"version": "1.6.0", | ||
"private": true, | ||
"license": "GPL-3.0", | ||
"author": "Arimura Sena <[email protected]>", | ||
"scripts": { | ||
"kotori": "pnpm --filter kotori-bot", | ||
"build": "rm -rf ./{packages,modules}/*/tsconfig.tsbuildinfo && pnpm -r exec tsup --define.env=prod && pnpm -r exec tsc --build", | ||
"build": "rm -rf ./{packages,modules}/*/tsconfig.tsbuildinfo && pnpm -r exec tsup --define.env=prod && pnpm --filter \"./packages/*\" exec tsc --build && pnpm --filter \"./modules/*\" exec tsc --build", | ||
"build:action": "rm -rf ./{packages,modules}/*/tsconfig.tsbuildinfo && pnpm -r exec tsup --define.env=prod && tsx scripts/build-ts", | ||
"dev:only": "pnpm --filter \"./packages/*\" exec \"tsup --silent\" && tsx packages/kotori/src/cli --mode dev", | ||
"dev": "nodemon --watch", | ||
"test": "pnpm -r exec jest --preset ts-jest --coverageDirectory coverage --testEnvironment node --passWithNoTests", | ||
"version": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0", | ||
"clean": "rm -rf {./{packages,modules}/*/{tsconfig.tsbuildinfo,lib},./packages/*/{dist}" | ||
"clean": "rm -rf ./{packages,modules}/*/{tsconfig.tsbuildinfo,lib} && rm -rf ./packages/*/dist" | ||
}, | ||
"files": [ | ||
"{packages,modules}/*/locales/**/*", | ||
|
@@ -25,11 +26,14 @@ | |
], | ||
"devDependencies": { | ||
"@biomejs/biome": "1.8.3", | ||
"@manypkg/get-packages": "^2.2.2", | ||
"@types/jest": "^29.5.12", | ||
"@types/node": "^20.14.1", | ||
"@types/shelljs": "^0.8.15", | ||
"conventional-changelog-cli": "^4.1.0", | ||
"jest": "^29.7.0", | ||
"nodemon": "^3.1.3", | ||
"shelljs": "^0.8.5", | ||
"ts-jest": "^29.2.4", | ||
"tsup": "^8.1.0", | ||
"tsx": "^4.11.2", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
import type { CoreConfig } from '../types' | ||
import { DEFAULT_CORE_CONFIG } from '../global' | ||
import pkg from '../../package.json' | ||
|
||
/** Meta information. */ | ||
interface MetaInfo { | ||
|
@@ -34,6 +33,16 @@ export class Config { | |
public constructor(config: Omit<Partial<CoreConfig>, 'global'> & { global?: Partial<CoreConfig['global']> } = {}) { | ||
this.config = { ...DEFAULT_CORE_CONFIG, ...config } as CoreConfig | ||
this.config.global = { ...DEFAULT_CORE_CONFIG.global, ...this.config.global } | ||
const pkg = | ||
typeof require === 'function' | ||
? require('../../package.json') | ||
: { | ||
name: '@kotori-bot/core', | ||
version: 'BROWSER', | ||
description: '', | ||
author: 'Arimura Sena <[email protected]>', | ||
main: 'lib/index.js' | ||
} | ||
this.meta = { | ||
name: pkg.name, | ||
description: pkg.description, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.