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,11 @@
1
+ import { Logger } from "koishi";
2
+ import { GameService, IServer, TGame, TServer } from '../../types';
3
+ export declare class Asphyxia implements IServer {
4
+ name: TServer;
5
+ supportedGames: TGame[];
6
+ gameServices: {
7
+ [key in TGame]?: GameService;
8
+ };
9
+ logger: Logger;
10
+ constructor();
11
+ }
@@ -0,0 +1,9 @@
1
+ import { Logger } from 'koishi';
2
+ import { GameService } from '../../../types';
3
+ export declare class IIDXService implements GameService {
4
+ private static instance;
5
+ logger: Logger;
6
+ private constructor();
7
+ static getInstance(logger: Logger): IIDXService;
8
+ fetchData(url: string): Promise<void>;
9
+ }
@@ -0,0 +1,12 @@
1
+ import { Context, Logger } from 'koishi';
2
+ import { GameService, SDVXScore } from "../../../types";
3
+ import { SDVXProfile } from '../../../games/sdvx/types';
4
+ export declare class SDVXService implements GameService {
5
+ private static instance;
6
+ logger: Logger;
7
+ private constructor();
8
+ static getInstance(logger: Logger): SDVXService;
9
+ private fetchRefid;
10
+ fetchProfile(ctx: Context, url: string, model: string, card: string): Promise<SDVXProfile>;
11
+ fetchScore(ctx: Context, url: string, model: string, card: string): Promise<SDVXScore>;
12
+ }
@@ -0,0 +1,11 @@
1
+ import { Logger } from "koishi";
2
+ import { IServer, TGame, TServer, GameService } from '../../types';
3
+ export declare class Mao implements IServer {
4
+ name: TServer;
5
+ supportedGames: TGame[];
6
+ gameServices: {
7
+ [key in TGame]?: GameService;
8
+ };
9
+ logger: Logger;
10
+ constructor();
11
+ }
@@ -0,0 +1,19 @@
1
+ import { Context, Logger } from 'koishi';
2
+ import { SDVXService as ISDVXService } from "../../../types";
3
+ import { SDVXScore } from '../../../games/sdvx/types';
4
+ import { SDVXConfig } from '../../../types/config';
5
+ export declare class SDVXService implements ISDVXService {
6
+ private static instance;
7
+ logger: Logger;
8
+ private constructor();
9
+ static getInstance(logger: Logger): SDVXService;
10
+ /**
11
+ * Get the difficulty string based on the difficulty type number
12
+ * @param diffType Difficulty type (0-4)
13
+ * @returns The difficulty string (novice, advanced, exhaust, infinite, maximum)
14
+ */
15
+ private getDifficultyString;
16
+ getAllScore(ctx: Context, url: string, cardId: string, config: SDVXConfig): Promise<SDVXScore[]>;
17
+ getScore(ctx: Context, url: string, cardId: string, musicId: number, config: SDVXConfig): Promise<SDVXScore>;
18
+ getRecentScores(ctx: Context, url: string, cardId: string, count: number, config: SDVXConfig): Promise<SDVXScore[]>;
19
+ }
@@ -0,0 +1,5 @@
1
+ import { IServer, TServer } from '../types';
2
+ export declare class ServerFactory {
3
+ private serverInstances;
4
+ getServer(serverType: TServer): IServer;
5
+ }
File without changes
@@ -0,0 +1,13 @@
1
+ import type { AppConfig } from "../types/config";
2
+ import { TServer, TGame } from '../types';
3
+ import { Context } from "koishi";
4
+ export declare const name = "Noah-Server";
5
+ export declare class ServerManager {
6
+ private static instance;
7
+ private factory;
8
+ private constructor();
9
+ static getInstance(): ServerManager;
10
+ getServer(serverType: TServer): import("../types").IServer;
11
+ getGameService(serverType: TServer, gameType: TGame): import("../types").GameService;
12
+ }
13
+ export declare function apply(ctx: Context, config: AppConfig): void;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Get the abbreviated difficulty name based on the difficulty type and infinite version
3
+ * @param diffStr The difficulty string (novice, advanced, exhaust, infinite, maximum)
4
+ * @param infVer The infinite version (2-6)
5
+ * @returns The abbreviated difficulty name (e.g., "NOV", "ADV", "INF", "GRV", etc.)
6
+ */
7
+ export declare function getDiffName(diffStr: string, infVer: string | number): string;
8
+ /**
9
+ * Get the full difficulty name based on the difficulty type and infinite version
10
+ * @param diffStr The difficulty string (novice, advanced, exhaust, infinite, maximum)
11
+ * @param infVer The infinite version (2-6)
12
+ * @returns The full difficulty name (e.g., "NOVICE", "ADVANCED", "INFINITE", etc.)
13
+ */
14
+ export declare function getDiffFullName(diffStr: string, infVer: string | number): string;
@@ -0,0 +1,3 @@
1
+ import { SDVXClearType, SDVXGrade } from "../../games/sdvx/types";
2
+ export declare function getSDVXGrade(score: number): SDVXGrade;
3
+ export declare function getSDVXClearType(clearType: number): SDVXClearType;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * 将 XML 字符串转换为 JSON。
3
+ *
4
+ * @param xml - 一个 XML 格式的字符串
5
+ * @returns 返回一个 Promise,其中解析后的 JSON 对象
6
+ */
7
+ export declare const xmlToJson: (xml: string) => Promise<any>;
8
+ /**
9
+ * 将 JSON 对象转换为 XML 字符串。
10
+ *
11
+ * @param json - 一个 JavaScript 对象,表示要转换的 JSON 数据
12
+ * @returns 返回 XML 格式的字符串
13
+ */
14
+ export declare const jsonToXml: (json: any) => string;
@@ -0,0 +1,13 @@
1
+ export interface BaseConfig {
2
+ }
3
+ export interface CoreConfig extends BaseConfig {
4
+ adminUsers?: string[];
5
+ }
6
+ export interface SDVXConfig extends BaseConfig {
7
+ default_model: string;
8
+ sdvx_data_url: string;
9
+ }
10
+ export interface AppConfig {
11
+ core: CoreConfig;
12
+ sdvx: SDVXConfig;
13
+ }
@@ -0,0 +1,66 @@
1
+ import { Context, Logger } from 'koishi';
2
+ import { SDVXConfig } from './config';
3
+ import { SDVXScore } from '../games/sdvx/types';
4
+ export type TServer = 'asphyxia' | 'mao';
5
+ export declare const serverValues: TServer[];
6
+ export type TGame = 'sdvx' | 'iidx' | 'ddr' | 'gitadora' | 'jubeat' | 'mga' | 'museca' | 'nostalgia' | 'popn' | 'bst';
7
+ export declare const gameValues: readonly ["sdvx", "iidx", "ddr", "gitadora", "jubeat", "mga", "museca", "nostalgia", "popn", "bst"];
8
+ /**
9
+ * Base interface for all game services
10
+ * Provides common functionality and properties that all game services must implement
11
+ */
12
+ export interface GameService {
13
+ /** Logger instance for service-specific logging */
14
+ logger: Logger;
15
+ }
16
+ /**
17
+ * Service interface for Sound Voltex (SDVX) game operations
18
+ * Extends the base GameService with SDVX-specific functionality
19
+ */
20
+ export interface SDVXService extends GameService {
21
+ /**
22
+ * Retrieve all scores for a specific card
23
+ * @param url - Base URL of the SDVX service
24
+ * @param cardId - ID of the player's card
25
+ * @returns Promise resolving to an array of SDVX scores
26
+ * @throws Error if the fetch operation fails
27
+ */
28
+ getAllScore(ctx: Context, url: string, cardId: string, config: SDVXConfig): Promise<SDVXScore[]>;
29
+ /**
30
+ * Retrieve score for a specific music ID
31
+ * @param url - Base URL of the SDVX service
32
+ * @param cardId - ID of the player's card
33
+ * @param musicId - ID of the music track
34
+ * @param config - SDVX configuration settings
35
+ * @returns Promise resolving to a single SDVX score
36
+ * @throws Error if the fetch operation fails
37
+ */
38
+ getScore(ctx: Context, url: string, cardId: string, musicId: number, config: SDVXConfig): Promise<SDVXScore>;
39
+ /**
40
+ * Retrieve recent scores for a card
41
+ * @param url - Base URL of the SDVX service
42
+ * @param cardId - ID of the player's card
43
+ * @param count - Number of recent scores to retrieve (optional, defaults to 1)
44
+ * @param config - SDVX configuration settings (optional)
45
+ * @returns Promise resolving to an array of recent SDVX scores
46
+ * @throws Error if the fetch operation fails
47
+ */
48
+ getRecentScores(ctx: Context, url: string, cardId: string, count?: number, config?: SDVXConfig): Promise<SDVXScore[]>;
49
+ }
50
+ export interface IServer {
51
+ name: TServer;
52
+ supportedGames: TGame[];
53
+ gameServices: {
54
+ [key in TGame]?: GameService;
55
+ };
56
+ logger: Logger;
57
+ }
58
+ /**
59
+ * Base interface for all drawer services
60
+ * Provides common drawing functionality for different game types
61
+ */
62
+ export interface IDrawer {
63
+ /** Context for using Koishi functionality */
64
+ ctx: Context;
65
+ }
66
+ export { SDVXScore };
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "koishi-plugin-noah",
3
+ "version": "1.0.0",
4
+ "contributors": [
5
+ "Logthm <logthm@outlook.com>"
6
+ ],
7
+ "homepage": "https://docs.logthm.com/noah",
8
+ "main": "lib/index.js",
9
+ "typings": "lib/index.d.ts",
10
+ "files": [
11
+ "lib",
12
+ "dist"
13
+ ],
14
+ "license": "MIT",
15
+ "keywords": [
16
+ "chatbot",
17
+ "koishi",
18
+ "plugin"
19
+ ],
20
+ "peerDependencies": {
21
+ "koishi": "^4.18.7"
22
+ },
23
+ "dependencies": {
24
+ "sharp": "^0.33.5",
25
+ "xml2js": "^0.6.2"
26
+ },
27
+ "koishi": {
28
+ "description": {
29
+ "en": "Multifunctional, multi-platform-supported arcade music game tool bot.",
30
+ "zh": "多功能,多平台支持的街机音游工具机器人。"
31
+ },
32
+ "service": {
33
+ "required": [
34
+ "database",
35
+ "skia"
36
+ ]
37
+ },
38
+ "locales": [
39
+ "en",
40
+ "zh"
41
+ ]
42
+ },
43
+ "devDependencies": {
44
+ "@ltxhhz/koishi-plugin-skia-canvas": "^0.0.8",
45
+ "@types/xml2js": "^0"
46
+ }
47
+ }
package/readme.md ADDED
@@ -0,0 +1,5 @@
1
+ # koishi-plugin-noah
2
+
3
+ [![npm](https://img.shields.io/npm/v/koishi-plugin-noah?style=flat-square)](https://www.npmjs.com/package/koishi-plugin-noah)
4
+
5
+ undefined