diff --git a/notifications/telegram.js b/notifications/telegram.js
index d01ec2f..98e7ee3 100644
--- a/notifications/telegram.js
+++ b/notifications/telegram.js
@@ -1,27 +1,27 @@
import { config } from "../config";
const Telegram = require("telegraf/telegram");
import { telegraph } from "../utils/telegraph";
-import { md } from "../utils/markdown";
+import { html } from "../utils/html";
let sendto = config.TG_SENDID;
export async function reply(feed, item) {
const telegram = new Telegram(config.TG_TOKEN);
await telegram.sendMessage(
sendto,
- `*${md(feed.title)}*\n${md(item.title)}\n${
+ `${html(feed.title)}\n${html(item.title)}\n${
feed.telegraph
? item.content
- ? `[telegraph](${await telegraph(item)})`
+ ? `telegraph`
: ""
: ""
- } ${item.link ? `[查看原文](${item.link})` : ""}`,
- { parse_mode: "MARKDOWN" }
+ } ${item.link ? `origin` : ""}`,
+ { parse_mode: "HTML" }
);
}
export async function replyWhenError(feed) {
const telegram = new Telegram(config.TG_TOKEN);
await telegram.sendMessage(
sendto,
- `*${md(feed.title)}*\n 连续多次失败,将暂停更新,请检查订阅源是否正常。`,
- { parse_mode: "MARKDOWN" }
+ `${html(feed.title)}\n 连续多次失败,将暂停更新,请检查订阅源是否正常。`,
+ { parse_mode: "HTML" }
);
}
diff --git a/utils/html.js b/utils/html.js
new file mode 100644
index 0000000..1a6a8b5
--- /dev/null
+++ b/utils/html.js
@@ -0,0 +1,6 @@
+const map = {
+ "<": "<",
+ ">": ">",
+ "&": "&",
+};
+export const html = (string) => string.replace(/[\<\>\&]/g, (m) => map[m]);
diff --git a/utils/markdown.js b/utils/markdown.js
deleted file mode 100644
index ba9a898..0000000
--- a/utils/markdown.js
+++ /dev/null
@@ -1,18 +0,0 @@
-const map = {
- "*": "\\*",
- "#": "\\#",
- "(": "\\(",
- ")": "\\)",
- "[": "\\[",
- "]": "\\]",
- _: "\\_",
- "\\": "\\\\",
- "+": "\\+",
- "-": "\\-",
- "`": "\\`",
- "<": "<",
- ">": ">",
- "&": "&",
-};
-export const md = (string) =>
- string.replace(/[\*\(\)\[\]\+\-\\_`#<>]/g, (m) => map[m]);
diff --git a/utils/tgbot_command/list.js b/utils/tgbot_command/list.js
index 1c18f55..027afbc 100644
--- a/utils/tgbot_command/list.js
+++ b/utils/tgbot_command/list.js
@@ -1,4 +1,4 @@
-import { md } from "../markdown";
+import { html} from "../html";
export async function botList(ctx) {
let subraw = (await KV.get("sub")) || "[]";
const sub = JSON.parse(subraw);
@@ -7,8 +7,8 @@ export async function botList(ctx) {
} else {
let msg = "";
for (let i = 0; i < sub.length; i++) {
- msg += `[${md(sub[i].title)}](${sub[i].url})\n`;
+ msg += `[${html(sub[i].title)}](${sub[i].url})\n`;
}
- await ctx.reply(msg, { parse_mode: "Markdown" });
+ await ctx.reply(msg, { parse_mode: "HTML" });
}
}