mirror of
https://github.com/ReCloudStudio/WebHooker.git
synced 2026-09-22 16:11:29 +00:00
feat(telegram): send author avatar as richheader link-preview card
Serve an OG page at /api/richheader and use a small link-preview card (avatar + author name) above the message instead of sending a photo.
This commit is contained in:
parent
be50d23319
commit
fc2e2c2efa
5 changed files with 61 additions and 1 deletions
|
|
@ -19,6 +19,15 @@ export class TelegramDriver implements PlatformDriver {
|
|||
const token = env.TELEGRAM_TOKEN ?? "";
|
||||
const text = renderNeutralMessage(message);
|
||||
const avatar = message.author?.iconUrl;
|
||||
const richHeaderHost = env.TELEGRAM_RICH_HEADER_HOST ?? env.BASE_URL;
|
||||
if (avatar && richHeaderHost) {
|
||||
const params = new URLSearchParams();
|
||||
if (message.author?.name) params.set("title", message.author.name);
|
||||
if (message.title) params.set("content", message.title);
|
||||
params.set("avatar", avatar);
|
||||
const rhUrl = `${richHeaderHost.replace(/\/+$/, "")}/api/richheader?${params.toString()}`;
|
||||
return sendMessage(token, chatId, text, target.topicId, rhUrl);
|
||||
}
|
||||
if (avatar) {
|
||||
return sendPhoto(token, chatId, smallAvatar(avatar), text, target.topicId);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue