telert 0.2.2__tar.gz → 0.2.3__tar.gz

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.
Files changed (28) hide show
  1. {telert-0.2.2/telert.egg-info → telert-0.2.3}/PKG-INFO +14 -4
  2. {telert-0.2.2 → telert-0.2.3}/README.md +13 -3
  3. {telert-0.2.2 → telert-0.2.3}/pyproject.toml +1 -1
  4. {telert-0.2.2 → telert-0.2.3}/telert/__init__.py +1 -1
  5. {telert-0.2.2 → telert-0.2.3}/telert/messaging.py +91 -17
  6. {telert-0.2.2 → telert-0.2.3/telert.egg-info}/PKG-INFO +14 -4
  7. {telert-0.2.2 → telert-0.2.3}/LICENSE +0 -0
  8. {telert-0.2.2 → telert-0.2.3}/MANIFEST.in +0 -0
  9. {telert-0.2.2 → telert-0.2.3}/setup.cfg +0 -0
  10. {telert-0.2.2 → telert-0.2.3}/telert/api.py +0 -0
  11. {telert-0.2.2 → telert-0.2.3}/telert/cli.py +0 -0
  12. {telert-0.2.2 → telert-0.2.3}/telert/data/notification-icon.png +0 -0
  13. {telert-0.2.2 → telert-0.2.3}/telert/data/notification.mp3 +0 -0
  14. {telert-0.2.2 → telert-0.2.3}/telert/monitoring/__init__.py +0 -0
  15. {telert-0.2.2 → telert-0.2.3}/telert/monitoring/activity_logs.py +0 -0
  16. {telert-0.2.2 → telert-0.2.3}/telert/monitoring/base.py +0 -0
  17. {telert-0.2.2 → telert-0.2.3}/telert/monitoring/cli.py +0 -0
  18. {telert-0.2.2 → telert-0.2.3}/telert/monitoring/cli_logs.py +0 -0
  19. {telert-0.2.2 → telert-0.2.3}/telert/monitoring/debug_logs.py +0 -0
  20. {telert-0.2.2 → telert-0.2.3}/telert/monitoring/log.py +0 -0
  21. {telert-0.2.2 → telert-0.2.3}/telert/monitoring/network.py +0 -0
  22. {telert-0.2.2 → telert-0.2.3}/telert/monitoring/process.py +0 -0
  23. {telert-0.2.2 → telert-0.2.3}/telert.egg-info/SOURCES.txt +0 -0
  24. {telert-0.2.2 → telert-0.2.3}/telert.egg-info/dependency_links.txt +0 -0
  25. {telert-0.2.2 → telert-0.2.3}/telert.egg-info/entry_points.txt +0 -0
  26. {telert-0.2.2 → telert-0.2.3}/telert.egg-info/requires.txt +0 -0
  27. {telert-0.2.2 → telert-0.2.3}/telert.egg-info/top_level.txt +0 -0
  28. {telert-0.2.2 → telert-0.2.3}/telert.png +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: telert
3
- Version: 0.2.2
3
+ Version: 0.2.3
4
4
  Summary: Ultimate command monitoring & notification system: Telegram, Slack, Discord, Teams, Pushover, Email, desktop & more. Monitor Python code and CLI tasks with context managers, decorators, and webhooks.
5
5
  Author-email: Mihir Khandekar <mihirkhandekar@gmail.com>
6
6
  License-Expression: MIT
@@ -54,11 +54,11 @@ Dynamic: license-file
54
54
  <img src="https://github.com/navig-me/telert/raw/main/telert.png" alt="telert logo" width="150">
55
55
  </p>
56
56
 
57
- **Version 0.2.2**
57
+ **Version 0.2.3**
58
58
 
59
+ [![PyPI Downloads](https://static.pepy.tech/badge/telert)](https://pepy.tech/projects/telert)
59
60
  [![GitHub Stars](https://img.shields.io/github/stars/navig-me/telert?style=social)](https://github.com/navig-me/telert/stargazers)
60
61
  [![PyPI version](https://img.shields.io/pypi/v/telert)](https://pypi.org/project/telert/)
61
- [![Downloads](https://static.pepy.tech/personalized-badge/telert?period=month&units=international_system&left_color=grey&right_color=blue&left_text=downloads)](https://pepy.tech/project/telert)
62
62
  [![License](https://img.shields.io/github/license/navig-me/telert)](https://github.com/navig-me/telert/blob/main/LICENSE)
63
63
  [![Marketplace](https://img.shields.io/badge/GitHub%20Marketplace-Use%20this%20Action-blue?logo=github)](https://github.com/marketplace/actions/telert-run)
64
64
  [![VS Code Marketplace](https://vsmarketplacebadges.dev/version/Navig.telert-vscode.svg?subject=VS%20Code%20Marketplace&style=flat-square)](https://marketplace.visualstudio.com/items?itemName=Navig.telert-vscode)
@@ -102,10 +102,14 @@ Use it as a CLI tool, Python library, or a notification API. Telert is available
102
102
  - As a cloud-hosted API on [Replit](https://replit.com/@mihir95/Telert-CLI-Notifier), [Railway](https://railway.com/template/A_kYXt?referralCode=vj4bEA), [Render](https://render.com/deploy?repo=https://github.com/navig-me/telert-notifier) or [Fly.io](https://github.com/navig-me/telert-notifier?tab=readme-ov-file#-deploy-manually-on-flyio) with one-click deployments.
103
103
 
104
104
 
105
- <img src="https://github.com/navig-me/telert/raw/main/docs/telert-demo.svg" alt="telert demo" width="600">
105
+ <img src="https://github.com/navig-me/telert/raw/main/docs/telert-demo.svg" alt="telert demo" width="700">
106
106
 
107
107
 
108
108
  ## 📋 Table of Contents
109
+
110
+ <details>
111
+ <summary> <b>View Table of Contents</b> </summary>
112
+
109
113
  - [Installation & Quick Start](#-installation--quick-start)
110
114
  - [Notification Providers](#-notification-providers)
111
115
  - [Telegram](#telegram-setup)
@@ -133,9 +137,13 @@ Use it as a CLI tool, Python library, or a notification API. Telert is available
133
137
  - [Message Formatting](#-message-formatting)
134
138
  - [Use Cases](#-use-cases-and-tips)
135
139
  - [Contributing](#-contributing--license)
140
+ </details>
136
141
 
137
142
  ## Documentation
138
143
 
144
+ <details>
145
+ <summary> <b>View Documentation Directory</b></summary>
146
+
139
147
  For more detailed information, please refer to the [docs](https://github.com/navig-me/telert/blob/main/docs/) directory:
140
148
 
141
149
  - [Environment Variables](https://github.com/navig-me/telert/blob/main/docs/ENVIRONMENT_VARIABLES.md)
@@ -153,6 +161,8 @@ For more detailed information, please refer to the [docs](https://github.com/nav
153
161
  - [Docker Usage](https://github.com/navig-me/telert/blob/main/docs/DOCKER.md)
154
162
  - [CI/CD Integrations](https://github.com/navig-me/telert/blob/main/docs/CI-CD.md)
155
163
 
164
+ </details>
165
+
156
166
  ## 🚀 Installation & Quick Start
157
167
 
158
168
  Install and configure in seconds:
@@ -6,11 +6,11 @@
6
6
  <img src="https://github.com/navig-me/telert/raw/main/telert.png" alt="telert logo" width="150">
7
7
  </p>
8
8
 
9
- **Version 0.2.2**
9
+ **Version 0.2.3**
10
10
 
11
+ [![PyPI Downloads](https://static.pepy.tech/badge/telert)](https://pepy.tech/projects/telert)
11
12
  [![GitHub Stars](https://img.shields.io/github/stars/navig-me/telert?style=social)](https://github.com/navig-me/telert/stargazers)
12
13
  [![PyPI version](https://img.shields.io/pypi/v/telert)](https://pypi.org/project/telert/)
13
- [![Downloads](https://static.pepy.tech/personalized-badge/telert?period=month&units=international_system&left_color=grey&right_color=blue&left_text=downloads)](https://pepy.tech/project/telert)
14
14
  [![License](https://img.shields.io/github/license/navig-me/telert)](https://github.com/navig-me/telert/blob/main/LICENSE)
15
15
  [![Marketplace](https://img.shields.io/badge/GitHub%20Marketplace-Use%20this%20Action-blue?logo=github)](https://github.com/marketplace/actions/telert-run)
16
16
  [![VS Code Marketplace](https://vsmarketplacebadges.dev/version/Navig.telert-vscode.svg?subject=VS%20Code%20Marketplace&style=flat-square)](https://marketplace.visualstudio.com/items?itemName=Navig.telert-vscode)
@@ -54,10 +54,14 @@ Use it as a CLI tool, Python library, or a notification API. Telert is available
54
54
  - As a cloud-hosted API on [Replit](https://replit.com/@mihir95/Telert-CLI-Notifier), [Railway](https://railway.com/template/A_kYXt?referralCode=vj4bEA), [Render](https://render.com/deploy?repo=https://github.com/navig-me/telert-notifier) or [Fly.io](https://github.com/navig-me/telert-notifier?tab=readme-ov-file#-deploy-manually-on-flyio) with one-click deployments.
55
55
 
56
56
 
57
- <img src="https://github.com/navig-me/telert/raw/main/docs/telert-demo.svg" alt="telert demo" width="600">
57
+ <img src="https://github.com/navig-me/telert/raw/main/docs/telert-demo.svg" alt="telert demo" width="700">
58
58
 
59
59
 
60
60
  ## 📋 Table of Contents
61
+
62
+ <details>
63
+ <summary> <b>View Table of Contents</b> </summary>
64
+
61
65
  - [Installation & Quick Start](#-installation--quick-start)
62
66
  - [Notification Providers](#-notification-providers)
63
67
  - [Telegram](#telegram-setup)
@@ -85,9 +89,13 @@ Use it as a CLI tool, Python library, or a notification API. Telert is available
85
89
  - [Message Formatting](#-message-formatting)
86
90
  - [Use Cases](#-use-cases-and-tips)
87
91
  - [Contributing](#-contributing--license)
92
+ </details>
88
93
 
89
94
  ## Documentation
90
95
 
96
+ <details>
97
+ <summary> <b>View Documentation Directory</b></summary>
98
+
91
99
  For more detailed information, please refer to the [docs](https://github.com/navig-me/telert/blob/main/docs/) directory:
92
100
 
93
101
  - [Environment Variables](https://github.com/navig-me/telert/blob/main/docs/ENVIRONMENT_VARIABLES.md)
@@ -105,6 +113,8 @@ For more detailed information, please refer to the [docs](https://github.com/nav
105
113
  - [Docker Usage](https://github.com/navig-me/telert/blob/main/docs/DOCKER.md)
106
114
  - [CI/CD Integrations](https://github.com/navig-me/telert/blob/main/docs/CI-CD.md)
107
115
 
116
+ </details>
117
+
108
118
  ## 🚀 Installation & Quick Start
109
119
 
110
120
  Install and configure in seconds:
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "telert"
3
- version = "0.2.2"
3
+ version = "0.2.3"
4
4
  description = "Ultimate command monitoring & notification system: Telegram, Slack, Discord, Teams, Pushover, Email, desktop & more. Monitor Python code and CLI tasks with context managers, decorators, and webhooks."
5
5
  authors = [{name = "Mihir Khandekar", email = "mihirkhandekar@gmail.com"}]
6
6
  license = "MIT"
@@ -19,7 +19,7 @@ __all__ = [
19
19
  "set_default_providers",
20
20
  "list_providers",
21
21
  ]
22
- __version__ = "0.2.2"
22
+ __version__ = "0.2.3"
23
23
 
24
24
  from telert.api import (
25
25
  configure,
@@ -337,7 +337,11 @@ def prepare_telegram_html(message: str) -> str:
337
337
  # Process all elements recursively
338
338
  def process_node(node):
339
339
  if node.name is None: # Text node
340
- return node.string
340
+ # Escape HTML special characters in text content
341
+ text = node.string or ""
342
+ # HTML mode requires escaping of <, >, & characters
343
+ text = text.replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;')
344
+ return text
341
345
 
342
346
  # Only include supported tags, strip others but keep their content
343
347
  supported_tags = ['b', 'i', 'u', 's', 'code', 'pre', 'a']
@@ -361,6 +365,37 @@ def prepare_telegram_html(message: str) -> str:
361
365
  return result
362
366
 
363
367
 
368
+ def prepare_telegram_plain_text(message: str) -> str:
369
+ """
370
+ Prepare plain text messages for Telegram by escaping special characters.
371
+
372
+ When sending plain text (no HTML or Markdown), certain characters still need
373
+ to be escaped to prevent Telegram API errors. This function handles the
374
+ escaping of characters that have special meaning in Telegram messages.
375
+
376
+ Args:
377
+ message: Message text that contains special characters
378
+
379
+ Returns:
380
+ Message with special characters properly escaped for plain text mode
381
+ """
382
+ if not message:
383
+ return message
384
+
385
+ # Characters that need to be escaped in plain text to prevent API errors
386
+ # Based on Telegram Bot API documentation and common error patterns
387
+ special_chars = ['_', '*', '[', ']', '(', ')', '~', '`', '>', '#', '+', '-', '=', '|', '{', '}', '.', '!']
388
+
389
+ result = ""
390
+ for char in message:
391
+ if char in special_chars:
392
+ result += '\\' + char
393
+ else:
394
+ result += char
395
+
396
+ return result
397
+
398
+
364
399
  def prepare_telegram_markdown(message: str) -> str:
365
400
  """
366
401
  Prepare Markdown-formatted messages for Telegram.
@@ -380,29 +415,65 @@ def prepare_telegram_markdown(message: str) -> str:
380
415
  # Characters that need to be escaped in MarkdownV2
381
416
  special_chars = ['_', '*', '[', ']', '(', ')', '~', '`', '>', '#', '+', '-', '=', '|', '{', '}', '.', '!']
382
417
 
383
- # We need to escape these characters outside of formatting tags
418
+ # For MarkdownV2, we need to escape special characters but preserve markdown syntax
419
+ # This is a simplified approach - for complex markdown, consider using a proper parser
384
420
  result = ""
385
- in_tag = False
386
421
  i = 0
387
422
 
388
423
  while i < len(message):
389
- # Check for formatting tags
390
- if message[i:i+2] in ['**', '__'] or message[i] in ['*', '_', '`', '~']:
391
- # Toggle in_tag state
392
- in_tag = not in_tag
393
- result += message[i]
424
+ char = message[i]
425
+
426
+ # Handle code blocks (``` or single `)
427
+ if char == '`':
428
+ # Find the matching closing backtick(s)
429
+ if i + 2 < len(message) and message[i:i+3] == '```':
430
+ # Code block - find closing ```
431
+ end = message.find('```', i + 3)
432
+ if end != -1:
433
+ # Include the entire code block without escaping
434
+ result += message[i:end+3]
435
+ i = end + 3
436
+ continue
437
+ else:
438
+ # Inline code - find closing `
439
+ end = message.find('`', i + 1)
440
+ if end != -1:
441
+ # Include the entire inline code without escaping
442
+ result += message[i:end+1]
443
+ i = end + 1
444
+ continue
445
+
446
+ # Handle other markdown formatting characters
447
+ if char in ['*', '_', '~'] and i + 1 < len(message):
448
+ # Check for double characters (**, __, etc.)
394
449
  if message[i:i+2] in ['**', '__']:
395
- result += message[i+1]
396
- i += 2
450
+ # Find matching closing tag
451
+ tag = message[i:i+2]
452
+ end = message.find(tag, i + 2)
453
+ if end != -1:
454
+ # Include the formatted text, escaping content inside
455
+ content = message[i+2:end]
456
+ escaped_content = ''.join('\\' + c if c in special_chars and c not in ['*', '_'] else c for c in content)
457
+ result += tag + escaped_content + tag
458
+ i = end + 2
459
+ continue
397
460
  else:
398
- i += 1
461
+ # Single character formatting
462
+ end = message.find(char, i + 1)
463
+ if end != -1:
464
+ # Include the formatted text, escaping content inside
465
+ content = message[i+1:end]
466
+ escaped_content = ''.join('\\' + c if c in special_chars and c != char else c for c in content)
467
+ result += char + escaped_content + char
468
+ i = end + 1
469
+ continue
470
+
471
+ # Regular character - escape if it's a special character
472
+ if char in special_chars:
473
+ result += '\\' + char
399
474
  else:
400
- # Escape special characters outside of formatting tags
401
- if not in_tag and message[i] in special_chars:
402
- result += '\\' + message[i]
403
- else:
404
- result += message[i]
405
- i += 1
475
+ result += char
476
+ i += 1
406
477
 
407
478
  return result
408
479
 
@@ -486,6 +557,9 @@ class TelegramProvider:
486
557
  elif has_markdown:
487
558
  payload["parse_mode"] = "MarkdownV2"
488
559
  payload["text"] = prepare_telegram_markdown(message)
560
+ else:
561
+ # Plain text - escape special characters to prevent API errors
562
+ payload["text"] = prepare_telegram_plain_text(message)
489
563
 
490
564
  try:
491
565
  response = requests.post(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: telert
3
- Version: 0.2.2
3
+ Version: 0.2.3
4
4
  Summary: Ultimate command monitoring & notification system: Telegram, Slack, Discord, Teams, Pushover, Email, desktop & more. Monitor Python code and CLI tasks with context managers, decorators, and webhooks.
5
5
  Author-email: Mihir Khandekar <mihirkhandekar@gmail.com>
6
6
  License-Expression: MIT
@@ -54,11 +54,11 @@ Dynamic: license-file
54
54
  <img src="https://github.com/navig-me/telert/raw/main/telert.png" alt="telert logo" width="150">
55
55
  </p>
56
56
 
57
- **Version 0.2.2**
57
+ **Version 0.2.3**
58
58
 
59
+ [![PyPI Downloads](https://static.pepy.tech/badge/telert)](https://pepy.tech/projects/telert)
59
60
  [![GitHub Stars](https://img.shields.io/github/stars/navig-me/telert?style=social)](https://github.com/navig-me/telert/stargazers)
60
61
  [![PyPI version](https://img.shields.io/pypi/v/telert)](https://pypi.org/project/telert/)
61
- [![Downloads](https://static.pepy.tech/personalized-badge/telert?period=month&units=international_system&left_color=grey&right_color=blue&left_text=downloads)](https://pepy.tech/project/telert)
62
62
  [![License](https://img.shields.io/github/license/navig-me/telert)](https://github.com/navig-me/telert/blob/main/LICENSE)
63
63
  [![Marketplace](https://img.shields.io/badge/GitHub%20Marketplace-Use%20this%20Action-blue?logo=github)](https://github.com/marketplace/actions/telert-run)
64
64
  [![VS Code Marketplace](https://vsmarketplacebadges.dev/version/Navig.telert-vscode.svg?subject=VS%20Code%20Marketplace&style=flat-square)](https://marketplace.visualstudio.com/items?itemName=Navig.telert-vscode)
@@ -102,10 +102,14 @@ Use it as a CLI tool, Python library, or a notification API. Telert is available
102
102
  - As a cloud-hosted API on [Replit](https://replit.com/@mihir95/Telert-CLI-Notifier), [Railway](https://railway.com/template/A_kYXt?referralCode=vj4bEA), [Render](https://render.com/deploy?repo=https://github.com/navig-me/telert-notifier) or [Fly.io](https://github.com/navig-me/telert-notifier?tab=readme-ov-file#-deploy-manually-on-flyio) with one-click deployments.
103
103
 
104
104
 
105
- <img src="https://github.com/navig-me/telert/raw/main/docs/telert-demo.svg" alt="telert demo" width="600">
105
+ <img src="https://github.com/navig-me/telert/raw/main/docs/telert-demo.svg" alt="telert demo" width="700">
106
106
 
107
107
 
108
108
  ## 📋 Table of Contents
109
+
110
+ <details>
111
+ <summary> <b>View Table of Contents</b> </summary>
112
+
109
113
  - [Installation & Quick Start](#-installation--quick-start)
110
114
  - [Notification Providers](#-notification-providers)
111
115
  - [Telegram](#telegram-setup)
@@ -133,9 +137,13 @@ Use it as a CLI tool, Python library, or a notification API. Telert is available
133
137
  - [Message Formatting](#-message-formatting)
134
138
  - [Use Cases](#-use-cases-and-tips)
135
139
  - [Contributing](#-contributing--license)
140
+ </details>
136
141
 
137
142
  ## Documentation
138
143
 
144
+ <details>
145
+ <summary> <b>View Documentation Directory</b></summary>
146
+
139
147
  For more detailed information, please refer to the [docs](https://github.com/navig-me/telert/blob/main/docs/) directory:
140
148
 
141
149
  - [Environment Variables](https://github.com/navig-me/telert/blob/main/docs/ENVIRONMENT_VARIABLES.md)
@@ -153,6 +161,8 @@ For more detailed information, please refer to the [docs](https://github.com/nav
153
161
  - [Docker Usage](https://github.com/navig-me/telert/blob/main/docs/DOCKER.md)
154
162
  - [CI/CD Integrations](https://github.com/navig-me/telert/blob/main/docs/CI-CD.md)
155
163
 
164
+ </details>
165
+
156
166
  ## 🚀 Installation & Quick Start
157
167
 
158
168
  Install and configure in seconds:
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes