Skip to content

Commit a5ddeab

Browse files
kawaiipantsuclaude
andcommitted
Version 0.7.0 - Message Sending & Token Annotation
Added comprehensive message sending system with advanced formatting options and token annotation capabilities. Features: - Token annotation: --note option to add context to validated tokens - Message sending: --send-message with full formatting support - Formatting modes: Markdown, MarkdownV2, and HTML - Delivery options: --silent (no notifications) and --nopreview - Complete documentation in FORMATTING.md Technical changes: - Extended TelegramApi::sendMessage() with parse_mode and delivery options - Added URL encoding for message text - Updated Config::saveTokenSeen() to support optional notes - New argument parsing for --note, --parse-mode, --silent, --nopreview 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 17c3023 commit a5ddeab

File tree

9 files changed

+686
-9
lines changed

9 files changed

+686
-9
lines changed

.claude/settings.local.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,14 @@
1717
"WebFetch(domain:core.telegram.org)",
1818
"Bash(TGDIGGER_TOKEN=\"123456789:ABCdefGHIjklMNOpqrsTUVwxyz-1234567890\" ./bin/telegramdigger --analyze)",
1919
"Bash(TGDIGGER_TOKEN=\"123456789:ABCdefGHIjklMNOpqrsTUVwxyz-1234567890\" ./bin/telegramdigger --analyze --groupid invalid)",
20-
"Bash(TGDIGGER_TOKEN=\"123456789:ABCdefGHIjklMNOpqrsTUVwxyz-1234567890\" ./bin/telegramdigger:*)"
20+
"Bash(TGDIGGER_TOKEN=\"123456789:ABCdefGHIjklMNOpqrsTUVwxyz-1234567890\" ./bin/telegramdigger:*)",
21+
"Bash(TGDIGGER_TOKEN=\"123456789:ABCdefGHIjklMNOpqrsTUVwxyz-1234567890\" ./bin/telegramdigger --validate --note \"Found on production server\")",
22+
"Bash(if [ -f ~/.telegramdigger/tokens-seen ])",
23+
"Bash(then cat ~/.telegramdigger/tokens-seen)",
24+
"Bash(else echo \"No tokens-seen file exists yet\")",
25+
"Bash(fi)",
26+
"Bash(git tag:*)",
27+
"Bash(git add:*)"
2128
]
2229
}
2330
}

CHANGELOG.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,75 @@ All notable changes to TelegramDigger will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.7.0] - 2026-01-07
9+
10+
### Added
11+
12+
#### Token Annotation System
13+
- **`--note` option** for `--validate` command
14+
- Add custom notes to tokens in the tokens-seen file
15+
- Notes appended as third field in CSV format: `token#timestamp#note`
16+
- Useful for tracking token sources and context
17+
- Example: `--validate --token TOKEN --note "Found on production server"`
18+
19+
#### Message Sending System (`--send-message`)
20+
- **Complete message sending functionality**
21+
- `--send-message <TEXT>` - Send text messages to any chat
22+
- `--chatid <ID>` - Specify target chat ID (private, group, or channel)
23+
- Support for all chat types (private chats, groups, supergroups, channels)
24+
- Message ID returned on successful send
25+
26+
- **Advanced Formatting Support**
27+
- `--parse-mode <MODE>` - Format messages with Markdown, MarkdownV2, or HTML
28+
- **Markdown**: `*bold*`, `_italic_`, `` `code` ``, `[link](URL)`
29+
- **MarkdownV2**: Enhanced Markdown with `__underline__`, `~strikethrough~`, `||spoiler||`
30+
- **HTML**: `<b>`, `<i>`, `<u>`, `<code>`, `<pre>`, `<a>` tags
31+
- Full URL encoding for special characters
32+
- Comprehensive formatting guide in FORMATTING.md
33+
34+
- **Message Delivery Options**
35+
- `--silent` - Send messages without notifications (no sound/vibration)
36+
- Perfect for automated monitoring
37+
- Useful for off-hours alerts
38+
- Low-priority status updates
39+
- `--nopreview` - Disable link preview generation
40+
- Cleaner messages with multiple URLs
41+
- Security best practice for suspicious links
42+
- Faster message delivery
43+
44+
- **Examples**:
45+
```bash
46+
# Send plain text message
47+
telegramdigger --send-message "Hello World" --chatid 123456789
48+
49+
# Send formatted HTML message
50+
telegramdigger --send-message "<b>Alert:</b> Token found" --chatid 123 --parse-mode HTML
51+
52+
# Send silent message without link preview
53+
telegramdigger --send-message "Check https://example.com" --chatid 123 --silent --nopreview
54+
```
55+
56+
#### Documentation
57+
- **FORMATTING.md** - Comprehensive formatting guide
58+
- Complete syntax reference for all three formatting modes
59+
- Real-world examples for security alerts, monitoring, and automation
60+
- Best practices for silent messages and link previews
61+
- Tips for choosing the right formatting mode
62+
- Common use cases with working examples
63+
64+
### Improved
65+
- Help screen updated with message sending options
66+
- Extended examples section with formatting demonstrations
67+
- Enhanced output display showing parse mode, silent status, and preview settings
68+
- Better error messages for missing parameters
69+
70+
### Technical
71+
- Extended `TelegramApi::sendMessage()` with formatting and delivery options
72+
- Added URL encoding for message text
73+
- Implemented boolean flags for notification and preview control
74+
- New argument parsing functions: `getParseMode()`, `hasSilentFlag()`, `hasNoPreviewFlag()`
75+
- Updated `Config::saveTokenSeen()` to support optional notes
76+
877
## [0.6.1] - 2026-01-06
978

1079
### Added

FORMATTING.md

Lines changed: 278 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,278 @@
1+
# Message Formatting Guide
2+
3+
TelegramDigger supports three formatting modes for sending messages: Markdown, MarkdownV2, and HTML.
4+
5+
## Usage
6+
7+
```bash
8+
telegramdigger --send-message "Your formatted text" --chatid CHAT_ID [OPTIONS]
9+
```
10+
11+
### Available Options
12+
13+
- `--parse-mode MODE` - Formatting mode: `Markdown`, `MarkdownV2`, or `HTML`
14+
- `--silent` - Send message silently (no notification to users)
15+
- `--nopreview` - Disable link preview for URLs in the message
16+
17+
## Markdown Mode
18+
19+
### Supported Formatting
20+
21+
| Style | Syntax | Example |
22+
|-------|--------|---------|
23+
| Bold | `*text*` | `*bold text*` |
24+
| Italic | `_text_` | `_italic text_` |
25+
| Inline Code | `` `text` `` | `` `inline code` `` |
26+
| Pre-formatted Code | ``` ```text``` ``` | ``` ```code block``` ``` |
27+
| Inline Link | `[text](URL)` | `[Google](https://google.com)` |
28+
29+
### Example
30+
31+
```bash
32+
telegramdigger --send-message "*Bold* _italic_ `code` [link](https://example.com)" \
33+
--chatid 123456789 --parse-mode Markdown
34+
```
35+
36+
## MarkdownV2 Mode
37+
38+
MarkdownV2 is more strict and requires escaping special characters.
39+
40+
### Supported Formatting
41+
42+
| Style | Syntax | Example |
43+
|-------|--------|---------|
44+
| Bold | `*text*` | `*bold*` |
45+
| Italic | `_text_` | `_italic_` |
46+
| Underline | `__text__` | `__underline__` |
47+
| Strikethrough | `~text~` | `~strikethrough~` |
48+
| Spoiler | `\|\|text\|\|` | `\|\|spoiler\|\|` |
49+
| Inline Code | `` `text` `` | `` `code` `` |
50+
| Pre-formatted | ``` ```text``` ``` | ``` ```block``` ``` |
51+
| Inline Link | `[text](URL)` | `[link](https://example.com)` |
52+
53+
### Characters that need escaping
54+
`_`, `*`, `[`, `]`, `(`, `)`, `~`, `` ` ``, `>`, `#`, `+`, `-`, `=`, `|`, `{`, `}`, `.`, `!`
55+
56+
### Example
57+
58+
```bash
59+
telegramdigger --send-message "*bold* _italic_ __underline__ ~strike~ \`code\`" \
60+
--chatid 123456789 --parse-mode MarkdownV2
61+
```
62+
63+
## HTML Mode
64+
65+
### Supported Tags
66+
67+
| Style | Tag | Example |
68+
|-------|-----|---------|
69+
| Bold | `<b>` or `<strong>` | `<b>bold text</b>` |
70+
| Italic | `<i>` or `<em>` | `<i>italic text</i>` |
71+
| Underline | `<u>` | `<u>underlined text</u>` |
72+
| Strikethrough | `<s>` or `<strike>` or `<del>` | `<s>strikethrough</s>` |
73+
| Spoiler | `<tg-spoiler>` or `<span class="tg-spoiler">` | `<tg-spoiler>spoiler</tg-spoiler>` |
74+
| Inline Link | `<a href="URL">` | `<a href="https://example.com">link</a>` |
75+
| Inline Code | `<code>` | `<code>inline code</code>` |
76+
| Pre-formatted | `<pre>` | `<pre>code block</pre>` |
77+
| Pre-formatted with language | `<pre><code class="language-*">` | `<pre><code class="language-python">code</code></pre>` |
78+
79+
### Example
80+
81+
```bash
82+
telegramdigger --send-message "<b>Bold</b> <i>italic</i> <u>underline</u> <code>code</code>" \
83+
--chatid 123456789 --parse-mode HTML
84+
```
85+
86+
## Advanced Examples
87+
88+
### Multi-line Message with Markdown
89+
90+
```bash
91+
telegramdigger --send-message "
92+
*Security Alert*
93+
94+
_Bot Token Detected:_ \`123456:ABC...\`
95+
96+
*Recommendations:*
97+
• Rotate the token immediately
98+
• Check access logs
99+
• Update security policies
100+
" --chatid 123456789 --parse-mode Markdown
101+
```
102+
103+
### HTML with Code Block
104+
105+
```bash
106+
telegramdigger --send-message "
107+
<b>Configuration Found:</b>
108+
109+
<pre><code class=\"language-json\">
110+
{
111+
\"api_key\": \"secret\",
112+
\"enabled\": true
113+
}
114+
</code></pre>
115+
116+
<i>Review and secure immediately.</i>
117+
" --chatid 123456789 --parse-mode HTML
118+
```
119+
120+
### Markdown with Links
121+
122+
```bash
123+
telegramdigger --send-message "
124+
*Alert:* Exposed credentials detected
125+
126+
[View Report](https://report.example.com)
127+
[Documentation](https://docs.example.com)
128+
" --chatid 123456789 --parse-mode Markdown
129+
```
130+
131+
## Special Options
132+
133+
### Silent Messages (`--silent`)
134+
135+
Send messages without triggering notifications for recipients. Useful for:
136+
- Low-priority alerts that don't need immediate attention
137+
- Automated logs or status updates
138+
- Night-time messages that shouldn't wake users
139+
140+
```bash
141+
telegramdigger --send-message "Low priority update" --chatid 123 --silent
142+
```
143+
144+
### Disable Link Preview (`--nopreview`)
145+
146+
Prevent Telegram from generating link previews. Useful for:
147+
- Messages with multiple links (keeps it clean)
148+
- Security alerts with potentially dangerous URLs
149+
- When you want to save bandwidth
150+
151+
```bash
152+
telegramdigger --send-message "Check https://example.com" --chatid 123 --nopreview
153+
```
154+
155+
### Combining Options
156+
157+
You can combine all options together:
158+
159+
```bash
160+
telegramdigger --send-message "<b>Alert:</b> Token found at <code>https://github.com/...</code>" \
161+
--chatid 123 --parse-mode HTML --silent --nopreview
162+
```
163+
164+
## Tips
165+
166+
1. **Choose the right mode:**
167+
- Use `Markdown` for simple formatting (easiest)
168+
- Use `HTML` for complex formatting with nested tags
169+
- Use `MarkdownV2` for advanced Markdown features (requires escaping)
170+
171+
2. **Use silent mode wisely:**
172+
- For automated monitoring that runs frequently
173+
- For non-urgent security findings
174+
- For informational messages that don't need immediate action
175+
176+
3. **Disable previews when:**
177+
- Sending security alerts with suspicious URLs
178+
- Message contains many links (cleaner appearance)
179+
- You want faster message delivery
180+
181+
4. **Test your formatting:**
182+
- Always test with a private chat first
183+
- Check how special characters are displayed
184+
- Verify links work correctly
185+
186+
5. **Error handling:**
187+
- Invalid formatting will cause the API to reject the message
188+
- The error will be displayed with details
189+
- Fix the formatting and try again
190+
191+
6. **Plain text:**
192+
- Omit `--parse-mode` to send plain text
193+
- Special characters won't be interpreted
194+
195+
## Common Use Cases
196+
197+
### Security Alerts
198+
199+
```bash
200+
# HTML format for clear alerts (with silent mode for off-hours)
201+
telegramdigger --send-message "
202+
<b>🔴 SECURITY ALERT</b>
203+
204+
<b>Issue:</b> Exposed API token
205+
<b>Severity:</b> Critical
206+
<b>Location:</b> Production server
207+
208+
<i>Action required immediately</i>
209+
" --chatid -1001234567890 --parse-mode HTML --silent
210+
```
211+
212+
```bash
213+
# Alert with URL but no preview (security best practice)
214+
telegramdigger --send-message "
215+
<b>⚠️ Token Exposed</b>
216+
217+
Found at: <code>https://github.com/repo/file.js</code>
218+
219+
Review immediately.
220+
" --chatid 123456789 --parse-mode HTML --nopreview
221+
```
222+
223+
### Bot Information Summary
224+
225+
```bash
226+
# Markdown for clean summaries
227+
telegramdigger --send-message "
228+
*Bot Validation Complete*
229+
230+
_Bot Name:_ MyBot
231+
_Username:_ @mybot
232+
_Status:_ ✅ Active
233+
234+
\`Token saved to database\`
235+
" --chatid 123456789 --parse-mode Markdown
236+
```
237+
238+
### Code Snippets
239+
240+
```bash
241+
# HTML with syntax highlighting
242+
telegramdigger --send-message "
243+
Found configuration file:
244+
245+
<pre><code class=\"language-python\">
246+
API_TOKEN = '123456:ABC...'
247+
WEBHOOK_URL = 'https://example.com'
248+
DEBUG = True
249+
</code></pre>
250+
" --chatid 123456789 --parse-mode HTML
251+
```
252+
253+
### Monitoring and Automation
254+
255+
```bash
256+
# Silent monitoring updates (won't disturb users)
257+
telegramdigger --send-message "
258+
*Hourly Status Report*
259+
260+
• Tokens validated: 15
261+
• New findings: 2
262+
• All systems operational
263+
264+
_Last check: $(date)_
265+
" --chatid 123456789 --parse-mode Markdown --silent
266+
```
267+
268+
```bash
269+
# Bulk notifications with links (no preview to keep clean)
270+
telegramdigger --send-message "
271+
*Daily Summary*
272+
273+
Reports available:
274+
• Security: https://report.example.com/security
275+
• Performance: https://report.example.com/perf
276+
• Logs: https://report.example.com/logs
277+
" --chatid 123 --parse-mode Markdown --nopreview
278+
```

include/config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class Config {
6666
/**
6767
* Save token to tokens-seen file
6868
*/
69-
bool saveTokenSeen(const std::string& token);
69+
bool saveTokenSeen(const std::string& token, const std::string& note = "");
7070

7171
/**
7272
* Check if token has been seen before

include/telegram_api.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,16 @@ class TelegramApi {
271271
*/
272272
bool getChatMemberCount(long long chatId, int& count);
273273

274+
/**
275+
* Send message to a chat
276+
* @param parseMode Optional: "Markdown", "MarkdownV2", or "HTML"
277+
* @param disableNotification Optional: Send message silently (no notification)
278+
* @param disableWebPagePreview Optional: Disable link previews
279+
*/
280+
bool sendMessage(long long chatId, const std::string& text, long long& messageId,
281+
const std::string& parseMode = "", bool disableNotification = false,
282+
bool disableWebPagePreview = false);
283+
274284
/**
275285
* Get last API response
276286
*/

0 commit comments

Comments
 (0)