@tb-eng/sendkit 0.0.0 → 0.0.1
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.
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -23,7 +23,7 @@ program.name("sendkit").description("SendKit CLI backed by sendkit-core.");
|
|
|
23
23
|
program.command("init").description("Configure SendKit CLI local settings").requiredOption("--telegram-bot-token <botToken>", "Telegram bot token").action(async (options) => {
|
|
24
24
|
writeTelegramBotToken(options.telegramBotToken);
|
|
25
25
|
});
|
|
26
|
-
program.name("telegram").description("SendKit a
|
|
26
|
+
program.name("telegram").description("SendKit send a message to Telegram groups and channels.").command("telegram").argument("<chatId>", "Telegram chatId").argument("<message>", "Message text to send").action(async (chatId, message) => {
|
|
27
27
|
const token = getTelegramBotToken();
|
|
28
28
|
if (!chatId || !message) {
|
|
29
29
|
console.error("ChatId and message are required");
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { Command } from \"commander\";\nimport { sendTelegramMessage } from \"@tb-eng/sendkit-core\";\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { dirname, join } from \"node:path\";\n\nconst program = new Command();\nconst configPath = join(homedir(), \".config\", \"sednkit\", \"config.json\");\n\nfunction writeTelegramBotToken(token: string) {\n mkdirSync(dirname(configPath), { recursive: true });\n writeFileSync(configPath, `${JSON.stringify({ telegramBotToken: token }, null, 2)}\\n`, {\n mode: 0o600,\n });\n console.log(`Telegram bot token saved successfully at ${configPath}`);\n}\nfunction getTelegramBotToken() {\n if (!existsSync(configPath)) {\n throw new Error(\"Telegram bot token is required. Run `sendkit init.`\");\n }\n\n const config = JSON.parse(readFileSync(configPath, \"utf8\"));\n const token = config.telegramBotToken;\n\n if (!config || !token) {\n throw new Error(\"Telegram bot token is required. Run `sendkit init.`\");\n }\n\n return token;\n}\n\nprogram.name(\"sendkit\").description(\"SendKit CLI backed by sendkit-core.\");\nprogram\n .command(\"init\")\n .description(\"Configure SendKit CLI local settings\")\n .requiredOption(\"--telegram-bot-token <botToken>\", \"Telegram bot token\")\n .action(async (options: { telegramBotToken: string }) => {\n writeTelegramBotToken(options.telegramBotToken);\n });\n\nprogram\n .name(\"telegram\")\n .description(\"SendKit a
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { Command } from \"commander\";\nimport { sendTelegramMessage } from \"@tb-eng/sendkit-core\";\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { dirname, join } from \"node:path\";\n\nconst program = new Command();\nconst configPath = join(homedir(), \".config\", \"sednkit\", \"config.json\");\n\nfunction writeTelegramBotToken(token: string) {\n mkdirSync(dirname(configPath), { recursive: true });\n writeFileSync(configPath, `${JSON.stringify({ telegramBotToken: token }, null, 2)}\\n`, {\n mode: 0o600,\n });\n console.log(`Telegram bot token saved successfully at ${configPath}`);\n}\nfunction getTelegramBotToken() {\n if (!existsSync(configPath)) {\n throw new Error(\"Telegram bot token is required. Run `sendkit init.`\");\n }\n\n const config = JSON.parse(readFileSync(configPath, \"utf8\"));\n const token = config.telegramBotToken;\n\n if (!config || !token) {\n throw new Error(\"Telegram bot token is required. Run `sendkit init.`\");\n }\n\n return token;\n}\n\nprogram.name(\"sendkit\").description(\"SendKit CLI backed by sendkit-core.\");\nprogram\n .command(\"init\")\n .description(\"Configure SendKit CLI local settings\")\n .requiredOption(\"--telegram-bot-token <botToken>\", \"Telegram bot token\")\n .action(async (options: { telegramBotToken: string }) => {\n writeTelegramBotToken(options.telegramBotToken);\n });\n\nprogram\n .name(\"telegram\")\n .description(\"SendKit send a message to Telegram groups and channels.\")\n .command(\"telegram\")\n .argument(\"<chatId>\", \"Telegram chatId\")\n .argument(\"<message>\", \"Message text to send\")\n .action(async (chatId: string, message: string) => {\n const token = getTelegramBotToken();\n\n if (!chatId || !message) {\n console.error(\"ChatId and message are required\");\n process.exit(1);\n }\n\n try {\n const result = await sendTelegramMessage({\n botToken: token,\n chatId,\n message,\n });\n console.log(JSON.stringify(result));\n } catch (error) {\n console.error(\"Failed to send telegram message: \", error);\n process.exit(1);\n }\n });\nawait program.parseAsync(process.argv).catch((e) => {\n console.error(e instanceof Error ? e.message : String(e));\n process.exit(1);\n});\n"],"mappings":";;;;;;;AAOA,MAAM,UAAU,IAAI,QAAQ;AAC5B,MAAM,aAAa,KAAK,QAAQ,GAAG,WAAW,WAAW,aAAa;AAEtE,SAAS,sBAAsB,OAAe;CAC5C,UAAU,QAAQ,UAAU,GAAG,EAAE,WAAW,KAAK,CAAC;CAClD,cAAc,YAAY,GAAG,KAAK,UAAU,EAAE,kBAAkB,MAAM,GAAG,MAAM,CAAC,EAAE,KAAK,EACrF,MAAM,IACR,CAAC;CACD,QAAQ,IAAI,4CAA4C,YAAY;AACtE;AACA,SAAS,sBAAsB;CAC7B,IAAI,CAAC,WAAW,UAAU,GACxB,MAAM,IAAI,MAAM,qDAAqD;CAGvE,MAAM,SAAS,KAAK,MAAM,aAAa,YAAY,MAAM,CAAC;CAC1D,MAAM,QAAQ,OAAO;CAErB,IAAI,CAAC,UAAU,CAAC,OACd,MAAM,IAAI,MAAM,qDAAqD;CAGvE,OAAO;AACT;AAEA,QAAQ,KAAK,SAAS,CAAC,CAAC,YAAY,qCAAqC;AACzE,QACG,QAAQ,MAAM,CAAC,CACf,YAAY,sCAAsC,CAAC,CACnD,eAAe,mCAAmC,oBAAoB,CAAC,CACvE,OAAO,OAAO,YAA0C;CACvD,sBAAsB,QAAQ,gBAAgB;AAChD,CAAC;AAEH,QACG,KAAK,UAAU,CAAC,CAChB,YAAY,yDAAyD,CAAC,CACtE,QAAQ,UAAU,CAAC,CACnB,SAAS,YAAY,iBAAiB,CAAC,CACvC,SAAS,aAAa,sBAAsB,CAAC,CAC7C,OAAO,OAAO,QAAgB,YAAoB;CACjD,MAAM,QAAQ,oBAAoB;CAElC,IAAI,CAAC,UAAU,CAAC,SAAS;EACvB,QAAQ,MAAM,iCAAiC;EAC/C,QAAQ,KAAK,CAAC;CAChB;CAEA,IAAI;EACF,MAAM,SAAS,MAAM,oBAAoB;GACvC,UAAU;GACV;GACA;EACF,CAAC;EACD,QAAQ,IAAI,KAAK,UAAU,MAAM,CAAC;CACpC,SAAS,OAAO;EACd,QAAQ,MAAM,qCAAqC,KAAK;EACxD,QAAQ,KAAK,CAAC;CAChB;AACF,CAAC;AACH,MAAM,QAAQ,WAAW,QAAQ,IAAI,CAAC,CAAC,OAAO,MAAM;CAClD,QAAQ,MAAM,aAAa,QAAQ,EAAE,UAAU,OAAO,CAAC,CAAC;CACxD,QAAQ,KAAK,CAAC;AAChB,CAAC"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -41,7 +41,7 @@ program
|
|
|
41
41
|
|
|
42
42
|
program
|
|
43
43
|
.name("telegram")
|
|
44
|
-
.description("SendKit a
|
|
44
|
+
.description("SendKit send a message to Telegram groups and channels.")
|
|
45
45
|
.command("telegram")
|
|
46
46
|
.argument("<chatId>", "Telegram chatId")
|
|
47
47
|
.argument("<message>", "Message text to send")
|