clansty / Q2TG

QQ 与 Telegram 群相互转发的 bot
https://t.me/Q2TGbot
GNU Affero General Public License v3.0
718 stars 73 forks source link

feat: don't use rich header if message contains urls #229

Closed sakarie9 closed 5 months ago

sakarie9 commented 5 months ago

开启 Rich Header 会导致正常链接无法被 tg 预览

简单判断当消息中包含 https://http:// 后跳过生成 Rich Header

clansty commented 5 months ago

要不要考虑使用正则表达式匹配 URL。以及有些 URL 不包含 https?://,直接写了 xxx.com/xxx 之类的,特别是短链接的情况

sakarie9 commented 5 months ago

要不要考虑使用正则表达式匹配 URL。以及有些 URL 不包含 https?://,直接写了 xxx.com/xxx 之类的,特别是短链接的情况

每条消息都要判断一次开销可能太大,简单测试过只正则匹配 https?:// 都比上面这个慢了一倍。没找到特别好的方法总之先这样了(

clansty commented 5 months ago

@sakarie9 也行