|
| 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 | +``` |
0 commit comments