Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

on message只获取了一半的内容,截断了,怎么解决呢? #2667

Open
lys623 opened this issue Apr 12, 2024 · 1 comment
Open

Comments

@lys623
Copy link

lys623 commented Apr 12, 2024

image

实际发送的是很长的:

img_v3_029s_12a4bbe6-1df6-4fed-ae08-ed7ba07949bg

🏡《唐顿庄园》全6季超清视频¥0領,学习英语口语必备利器……

🌈6季总提名60次,获奖16次
🌈英伦贵族餐桌文化、交际礼仪,纤毫毕现
🌈人物塑造之精良,被誉为英国版“红楼梦”

👉认領入口:https://dwz.cn/kz1pEy1J?IZiLZ
👉认領入口:https://dwz.cn/kz1pEy1J?IZiLZ

(¯﹁¯)✧时间会通知你改变一切罢了~@_@

Copy link

dosubot bot commented Apr 12, 2024

To address the issue of your messages being truncated when logged, you can modify the toString method in the MessageMixin class of the Wechaty SDK. This method is likely truncating the message content to a default length. By adjusting or removing the truncation limit, you can ensure that the full content of messages, including text, emojis, and URLs, is captured in your logs.

Here's a quick guide to modify the toString method to prevent truncation:

override toString () {
  if (!this.payload) {
    return this.constructor.name
  }

  let talker
  try {
    talker = this.talker()
  } catch (e) {
    talker = (e as Error).message
  }

  const msgStrList = [
    'Message',
    `#${PUPPET.types.Message[this.type()]}`,
    '[',
    '🗣',
    talker,
    this.room()
      ? '@👥' + this.room()
      : '',
    ']',
  ]
  if (this.type() === PUPPET.types.Message.Text
      || this.type() === PUPPET.types.Message.Unknown
  ) {
    // Remove the substring method to prevent truncation
    msgStrList.push(`\t${this.text()}`)
  } else {
    log.silly('Message', 'toString() for message type: %s(%s)', PUPPET.types.Message[this.type()], this.type())
  }

  return msgStrList.join('')
}

This modification removes the substring call that was truncating the text. For messages that are not of type Text or Unknown, ensure your logging captures and stores the full content or references needed to retrieve the content later.

By implementing this change, you should be able to log the entire content of messages without encountering truncation issues.

Sources

About Dosu

This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

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

No branches or pull requests

1 participant