"A request to the Telegram API was unsuccessful. Error code: 400. Description: Bad Request: message is too long"

"A request to the Telegram API was unsuccessful. Error code: 400. Description: Bad Request: message is too long"

我正在尝试使用 PRAW. It is working properly for most of the cases but I'm getting the following error that the message is too long.I'm using pytelegrambotApi

从 Reddit subreddits 检索消息

片段:

import praw
import telebot

bot = telebot.TeleBot(token)  

reddit = praw.Reddit(
    client_id=client, #these details are given accordingly and are correct. No errors here.
    client_secret=secret,
    user_agent="user_agent",
)

def get_posts(sub):
   for submission in reddit.subreddit(sub).hot(limit=10):
    print(submission)
    if submission.author.is_mod:
      continue
    elif submission.selftext=="":
      return submission.title,submission.url
    else:
      print("It's working")
      print(submission.url)
      return submission.title,submission.selftext 

@bot.message_handler(func=lambda message: True)
def echo_message(message):
    subreddit = message.text
    title,post = get_posts(subreddit)
    m = title + "\n" + post
    bot.reply_to(message,m)

bot.infinity_polling()

错误: 我可以在此处执行任何解决方法来访问完整消息吗?

一条 Telegram 消息不得超过 4096 个字符。然后将该消息拆分为另一条消息(即剩余部分)。 将此代码添加到您的 message_handler:

m = title + "\n" + post
if len(m) > 4095:
    for x in range(0, len(m), 4095):
        bot.reply_to(message, text=m[x:x+4095])
else:
    bot.reply_to(message, text=m)