Skip to content

Commit

Permalink
fix: telegram encoding err when slice long title
Browse files Browse the repository at this point in the history
  • Loading branch information
yllhwa committed Sep 14, 2024
1 parent 60c1d28 commit 4748f6a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
9 changes: 8 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"http2": "^3.3.7",
"mustache": "^4.2.0",
"node-forge": "^1.3.1",
"patch-package": "^8.0.0"
"patch-package": "^8.0.0",
"runes2": "^1.1.4"
}
}
3 changes: 2 additions & 1 deletion src/lib/telegram/channel.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { renderRss2 } from '../../utils/util';
import { substr } from 'runes2';

let deal = async (ctx) => {
const { username } = ctx.req.param();
Expand Down Expand Up @@ -80,7 +81,7 @@ let deal = async (ctx) => {
let title = tgme_widget_message_texts[i].replace(/<br>/g, ' ');
title = title.replace(/<b>|<\/b>|<img.*>/g, '');
if (title.length > 100) {
title = title.slice(0, 100) + '...';
title = substr(title, 0, 100) + '...';
} else if (title.trim().length === 0) {
title = '无标题';
}
Expand Down

0 comments on commit 4748f6a

Please sign in to comment.