@tb-eng/sendkit 0.0.0 → 0.0.2

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/Readme.md ADDED
@@ -0,0 +1,89 @@
1
+ # @tb-eng/sendkit
2
+
3
+ CLI for sending Telegram messages.
4
+
5
+ SendKit lets you send Telegram messages directly from your terminal.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install -g @tb-eng/sendkit
11
+ ```
12
+
13
+ Or run without installation:
14
+
15
+ ```bash
16
+ npx @tb-eng/sendkit
17
+ ```
18
+
19
+ ## Setup
20
+
21
+ Configure your Telegram bot token once:
22
+
23
+ ```bash
24
+ sendkit init --telegram-bot-token <botToken>
25
+ ```
26
+
27
+ The token is stored locally in:
28
+
29
+ ```txt
30
+ ~/.config/sendkit/config.json
31
+ ```
32
+
33
+ ## Send a message
34
+
35
+ ```bash
36
+ sendkit telegram <chatId> <message>
37
+ ```
38
+
39
+ Example:
40
+
41
+ ```bash
42
+ sendkit telegram 123456789 "Hello from SendKit 🚀"
43
+ ```
44
+
45
+ Response:
46
+
47
+ ```json
48
+ {
49
+ "ok": true,
50
+ "chatId": "123456789",
51
+ "messageId": 42
52
+ }
53
+ ```
54
+
55
+ ## Commands
56
+
57
+ ### Initialize configuration
58
+
59
+ ```bash
60
+ sendkit init --telegram-bot-token <botToken>
61
+ ```
62
+
63
+ ### Send Telegram message
64
+
65
+ ```bash
66
+ sendkit telegram <chatId> <message>
67
+ ```
68
+
69
+ ## Troubleshooting
70
+
71
+ ### Telegram bot token is required
72
+
73
+ Run:
74
+
75
+ ```bash
76
+ sendkit init --telegram-bot-token <botToken>
77
+ ```
78
+
79
+ ### Chat not found
80
+
81
+ Ensure:
82
+
83
+ * The chat ID is correct.
84
+ * The user has started the bot.
85
+ * The bot has permission to send messages.
86
+
87
+ ## License
88
+
89
+ MIT
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 messages to Telegram groups and channels.").command("telegram").argument("<chatId>", "Telegram chatId").argument("<message>", "Message text to send").action(async (chatId, message) => {
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 messages 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,qDAAqD,CAAC,CAClE,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"}
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tb-eng/sendkit",
3
- "version": "0.0.0",
3
+ "version": "0.0.2",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "sendkit": "./dist/index.js"
package/src/index.ts CHANGED
@@ -41,7 +41,7 @@ program
41
41
 
42
42
  program
43
43
  .name("telegram")
44
- .description("SendKit a messages to Telegram groups and channels.")
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")