@kotori-bot/core
Advanced tools
Comparing version 1.4.0 to 1.4.1
@@ -8,3 +8,3 @@ "use strict"; | ||
const tsukiko_1 = __importDefault(require("tsukiko")); | ||
const path_1 = require("path"); | ||
const node_path_1 = require("node:path"); | ||
const tools_1 = require("@kotori-bot/tools"); | ||
@@ -26,3 +26,3 @@ const global_1 = require("../global"); | ||
/* load package.json */ | ||
const info = (0, tools_1.loadConfig)((0, path_1.join)(__dirname, '../../package.json')); | ||
const info = (0, tools_1.loadConfig)((0, node_path_1.join)(__dirname, '../../package.json')); | ||
if (!info || Object.values(info).length === 0) { | ||
@@ -29,0 +29,0 @@ process.stderr.write(`Cannot find kotori-bot package.json\n`); |
@@ -9,3 +9,3 @@ export declare const OFFICIAL_MODULES_SCOPE = "@kotori-bot/"; | ||
global: { | ||
lang: "en_US" | "en_GB" | "en_AU" | "zh_CN" | "zh_HK" | "zh_TW" | "zh_SG" | "es_ES" | "es_MX" | "ar_EG" | "ar_AE" | "ru_RU" | "fr_FR" | "fr_CA" | "de_DE" | "de_CH" | "it_IT" | "it_CH" | "hi_IN" | "pt_BR" | "pt_PT" | "tr_TR" | "ja_JP" | "id_ID" | "uk_UA" | "vi_VN" | "th_TH" | "sv_SE" | "nb_NO" | "da_DK" | "fi_FI" | "he_IL" | "sk_SK" | "bg_BG" | "lt_LT" | "sl_SI" | "sr_RS" | "mk_MK" | "sq_AL" | "et_EE" | "mt_MT"; | ||
lang: "common" | "en_US" | "en_GB" | "en_AU" | "zh_CN" | "zh_HK" | "zh_TW" | "zh_SG" | "es_ES" | "es_MX" | "ar_EG" | "ar_AE" | "ru_RU" | "fr_FR" | "fr_CA" | "de_DE" | "de_CH" | "it_IT" | "it_CH" | "hi_IN" | "pt_BR" | "pt_PT" | "tr_TR" | "ja_JP" | "id_ID" | "uk_UA" | "vi_VN" | "th_TH" | "sv_SE" | "nb_NO" | "da_DK" | "fi_FI" | "he_IL" | "sk_SK" | "bg_BG" | "lt_LT" | "sl_SI" | "sr_RS" | "mk_MK" | "sq_AL" | "et_EE" | "mt_MT"; | ||
'command-prefix': string; | ||
@@ -12,0 +12,0 @@ port: number; |
@@ -8,2 +8,3 @@ export * from 'fluoro'; | ||
export * from './utils/container'; | ||
export * from './utils/factory'; | ||
export * from './global'; | ||
@@ -10,0 +11,0 @@ export * from './types'; |
@@ -31,2 +31,3 @@ "use strict"; | ||
__exportStar(require("./utils/container"), exports); | ||
__exportStar(require("./utils/factory"), exports); | ||
__exportStar(require("./global"), exports); | ||
@@ -33,0 +34,0 @@ __exportStar(require("./types"), exports); |
@@ -7,3 +7,2 @@ "use strict"; | ||
exports.Adapter = void 0; | ||
const tools_1 = require("@kotori-bot/tools"); | ||
const types_1 = require("../types"); | ||
@@ -48,20 +47,2 @@ const elements_1 = __importDefault(require("./elements")); | ||
} | ||
function formatFactory(i18n) { | ||
return (template, data) => { | ||
const params = data; | ||
if (Array.isArray(params)) { | ||
let str = i18n.locale(template); | ||
params.forEach((value, index) => { | ||
str = str.replaceAll(`{${index}}`, i18n.locale(typeof value === 'string' ? value : String(value))); | ||
}); | ||
return str; | ||
} | ||
Object.keys(params).forEach((key) => { | ||
if (typeof params[key] !== 'string') | ||
params[key] = String(params[key]); | ||
params[key] = i18n.locale(params[key]); | ||
}); | ||
return (0, tools_1.stringTemp)(i18n.locale(template), params); | ||
}; | ||
} | ||
function quickFactory(send, i18n) { | ||
@@ -76,3 +57,3 @@ return async (message) => { | ||
} | ||
send(formatFactory(i18n)(...msg)); | ||
send((0, factory_1.formatFactory)(i18n)(...msg)); | ||
}; | ||
@@ -144,3 +125,3 @@ } | ||
const send = sendMessageFactory(this, type, data); | ||
const format = formatFactory(i18n); | ||
const format = (0, factory_1.formatFactory)(i18n); | ||
const quick = quickFactory(send, i18n); | ||
@@ -147,0 +128,0 @@ const prompt = promptFactory(quick, this, data); |
@@ -0,2 +1,4 @@ | ||
import I18n from '@kotori-bot/i18n/src/common'; | ||
import type { Context } from 'fluoro'; | ||
import { CommandArgType } from '..'; | ||
export declare function disposeFactory(ctx: Context, dispose: () => void): void; | ||
@@ -8,1 +10,2 @@ export declare function cancelFactory(): { | ||
}; | ||
export declare function formatFactory(i18n: I18n): (template: string, data: Record<string, unknown> | CommandArgType[]) => string; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.cancelFactory = exports.disposeFactory = void 0; | ||
exports.formatFactory = exports.cancelFactory = exports.disposeFactory = void 0; | ||
const __1 = require(".."); | ||
function disposeFactory(ctx, dispose) { | ||
@@ -26,1 +27,20 @@ ctx.once('dispose_module', (data) => { | ||
exports.cancelFactory = cancelFactory; | ||
function formatFactory(i18n) { | ||
return (template, data) => { | ||
const params = data; | ||
if (Array.isArray(params)) { | ||
let str = i18n.locale(template); | ||
params.forEach((value, index) => { | ||
str = str.replaceAll(`{${index}}`, i18n.locale(typeof value === 'string' ? value : String(value))); | ||
}); | ||
return str; | ||
} | ||
Object.keys(params).forEach((key) => { | ||
if (typeof params[key] !== 'string') | ||
params[key] = String(params[key]); | ||
params[key] = i18n.locale(params[key]); | ||
}); | ||
return (0, __1.stringTemp)(i18n.locale(template), params); | ||
}; | ||
} | ||
exports.formatFactory = formatFactory; |
{ | ||
"name": "@kotori-bot/core", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"description": "Kotori Core", | ||
@@ -30,5 +30,5 @@ "main": "lib/index.js", | ||
"tsukiko": "^1.2.1", | ||
"@kotori-bot/i18n": "^1.2.1", | ||
"@kotori-bot/tools": "^1.3.0", | ||
"fluoro": "^1.0.0" | ||
"@kotori-bot/i18n": "^1.3.0", | ||
"@kotori-bot/tools": "^1.3.1", | ||
"fluoro": "^1.0.1" | ||
}, | ||
@@ -35,0 +35,0 @@ "scripts": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
122999
2332
Updated@kotori-bot/i18n@^1.3.0
Updated@kotori-bot/tools@^1.3.1
Updatedfluoro@^1.0.1