Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
- `npm run build`: Currently a no-op placeholder—extend it only if a transpile/bundle step is introduced.
- `npm test`: Placeholder that echoes a notice; replace with real checks once tests exist.

## SKILL.md Maintenance
- **ALWAYS** update `SKILL.md` when changing the CLI interface: adding/removing/renaming flags, commands, or options.
- Keep the "Core Command Patterns" section in `SKILL.md` in sync with actual CLI capabilities.
- Add usage examples for new flags in the relevant command section.

## Coding Style & Naming Conventions
- Use ES modules with semicolons, two-space indentation, and `camelCase` identifiers.
- Keep tool names descriptive and aligned with Telegram operations (`listChannels`, `searchChannels`, etc.).
Expand Down
1 change: 1 addition & 0 deletions SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ Both positional query and `--query` flag work. `--chat` accepts multiple values.
tgcli send text --to <id|@username> --message "Hello" --json --timeout 30s
tgcli send text --to <id|@username> --topic <topicId> --message "**Hello**" --parse-mode markdown --json --timeout 30s
tgcli send text --to <id|@username> --message "Done" --reply-to <messageId> --json --timeout 30s
tgcli send text --to <id|@username> --message "https://example.com check this" --no-preview --json --timeout 30s

tgcli send file --to <id|@username> --file /path/to/file --caption "Report" --json --timeout 30s
tgcli send file --to <id|@username> --file /path/to/file --caption "<b>Report</b>" --parse-mode html --json --timeout 30s
Expand Down
2 changes: 2 additions & 0 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ function buildProgram() {
.option('--parse-mode <mode>', 'Parse mode: markdown|html|none')
.option('--topic <id>', 'Forum topic id')
.option('--reply-to <id>', 'Reply to message id')
.option('--no-preview', 'Disable link preview')
.action(withGlobalOptions((globalFlags, options) => runSendText(globalFlags, options)));
send
.command('file')
Expand Down Expand Up @@ -2706,6 +2707,7 @@ async function runSendText(globalFlags, options = {}) {
topicId,
replyToMessageId,
parseMode,
noPreview: options.noPreview,
});
const payload = { channelId: options.to, ...result };

Expand Down
3 changes: 2 additions & 1 deletion docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,13 @@ MCP: disabled by default (set `mcp.enabled` in config.json to true to serve MCP)
- messages context --chat <id> --id <msgId> [--before N] [--after N] [--source]

## send
- send text --to <id|username> --message "..." [--parse-mode markdown|html|none] [--topic] [--reply-to <messageId>]
- send text --to <id|username> --message "..." [--parse-mode markdown|html|none] [--topic] [--reply-to <messageId>] [--no-preview]
- send file --to <id|username> --file PATH [--caption] [--filename] [--parse-mode markdown|html|none] [--topic] [--reply-to <messageId>]
- `--parse-mode` is case-insensitive on input.
- Allowed values: `markdown`, `html`, `none`.
- For `send file`, `--parse-mode` requires `--caption`.
- If both `--reply-to` and `--topic` are passed, `--reply-to` takes precedence.
- `--no-preview` disables automatic link preview (applies to `send text` only).

## media
- media download --chat <id|username> --id <msgId> [--output PATH]
Expand Down
7 changes: 6 additions & 1 deletion mcp-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,10 @@ const messagesSendSchema = {
.positive()
.optional()
.describe("Optional message ID to reply to"),
noPreview: z
.boolean({ invalid_type_error: "noPreview must be a boolean" })
.optional()
.describe("Disable link preview in the message"),
};

const messagesSendFileSchema = {
Expand Down Expand Up @@ -1327,11 +1331,12 @@ function createServerInstance() {
"messagesSend",
"Sends a text message to a channel or chat.",
messagesSendSchema,
async ({ channelId, text, topicId, replyToMessageId }) => {
async ({ channelId, text, topicId, replyToMessageId, noPreview }) => {
await telegramClient.ensureLogin();
const result = await telegramClient.sendTextMessage(channelId, text, {
topicId,
replyToMessageId,
noPreview,
});

return {
Expand Down
7 changes: 5 additions & 2 deletions telegram-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -893,9 +893,12 @@ class TelegramClient {
const replyTo = Number.isFinite(options.replyToMessageId)
? options.replyToMessageId
: (Number.isFinite(options.topicId) ? options.topicId : undefined);
const params = replyTo ? { replyTo } : undefined;
const params = {};
if (replyTo) params.replyTo = replyTo;
if (options.noPreview) params.noWebpage = true;
const peerRef = normalizeChannelId(channelId);
const sent = await this.client.sendText(peerRef, inputText, params);
const finalParams = Object.keys(params).length ? params : undefined;
const sent = await this.client.sendText(peerRef, inputText, finalParams);
return { messageId: sent.id };
}

Expand Down