pi-telegram-notifier 0.1.3 → 0.1.4

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 CHANGED
@@ -12,7 +12,7 @@ export PI_TELEGRAM_BOT_TOKEN='your-bot-token'
12
12
  pi
13
13
  ```
14
14
 
15
- If Pi is already running, run `/reload` after installing the package (restart Pi if you just set the token). If you previously installed a local checkout, run `pi list`, then `pi remove /absolute/path/to/pi-telegram-notifier` to avoid loading both copies. To get future releases, run `pi update npm:pi-telegram-notifier`. In Pi run `/telegram-pair`. Within five minutes send **`/start <code>`** to your bot in a private Telegram chat using the displayed one-time code. The extension stores only the numeric chat ID in `~/.pi/agent/pi-telegram-notifier.json` (or `$PI_CODING_AGENT_DIR/pi-telegram-notifier.json`), with mode 0600. To switch chats, run `/telegram-pair` again; the existing chat stays paired if pairing fails. The bot needs to receive messages via `getUpdates` during pairing: a webhook or another updates consumer must be disconnected first. There is no always-on polling after pairing.
15
+ If Pi is already running, run `/reload` after installing the package (restart Pi if you just set the token). If you previously installed a local checkout, run `pi list`, then `pi remove /absolute/path/to/pi-telegram-notifier` to avoid loading both copies. To get future releases, run `pi update npm:pi-telegram-notifier`. In Pi run `/telegram-pair`. Use `/telegram-status` to see whether the bot token is configured and a private chat is paired; it reports local state and does not verify live Telegram connectivity. Within five minutes send **`/start <code>`** to your bot in a private Telegram chat using the displayed one-time code. The extension stores only the numeric chat ID in `~/.pi/agent/pi-telegram-notifier.json` (or `$PI_CODING_AGENT_DIR/pi-telegram-notifier.json`), with mode 0600. To switch chats, run `/telegram-pair` again; the existing chat stays paired if pairing fails. The bot needs to receive messages via `getUpdates` during pairing: a webhook or another updates consumer must be disconnected first. There is no always-on polling after pairing.
16
16
 
17
17
  **Privacy:** final agent responses and the device hostname are sent to Telegram. Responses can contain sensitive text; only use this package if that is acceptable for your projects and Telegram chat. Bot and provider tokens are not stored in the package or sent as message text. Telegram Bot API uses the bot token in the request URL; do not log outgoing URLs. Keep your shell environment and Pi credentials private. A lost or compromised Telegram bot token must be revoked with BotFather.
18
18
 
@@ -2,13 +2,28 @@ import { randomBytes } from 'node:crypto';
2
2
  import { homedir } from 'node:os';
3
3
  import { join } from 'node:path';
4
4
  import type { ExtensionAPI } from '@earendil-works/pi-coding-agent';
5
- import { pairChat, saveChatId } from '#src/telegram';
5
+ import { loadChatId, pairChat, saveChatId } from '#src/telegram';
6
6
  import { registerNotifications } from '#src/notification';
7
7
 
8
8
  const agentDir = () => process.env.PI_CODING_AGENT_DIR || join(homedir(), '.pi', 'agent');
9
9
 
10
10
  export default function (pi: ExtensionAPI) {
11
11
  registerNotifications(pi, agentDir(), process.env.PI_TELEGRAM_BOT_TOKEN);
12
+ pi.registerCommand('telegram-status', {
13
+ description: 'Show the Telegram bot configuration and pairing status',
14
+ handler: async (_args, ctx) => {
15
+ const tokenConfigured = !!process.env.PI_TELEGRAM_BOT_TOKEN;
16
+ const paired = loadChatId(agentDir()) !== undefined;
17
+ ctx.ui.notify([
18
+ 'Telegram status',
19
+ `Bot token: ${tokenConfigured ? 'configured' : 'not configured'}`,
20
+ `Private chat: ${paired ? 'paired' : 'not paired'}`,
21
+ 'Live connectivity: not checked',
22
+ !tokenConfigured ? 'Set PI_TELEGRAM_BOT_TOKEN and restart Pi.' : '',
23
+ !paired ? 'Run /telegram-pair to pair a private chat.' : '',
24
+ ].filter(Boolean).join('\n'), 'info');
25
+ },
26
+ });
12
27
  pi.registerCommand('telegram-pair', {
13
28
  description: 'Pair a private Telegram chat with this Pi installation',
14
29
  handler: async (_args, ctx) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-telegram-notifier",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Telegram notifications for final Pi agent responses and provider balances",
5
5
  "type": "module",
6
6
  "license": "MIT",