This repository has been archived by the owner on Aug 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
16 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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${ | ||
`<b>${html(feed.title)}</b>\n${html(item.title)}\n${ | ||
feed.telegraph | ||
? item.content | ||
? `[telegraph](${await telegraph(item)})` | ||
? `<a href="${await telegraph(item)}">telegraph</a>` | ||
: "" | ||
: "" | ||
} ${item.link ? `[查看原文](${item.link})` : ""}`, | ||
{ parse_mode: "MARKDOWN" } | ||
} ${item.link ? `<a href="${item.link}">origin</a>` : ""}`, | ||
{ 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" } | ||
`<b>${html(feed.title)}</b>\n 连续多次失败,将暂停更新,请检查订阅源是否正常。`, | ||
{ parse_mode: "HTML" } | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const map = { | ||
"<": "<", | ||
">": ">", | ||
"&": "&", | ||
}; | ||
export const html = (string) => string.replace(/[\<\>\&]/g, (m) => map[m]); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters