koishi-plugin-noah 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/lib/config.d.ts +2 -0
  2. package/lib/core/command.d.ts +4 -0
  3. package/lib/core/commands/bind.d.ts +3 -0
  4. package/lib/core/commands/card.d.ts +3 -0
  5. package/lib/core/commands/help.d.ts +3 -0
  6. package/lib/core/commands/server.d.ts +3 -0
  7. package/lib/core/config.d.ts +2 -0
  8. package/lib/core/database.d.ts +49 -0
  9. package/lib/core/index.d.ts +6 -0
  10. package/lib/core/services/card-service.d.ts +46 -0
  11. package/lib/core/services/drawer-service.d.ts +0 -0
  12. package/lib/core/services/server-service.d.ts +61 -0
  13. package/lib/core/types/index.d.ts +16 -0
  14. package/lib/core/utils/card.d.ts +24 -0
  15. package/lib/core/utils/role.d.ts +6 -0
  16. package/lib/drawer/BaseDrawer.d.ts +19 -0
  17. package/lib/drawer/Core/index.d.ts +22 -0
  18. package/lib/drawer/DrawerFactory.d.ts +8 -0
  19. package/lib/drawer/IIDX/index.d.ts +29 -0
  20. package/lib/drawer/SDVX/index.d.ts +35 -0
  21. package/lib/drawer/index.d.ts +13 -0
  22. package/lib/games/iidx/services/drawer-service.d.ts +0 -0
  23. package/lib/games/sdvx/command.d.ts +4 -0
  24. package/lib/games/sdvx/commands/vf.d.ts +3 -0
  25. package/lib/games/sdvx/config.d.ts +2 -0
  26. package/lib/games/sdvx/database.d.ts +3 -0
  27. package/lib/games/sdvx/event.d.ts +3 -0
  28. package/lib/games/sdvx/index.d.ts +6 -0
  29. package/lib/games/sdvx/services/drawer-service.d.ts +0 -0
  30. package/lib/games/sdvx/services/music-service.d.ts +10 -0
  31. package/lib/games/sdvx/services/score-service.d.ts +18 -0
  32. package/lib/games/sdvx/types/index.d.ts +82 -0
  33. package/lib/games/sdvx/utils/vf.d.ts +19 -0
  34. package/lib/index.d.ts +6 -0
  35. package/lib/index.js +2389 -0
  36. package/lib/servers/Asphyxia/index.d.ts +11 -0
  37. package/lib/servers/Asphyxia/services/iidx-service.d.ts +9 -0
  38. package/lib/servers/Asphyxia/services/sdvx-service.d.ts +12 -0
  39. package/lib/servers/Mao/index.d.ts +11 -0
  40. package/lib/servers/Mao/services/sdvx-service.d.ts +19 -0
  41. package/lib/servers/ServerFactory.d.ts +5 -0
  42. package/lib/servers/config.d.ts +0 -0
  43. package/lib/servers/index.d.ts +13 -0
  44. package/lib/servers/utils/difficulty.d.ts +14 -0
  45. package/lib/servers/utils/grade.d.ts +3 -0
  46. package/lib/servers/utils/xml.d.ts +14 -0
  47. package/lib/types/config.d.ts +13 -0
  48. package/lib/types/index.d.ts +66 -0
  49. package/package.json +47 -0
  50. package/readme.md +5 -0
@@ -0,0 +1,2 @@
1
+ import { AppConfig } from './types/config';
2
+ export declare const Config: AppConfig;
@@ -0,0 +1,4 @@
1
+ import { Context } from "koishi";
2
+ import { CoreConfig } from "../types/config";
3
+ export declare const name = "command";
4
+ export declare function apply(ctx: Context, config: CoreConfig): void;
@@ -0,0 +1,3 @@
1
+ import { Context } from 'koishi';
2
+ import { CoreConfig } from '../../types/config';
3
+ export declare function bind(ctx: Context, config: CoreConfig): void;
@@ -0,0 +1,3 @@
1
+ import { Context } from 'koishi';
2
+ import { CoreConfig } from '../../types/config';
3
+ export declare function card(ctx: Context, config: CoreConfig): void;
@@ -0,0 +1,3 @@
1
+ import { Context } from 'koishi';
2
+ import { CoreConfig } from '../../types/config';
3
+ export declare function help(ctx: Context, config: CoreConfig): void;
@@ -0,0 +1,3 @@
1
+ import { Context } from 'koishi';
2
+ import { CoreConfig } from '../../types/config';
3
+ export declare function server(ctx: Context, config: CoreConfig): void;
@@ -0,0 +1,2 @@
1
+ import { CoreConfig } from '../types/config';
2
+ export declare const coreConfig: CoreConfig;
@@ -0,0 +1,49 @@
1
+ import { Context } from "koishi";
2
+ import { TGame, TServer } from "../types";
3
+ declare module 'koishi' {
4
+ interface Tables {
5
+ card: Card;
6
+ server: Server;
7
+ user_card: UserCard;
8
+ user_server: UserServer;
9
+ channel_server: ChannelServer;
10
+ }
11
+ interface User {
12
+ defaultCardId: number;
13
+ defaultServerId: number;
14
+ }
15
+ interface Channel {
16
+ defaultServerId: number;
17
+ }
18
+ }
19
+ export interface Card {
20
+ id: number;
21
+ code: string;
22
+ name: string;
23
+ defaultServerId?: number;
24
+ }
25
+ export interface Server {
26
+ id: number;
27
+ type: TServer;
28
+ name: string;
29
+ baseUrl: string;
30
+ pcbid?: string;
31
+ supportedGames: TGame[];
32
+ }
33
+ export interface UserCard {
34
+ id: number;
35
+ uid: number;
36
+ cid: number;
37
+ }
38
+ export interface UserServer {
39
+ id: number;
40
+ uid: number;
41
+ sid: number;
42
+ }
43
+ export interface ChannelServer {
44
+ id: number;
45
+ cid: string;
46
+ sid: number;
47
+ }
48
+ export declare const name = "database";
49
+ export declare function apply(ctx: Context): void;
@@ -0,0 +1,6 @@
1
+ import { Context, Logger } from "koishi";
2
+ import type { AppConfig } from "../types/config";
3
+ export declare const name = "Noah-Core";
4
+ export declare const inject: string[];
5
+ export declare const logger: Logger;
6
+ export declare function apply(ctx: Context, config: AppConfig): void;
@@ -0,0 +1,46 @@
1
+ import { Context } from 'koishi';
2
+ import { Card } from '../types';
3
+ export declare class CardService {
4
+ private ctx;
5
+ private readonly tableName;
6
+ constructor(ctx: Context);
7
+ /**
8
+ * 获取所有卡片列表
9
+ */
10
+ getAllCards(): Promise<Card[]>;
11
+ /**
12
+ * 根据 user id 获取卡片列表
13
+ * @param uid 用户的 user id
14
+ * @returns 该用户绑定的卡片的完整信息列表
15
+ */
16
+ getCardsByUid(uid: number): Promise<Card[]>;
17
+ /**
18
+ * 根据 id 获取卡片信息
19
+ */
20
+ getCardById(id: number): Promise<Card | null>;
21
+ /**
22
+ * 根据 code 获取卡片信息
23
+ */
24
+ getCardByCode(code: string): Promise<Card | null>;
25
+ /**
26
+ * 创建一张新的卡
27
+ * @param uid 用户的 uid
28
+ * @param code 卡片的卡号
29
+ * @param name 卡片的名称
30
+ * @param defaultServerId 默认服务器 ID(若没有默认服务器则为 0)
31
+ * @returns 创建成功后包含自动填充 id 等字段的完整对象
32
+ */
33
+ createCard(uid: number, code: string, name: string, defaultServerId?: number): Promise<Card>;
34
+ /**
35
+ * 更新卡片的信息
36
+ * - 可更新 code、name、defaultServerId
37
+ * @param id 卡片的 id
38
+ * @param partial 更新字段
39
+ */
40
+ updateCard(id: number, partial: Partial<Omit<Card, 'id'>>): Promise<void>;
41
+ /**
42
+ * 删除卡片
43
+ * @param id 卡片 id
44
+ */
45
+ removeCard(id: number): Promise<void>;
46
+ }
File without changes
@@ -0,0 +1,61 @@
1
+ import { Context } from 'koishi';
2
+ import { TServer } from "../../types";
3
+ import { Server } from '../types';
4
+ export declare class ServerService {
5
+ private ctx;
6
+ private readonly tableName;
7
+ constructor(ctx: Context);
8
+ /**
9
+ * 获取所有服务器列表
10
+ */
11
+ getAllServers(): Promise<Server[]>;
12
+ /**
13
+ * 根据 user id 获取服务器列表
14
+ * @param uid 用户的 user id
15
+ * @returns 该用户绑定的服务器的完整信息列表
16
+ */
17
+ getServersByUid(uid: number): Promise<Server[]>;
18
+ /**
19
+ * 根据 channel id 获取服务器列表
20
+ * @param cid 频道的 channel id
21
+ * @returns 该频道绑定的服务器的完整信息列表
22
+ */
23
+ getServersByCid(cid: string): Promise<Server[]>;
24
+ /**
25
+ * 根据 id 获取服务器信息
26
+ */
27
+ getServerById(id: number): Promise<Server | null>;
28
+ /**
29
+ * 根据名称查找服务器
30
+ */
31
+ getServerByName(name: string): Promise<Server | null>;
32
+ /**
33
+ * 根据类型筛选服务器
34
+ */
35
+ getServersByType(type: TServer): Promise<Server[]>;
36
+ /**
37
+ * 创建一个新的服务器记录并关联到用户
38
+ * @param serverData 要插入的数据 (不含 id)
39
+ * @param uid 用户的 ID
40
+ * @returns 插入后的完整数据
41
+ */
42
+ createServerForUser(serverData: Omit<Server, 'id'>, uid: number): Promise<Server>;
43
+ /**
44
+ * 创建一个新的服务器记录并关联到频道
45
+ * @param serverData 要插入的数据 (不含 id)
46
+ * @param cid 频道的 ID
47
+ * @returns 插入后的完整数据
48
+ */
49
+ createServerForChannel(serverData: Omit<Server, 'id'>, cid: string): Promise<Server>;
50
+ /**
51
+ * 更新服务器记录
52
+ * @param id 服务器 id
53
+ * @param partial 要更新的字段
54
+ */
55
+ updateServer(id: number, partial: Partial<Omit<Server, 'id'>>): Promise<void>;
56
+ /**
57
+ * 删除服务器记录
58
+ * @param id 服务器 id
59
+ */
60
+ removeServer(id: number): Promise<void>;
61
+ }
@@ -0,0 +1,16 @@
1
+ import { TServer } from "../../types";
2
+ import { TGame } from "../../types";
3
+ export interface Card {
4
+ id: number;
5
+ code: string;
6
+ name: string;
7
+ defaultServerId: number;
8
+ }
9
+ export interface Server {
10
+ id: number;
11
+ type: TServer;
12
+ name: string;
13
+ baseUrl: string;
14
+ pcbid?: string;
15
+ supportedGames: TGame[];
16
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * 将 e-Amusement 卡号(16 个十六进制字符,对应 8 字节)转换为 KONAMI ID(16字符,从 ALPHABET 中取值)
3
+ * @param uid e-Amusement 卡号(十六进制字符串,必须为 16 位,大写或小写皆可)
4
+ * @returns KONAMI ID 字符串
5
+ */
6
+ export declare function toKonamiId(uid: string): string;
7
+ /**
8
+ * 将 KONAMI ID(16字符)转换回 e-Amusement 卡号(16 个十六进制字符)
9
+ * @param konamiId KONAMI ID 字符串
10
+ * @returns e-Amusement 卡号(16 位十六进制字符串,大写)
11
+ */
12
+ export declare function toUid(konamiId: string): string;
13
+ /**
14
+ * 判断给定的字符串是 UID、KONAMI ID 还是非法字符串。
15
+ * @param input 待判断的字符串
16
+ * @returns "uid" 表示 e-Amusement UID, "konamiid" 表示 KONAMI ID, "invalid" 表示非法字符串.
17
+ */
18
+ export declare function classifyCardId(input: string): "uid" | "konamiid" | "invalid";
19
+ /**
20
+ * 处理用户输入的卡号。
21
+ * @param input 用户输入的卡号
22
+ * @returns 修正后的全大写字符串
23
+ */
24
+ export declare function processInputCardCode(input: string): string;
@@ -0,0 +1,6 @@
1
+ import { Session } from 'koishi';
2
+ import { CoreConfig } from '../../types/config';
3
+ export * from '../config';
4
+ export declare function hasPermission(...perms: boolean[]): boolean;
5
+ export declare function isPluginAdmin(session: Session, config: CoreConfig): boolean;
6
+ export declare function isGuildAdmin(session: Session): boolean;
@@ -0,0 +1,19 @@
1
+ import { Context } from 'koishi';
2
+ import { IDrawer } from '../types';
3
+ /**
4
+ * Base drawer class that provides common functionality for all drawers
5
+ */
6
+ export declare abstract class BaseDrawer implements IDrawer {
7
+ ctx: Context;
8
+ constructor(ctx: Context);
9
+ /**
10
+ * Compress an image buffer
11
+ * @param canvas The canvas object to compress
12
+ * @param compression Compression options
13
+ * @returns Promise resolving to a compressed buffer
14
+ */
15
+ protected compressImage(canvas: any, compression?: {
16
+ lossless: boolean;
17
+ quality?: number;
18
+ }): Promise<Buffer>;
19
+ }
@@ -0,0 +1,22 @@
1
+ import { Context } from 'koishi';
2
+ import { BaseDrawer } from '../BaseDrawer';
3
+ export declare class CoreDrawer extends BaseDrawer {
4
+ ctx: Context;
5
+ constructor(ctx: Context);
6
+ /**
7
+ * Generate a generic image for core functionality
8
+ * @param options Configuration options for image generation
9
+ * @param compression Compression options
10
+ * @returns Promise resolving to a Buffer containing the image data
11
+ */
12
+ generateImage(options?: {
13
+ width?: number;
14
+ height?: number;
15
+ text?: string;
16
+ backgroundColor?: string;
17
+ textColor?: string;
18
+ }, compression?: {
19
+ lossless: boolean;
20
+ quality?: number;
21
+ }): Promise<Buffer>;
22
+ }
@@ -0,0 +1,8 @@
1
+ import { Context } from "koishi";
2
+ import { IDrawer, TGame } from '../types';
3
+ export declare class DrawerFactory {
4
+ private ctx;
5
+ private drawerInstances;
6
+ constructor(ctx: Context);
7
+ getDrawer(drawerType: TGame | 'core'): IDrawer;
8
+ }
@@ -0,0 +1,29 @@
1
+ import { Context } from 'koishi';
2
+ import { BaseDrawer } from '../BaseDrawer';
3
+ export declare class IIDXDrawer extends BaseDrawer {
4
+ ctx: Context;
5
+ constructor(ctx: Context);
6
+ /**
7
+ * Generate an image for IIDX data
8
+ * @param options Configuration options for image generation
9
+ * @param compression Compression options
10
+ * @returns Promise resolving to a Buffer containing the image data
11
+ */
12
+ generateImage(options?: {
13
+ width?: number;
14
+ height?: number;
15
+ playerName?: string;
16
+ backgroundColor?: string;
17
+ textColor?: string;
18
+ dj_level?: string;
19
+ sp_dan?: string;
20
+ dp_dan?: string;
21
+ }, compression?: {
22
+ lossless: boolean;
23
+ quality?: number;
24
+ }): Promise<Buffer>;
25
+ /**
26
+ * Draw ranking information
27
+ */
28
+ private drawRankingInfo;
29
+ }
@@ -0,0 +1,35 @@
1
+ import { Context } from 'koishi';
2
+ import { BaseDrawer } from '../BaseDrawer';
3
+ import { SDVXScore } from '../../games/sdvx/types';
4
+ import { SDVXConfig } from '../../types/config';
5
+ export declare class SDVXDrawer extends BaseDrawer {
6
+ ctx: Context;
7
+ constructor(ctx: Context);
8
+ /**
9
+ * Generate a Volforce image for SDVX scores
10
+ * @param options Configuration options for image generation
11
+ * @param compression Compression options
12
+ * @returns Promise resolving to a Buffer containing the image data
13
+ */
14
+ generateVFImage(options: {
15
+ scores: SDVXScore[];
16
+ playerName: string;
17
+ config: SDVXConfig;
18
+ }, compression?: {
19
+ lossless: boolean;
20
+ }): Promise<Buffer>;
21
+ /**
22
+ * Draw score cards on the canvas
23
+ */
24
+ private drawScoreCards;
25
+ /**
26
+ * Get abbreviation for a difficulty level
27
+ */
28
+ private getDifficultyAbbreviation;
29
+ /**
30
+ * Calculate the average volforce from best 50 scores
31
+ */
32
+ private calculateAverageVF;
33
+ private wrapText;
34
+ private roundRect;
35
+ }
@@ -0,0 +1,13 @@
1
+ import type { AppConfig } from "../types/config";
2
+ import { Context } from "koishi";
3
+ import { TGame } from '../types';
4
+ export declare const name = "Noah-Drawer";
5
+ export declare class DrawerManager {
6
+ private static instance;
7
+ private factory;
8
+ private logger;
9
+ private constructor();
10
+ static getInstance(ctx: Context): DrawerManager;
11
+ getDrawer(gameType: TGame | 'core'): import("../types").IDrawer;
12
+ }
13
+ export declare function apply(ctx: Context, config: AppConfig): void;
File without changes
@@ -0,0 +1,4 @@
1
+ import { Context } from "koishi";
2
+ import { SDVXConfig } from "../../types/config";
3
+ export declare const name = "command";
4
+ export declare function apply(ctx: Context, config: SDVXConfig): void;
@@ -0,0 +1,3 @@
1
+ import { Context } from 'koishi';
2
+ import { SDVXConfig } from '../../../types/config';
3
+ export declare function vf(ctx: Context, config: SDVXConfig): void;
@@ -0,0 +1,2 @@
1
+ import { SDVXConfig } from '../../types/config';
2
+ export declare const sdvxConfig: SDVXConfig;
@@ -0,0 +1,3 @@
1
+ import { Context } from "koishi";
2
+ export declare const name = "database";
3
+ export declare function apply(ctx: Context): void;
@@ -0,0 +1,3 @@
1
+ import { Context } from "koishi";
2
+ export declare const name = "event";
3
+ export declare function apply(ctx: Context): void;
@@ -0,0 +1,6 @@
1
+ import { Context, Logger } from "koishi";
2
+ import type { AppConfig } from "../../types/config";
3
+ export declare const name = "Noah-SDVX";
4
+ export declare const inject: string[];
5
+ export declare const logger: Logger;
6
+ export declare function apply(ctx: Context, config: AppConfig): Promise<void>;
File without changes
@@ -0,0 +1,10 @@
1
+ import { Context } from 'koishi';
2
+ import { SDVXMusic } from '../types';
3
+ import { SDVXConfig } from '../../../types/config';
4
+ export declare class MusicService {
5
+ private static instance;
6
+ private sdvx_data_url;
7
+ private constructor();
8
+ static getInstance(config: SDVXConfig): MusicService;
9
+ getMusic(ctx: Context, musicIds: number[]): Promise<SDVXMusic[]>;
10
+ }
@@ -0,0 +1,18 @@
1
+ import { SDVXScore } from '../types';
2
+ export declare class ScoreService {
3
+ private static instance;
4
+ private constructor();
5
+ static getInstance(): ScoreService;
6
+ /**
7
+ * Sort scores by volforce in descending order
8
+ * @param scores Array of SDVX scores to sort
9
+ * @returns New array of scores sorted by volforce (highest to lowest)
10
+ */
11
+ sortByVolforce(scores: SDVXScore[]): SDVXScore[];
12
+ /**
13
+ * Get the top 50 scores by volforce, including ties
14
+ * @param scores Array of SDVX scores to process
15
+ * @returns Array of scores with highest volforce values (may exceed 50 if there are ties)
16
+ */
17
+ getBest50(scores: SDVXScore[]): SDVXScore[];
18
+ }
@@ -0,0 +1,82 @@
1
+ export interface SDVXProfile {
2
+ }
3
+ export interface SDVXScore {
4
+ music: {
5
+ music_id: number;
6
+ music_diff: number;
7
+ music_diff_name: string;
8
+ music_diff_full_name: string;
9
+ score: number;
10
+ exscore: number;
11
+ clear_type: SDVXClearType;
12
+ score_grade: SDVXGrade;
13
+ btn_rate: string;
14
+ long_rate: string;
15
+ vol_rate: string;
16
+ };
17
+ extra: {
18
+ volforce: number;
19
+ play_count: number;
20
+ update_at: string;
21
+ };
22
+ music_data: SDVXMusic;
23
+ difficulty_data: SDVXMusicDifficulty;
24
+ }
25
+ export type SDVXGrade = 'S' | 'AAA+' | 'AAA' | 'AA+' | 'AA' | 'A+' | 'A' | 'B' | 'C' | 'D';
26
+ export type SDVXClearType = 'S-PUC' | 'PUC' | 'UC' | 'HC' | 'NC' | 'PLAYED' | 'NO PLAY';
27
+ export interface SDVXMusicDifficulty {
28
+ difstr: string;
29
+ difnum: number;
30
+ raw_illustrator: string;
31
+ illustrator: string;
32
+ raw_effected_by: string;
33
+ effected_by: string;
34
+ price: number;
35
+ limited: number;
36
+ jacket_print: number;
37
+ jacket_mask: number;
38
+ max_exscore: number;
39
+ max_chain: number;
40
+ chip_count: number;
41
+ hold_count: number;
42
+ tsumami_count: number;
43
+ radar: {
44
+ notes: number;
45
+ peak: number;
46
+ tsumami: number;
47
+ tricky: number;
48
+ hand_trip: number;
49
+ one_hand: number;
50
+ };
51
+ big_cover_url: string;
52
+ cover_url: string;
53
+ chart_url: string;
54
+ mirror_chart_url: string;
55
+ }
56
+ export interface SDVXMusic {
57
+ id: number;
58
+ label: string;
59
+ raw_title_name: string;
60
+ title_name: string;
61
+ main_title_name: string;
62
+ sub_title_name: string;
63
+ title_yomigana: string;
64
+ title_romaji: string;
65
+ raw_artist_name: string;
66
+ artist_name: string;
67
+ artist_yomigana: string;
68
+ artist_romaji: string;
69
+ ascii: string;
70
+ bpm_max: string;
71
+ bpm_min: string;
72
+ distribution_date: string;
73
+ volume: number;
74
+ bg_no: number;
75
+ genre: number;
76
+ genre_name: string;
77
+ is_fixed: number;
78
+ version: number;
79
+ demo_pri: number;
80
+ inf_ver: number;
81
+ difficulty: SDVXMusicDifficulty[];
82
+ }
@@ -0,0 +1,19 @@
1
+ import { SDVXGrade, SDVXClearType, SDVXScore } from '../types';
2
+ /**
3
+ * Calculate volforce based on score, level, grade, and clear type
4
+ * @param raw_score score object from the API
5
+ * @returns The calculated volforce value
6
+ */
7
+ export declare function calculateVolforce(raw_score: SDVXScore): number;
8
+ /**
9
+ * Get grade factor for a given grade
10
+ * @param grade The grade to get the factor for
11
+ * @returns The grade factor
12
+ */
13
+ export declare function getGradeFactor(grade: SDVXGrade): number;
14
+ /**
15
+ * Get clear factor for a given clear type
16
+ * @param clearType The clear type to get the factor for
17
+ * @returns The clear factor
18
+ */
19
+ export declare function getClearFactor(clearType: SDVXClearType): number;
package/lib/index.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import { Context } from 'koishi';
2
+ import type { AppConfig } from "./types/config";
3
+ export declare const name = "noah";
4
+ export declare const inject: string[];
5
+ export * from './config';
6
+ export declare function apply(ctx: Context, config: AppConfig): void;