Skip to content

Commit

Permalink
Merge pull request #44 from sudoskys/dev
Browse files Browse the repository at this point in the history
🔧 feat: add mermaid diagram rendering and improve logger integration
  • Loading branch information
sudoskys authored Dec 13, 2024
2 parents ec5c5a1 + 539b9db commit 89f968c
Show file tree
Hide file tree
Showing 12 changed files with 806 additions and 224 deletions.
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ for LLM responses, GitHub README files, and more.
ensure
its effectiveness.
- We also support Latex Visualization(escape) and Expanded Citation.
- Mermaid Diagrams render supported.

> [!NOTE]
> If you're interested, there's also a Node.js version of the library
Expand All @@ -40,10 +41,14 @@ pdm add telegramify-markdown
### 🤔 What you want to do?

- If you just want to send *static text* and don't want to worry about formatting,
check: **[playground/markdownify_case.py](https://github.com/sudoskys/telegramify-markdown/blob/main/playground/markdownify_case.py)**
check: *
*[playground/markdownify_case.py](https://github.com/sudoskys/telegramify-markdown/blob/main/playground/markdownify_case.py)
**

- If you are developing an *LLM application* and need to send potentially **super-long text**, please
check: **[playground/telegramify_case.py](https://github.com/sudoskys/telegramify-markdown/blob/main/playground/telegramify_case.py)**
check: *
*[playground/telegramify_case.py](https://github.com/sudoskys/telegramify-markdown/blob/main/playground/telegramify_case.py)
**

## 👀 Use case

Expand Down Expand Up @@ -139,7 +144,9 @@ print(converted)

### `telegramify_case`

please check: **[playground/telegramify_case.py](https://github.com/sudoskys/telegramify-markdown/blob/main/playground/telegramify_case.py)**
please check: *
*[playground/telegramify_case.py](https://github.com/sudoskys/telegramify-markdown/blob/main/playground/telegramify_case.py)
**

## 🔨 Supported Input

Expand Down
91 changes: 90 additions & 1 deletion pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions playground/inspect_telegramify.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import os
import pathlib
from time import sleep

from dotenv import load_dotenv
from telebot import TeleBot

import telegramify_markdown
from telegramify_markdown.customize import markdown_symbol
from telegramify_markdown.type import ContentTypes

tips = """
telegramify_markdown.telegramify
The stability of telegramify_markdown.telegramify is unproven, please keep good log records.
Feel free to check it out, if you have any questions please open an issue
"""

load_dotenv()
telegram_bot_token = os.getenv("TELEGRAM_BOT_TOKEN", None)
chat_id = os.getenv("TELEGRAM_CHAT_ID", None)
bot = TeleBot(telegram_bot_token)

markdown_symbol.head_level_1 = "📌" # If you want, Customizing the head level 1 symbol
markdown_symbol.link = "🔗" # If you want, Customizing the link symbol
md = pathlib.Path(__file__).parent.joinpath("t_longtext.md").read_text(encoding="utf-8")
boxs = telegramify_markdown.telegramify(md)
for item in boxs:
print("Sent one item")
sleep(0.2)
if item.content_type == ContentTypes.TEXT:
print("TEXT")
print(item.content)
elif item.content_type == ContentTypes.PHOTO:
print("PHOTO")
print(item.caption)
elif item.content_type == ContentTypes.FILE:
print("FILE")
print(item.file_name)
Loading

0 comments on commit 89f968c

Please sign in to comment.