Skip to content
This repository has been archived by the owner on Apr 24, 2024. It is now read-only.

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

Open
XamelionAG opened this issue Nov 5, 2023 · 2 comments

Comments

@XamelionAG
Copy link

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

@ciuzaak
Copy link
Owner

ciuzaak commented Nov 6, 2023

Thank you for your support and suggestions 😊. Implementing message segmentation involves a bit more complexity, considering the transitions between different responses and other functionalities (like with Google Bard), so it's not quite a simple fix 🤔. My schedule has been pretty packed lately, so it's tough to carve out time for updates . But hey, feel free to fork the repo and tweak it to your liking 👍!

@Kaifsarkar53
Copy link

Can it is possible to split the response when the character limit reached please tell me or guide me to implement this function

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants