Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ export const NotificationTelegram: React.FC = React.memo(() => {
<Input />
</Form.Item>

<Form.Item
className="flex-1"
name={['payload', 'messageId']}
noStyle={true}
rules={[{ required: false }]}
>
<Input />
</Form.Item>

{token && (
<AutoLoadingButton onClick={handleAutoGet}>
{t('Auto Fetch')}
Expand Down
6 changes: 5 additions & 1 deletion src/server/model/notification/provider/telegram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import { ImageContentToken } from '../token/type.js';
interface TelegramPayload {
botToken: string;
chatId: string;
messageId?: string;
}

export const telegram: NotificationProvider = {
send: async (notification, title, message) => {
const payload = notification.payload as unknown as TelegramPayload;
const { botToken, chatId } = payload;
const { botToken, chatId, messageId } = payload;

const text = telegramContentTokenizer.parse([
token.title(title, 1),
Expand All @@ -21,6 +22,7 @@ export const telegram: NotificationProvider = {
// send text part
await axios.post(`https://api.telegram.org/bot${botToken}/sendMessage`, {
chat_id: chatId,
reply_to_message_id: messageId,
text,
parse_mode: 'HTML',
});
Expand All @@ -33,11 +35,13 @@ export const telegram: NotificationProvider = {
if (imageTokens.length === 1) {
await axios.post(`https://api.telegram.org/bot${botToken}/sendPhoto`, {
chat_id: chatId,
reply_to_message_id: messageId,
photo: imageTokens[0].url,
});
} else {
await axios.post(`https://api.telegram.org/bot${botToken}/sendPhoto`, {
chat_id: chatId,
reply_to_message_id: messageId,
media: imageTokens.map((t) => ({
type: 'photo',
media: t.url,
Expand Down