mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-18 11:44:18 +00:00
Merge pull request #1270 from RockChinQ/fix/telegram-markdown
fix: markdown and image problems in tg
This commit is contained in:
@@ -4,7 +4,7 @@ import telegram
|
||||
import telegram.ext
|
||||
from telegram import Update
|
||||
from telegram.ext import ApplicationBuilder, ContextTypes, CommandHandler, MessageHandler, filters
|
||||
|
||||
import telegramify_markdown
|
||||
import typing
|
||||
import asyncio
|
||||
import traceback
|
||||
@@ -86,9 +86,10 @@ class TelegramMessageConverter(adapter.MessageConverter):
|
||||
if message.text:
|
||||
message_text = message.text
|
||||
message_components.extend(parse_message_text(message_text))
|
||||
|
||||
|
||||
if message.photo:
|
||||
message_components.extend(parse_message_text(message.caption))
|
||||
if message.caption:
|
||||
message_components.extend(parse_message_text(message.caption))
|
||||
|
||||
file = await message.photo[-1].get_file()
|
||||
|
||||
@@ -201,19 +202,20 @@ class TelegramAdapter(adapter.MessagePlatformAdapter):
|
||||
|
||||
for component in components:
|
||||
if component['type'] == 'text':
|
||||
|
||||
content = telegramify_markdown.markdownify(
|
||||
content= component['text'],
|
||||
)
|
||||
args = {
|
||||
"chat_id": message_source.source_platform_object.effective_chat.id,
|
||||
"text": component['text'],
|
||||
"text": content,
|
||||
}
|
||||
|
||||
if self.config['markdown_card'] is True:
|
||||
args["parse_mode"] = "MarkdownV2"
|
||||
if quote_origin:
|
||||
args['reply_to_message_id'] = message_source.source_platform_object.message.id
|
||||
|
||||
if quote_origin:
|
||||
args['reply_to_message_id'] = message_source.source_platform_object.message.id
|
||||
await self.bot.send_message(**args)
|
||||
|
||||
await self.bot.send_message(**args)
|
||||
|
||||
async def is_muted(self, group_id: int) -> bool:
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user