mirror of
https://github.com/zhigang1992/telegram-mcp.git
synced 2026-01-12 08:24:40 +08:00
feat: add textMarkdown field with entities to message APIs
Add textMarkdown field to formatMessage output that includes formatting entities (links, bold, italic, code, etc.) converted to markdown format using @mtcute/markdown-parser. Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import type { TelegramClient, Dialog, Message } from '@mtcute/bun';
|
||||
import type { ToolInfo } from './index.js';
|
||||
import { md } from '@mtcute/markdown-parser';
|
||||
|
||||
export const messageTools: ToolInfo[] = [
|
||||
{
|
||||
@@ -283,10 +284,16 @@ async function getRecentMessages(client: TelegramClient, args: any) {
|
||||
}
|
||||
|
||||
function formatMessage(msg: Message) {
|
||||
const textWithEntities = msg.textWithEntities;
|
||||
const textMarkdown = textWithEntities.entities && textWithEntities.entities.length > 0
|
||||
? md.unparse(textWithEntities)
|
||||
: msg.text;
|
||||
|
||||
return {
|
||||
id: msg.id,
|
||||
date: msg.date,
|
||||
text: msg.text,
|
||||
textMarkdown: textMarkdown,
|
||||
senderId: msg.sender.id,
|
||||
senderName: msg.sender.displayName || msg.sender.username || `User ${msg.sender.id}`,
|
||||
senderUsername: msg.sender.username,
|
||||
|
||||
Reference in New Issue
Block a user