Claude-Telegram-Bot icon indicating copy to clipboard operation
Claude-Telegram-Bot copied to clipboard

Request to Modify Message Sending Functionality in Claude-Telegram-Bot

Open XamelionAG opened this issue 7 months ago • 2 comments

Hello,

I have been using your Claude-Telegram-Bot and I am quite satisfied with its functionality. However, I have come across a requirement that I believe could be a valuable addition to the bot's capabilities.

Currently, when the bot is required to send a long message (more than 4000 characters) or to forward a code file, it attempts to send it as a text message. This can cause issues due to the maximum limit of characters in a single message imposed by Telegram.

I propose a modification to the bot's sending functionality. When a message exceeds 4000 characters or when a file needs to be forwarded, the bot could write the content to a file and send it as a document instead of a text message.

The modification could look something like this in the code:

def send_message_or_file(update, text): if len(text) <= 4000: bot.send_message(chat_id=update.effective_chat.id, text=text) else: with open('message.txt', 'w') as f: f.write(text) with open('message.txt', 'rb') as doc: bot.send_document(chat_id=update.effective_chat.id, document=doc)

This function would replace all occurrences of bot.send_message.

I believe this would be a valuable enhancement to the bot's functionality, allowing it to handle longer texts and file forwarding more effectively. Could you consider implementing this change, or guide me through doing it myself if it aligns with the project's direction?

Thank you for considering my suggestion. I look forward to hearing your thoughts.

Best regards, Ruslan Projekt Xamelion AG

XamelionAG avatar Nov 05 '23 11:11 XamelionAG