Alerts: a Telegram channel, one chat or group each, connected by a one-time link
The channel sends through the Bot API with httpx only: HTML with escaped text, cut to fit a message, silent for a warning, a short 429 waited out once, and errors that say what to do about a blocked bot, a lost chat or a bad token and never quote the request URL. The bot token is a stored secret: saving a channel refuses a literal one, the card's "Store token" writes the secret and a reference, and no endpoint returns it. A chat id is never typed. Connect starts a ten minute code, and the chat that sends `/start <code>` back through the bot is the one connected, so it is a chat somebody opened a link for. The engine fetches updates only while a code is waiting (no standing poll, no webhook, no inbound address) and ignores everything else without a reply. Connect needs a saved form, and the form takes the connected chat in without touching what was typed since. The token is part of every Bot API URL, so the httpx logger gets the same filter the request lines have, which now also masks an httpx.URL argument.
This commit is contained in:
@@ -485,7 +485,7 @@ export const ChannelSchema = {
|
||||
},
|
||||
kind: {
|
||||
type: 'string',
|
||||
enum: ['ntfy', 'smtp', 'webhook', 'dashboard', 'webpush'],
|
||||
enum: ['ntfy', 'smtp', 'webhook', 'dashboard', 'webpush', 'telegram'],
|
||||
title: 'Kind'
|
||||
},
|
||||
enabled: {
|
||||
@@ -4440,6 +4440,48 @@ export const TargetResourcesSchema = {
|
||||
description: 'One machine: this engine, or a worker attached to it.'
|
||||
} as const;
|
||||
|
||||
export const TelegramLinkSchema = {
|
||||
properties: {
|
||||
url: {
|
||||
type: 'string',
|
||||
title: 'Url'
|
||||
},
|
||||
group_url: {
|
||||
type: 'string',
|
||||
title: 'Group Url'
|
||||
},
|
||||
expires_in: {
|
||||
type: 'integer',
|
||||
title: 'Expires In'
|
||||
}
|
||||
},
|
||||
type: 'object',
|
||||
required: ['url', 'group_url', 'expires_in'],
|
||||
title: 'TelegramLink'
|
||||
} as const;
|
||||
|
||||
export const TelegramLinkStatusSchema = {
|
||||
properties: {
|
||||
waiting: {
|
||||
type: 'boolean',
|
||||
title: 'Waiting'
|
||||
},
|
||||
expires_in: {
|
||||
type: 'integer',
|
||||
title: 'Expires In',
|
||||
default: 0
|
||||
},
|
||||
error: {
|
||||
type: 'string',
|
||||
title: 'Error',
|
||||
default: ''
|
||||
}
|
||||
},
|
||||
type: 'object',
|
||||
required: ['waiting'],
|
||||
title: 'TelegramLinkStatus'
|
||||
} as const;
|
||||
|
||||
export const TokenSchema = {
|
||||
properties: {
|
||||
access_token: {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -123,14 +123,14 @@ export type BrainNode = {
|
||||
*/
|
||||
export type Channel = {
|
||||
name: string;
|
||||
kind: 'ntfy' | 'smtp' | 'webhook' | 'dashboard' | 'webpush';
|
||||
kind: 'ntfy' | 'smtp' | 'webhook' | 'dashboard' | 'webpush' | 'telegram';
|
||||
enabled?: boolean;
|
||||
config?: {
|
||||
[key: string]: unknown;
|
||||
};
|
||||
};
|
||||
|
||||
export type kind = 'ntfy' | 'smtp' | 'webhook' | 'dashboard' | 'webpush';
|
||||
export type kind = 'ntfy' | 'smtp' | 'webhook' | 'dashboard' | 'webpush' | 'telegram';
|
||||
|
||||
export type ChatItem = {
|
||||
role: string;
|
||||
@@ -1454,6 +1454,18 @@ export type TargetResources = {
|
||||
in_flight?: number;
|
||||
};
|
||||
|
||||
export type TelegramLink = {
|
||||
url: string;
|
||||
group_url: string;
|
||||
expires_in: number;
|
||||
};
|
||||
|
||||
export type TelegramLinkStatus = {
|
||||
waiting: boolean;
|
||||
expires_in?: number;
|
||||
error?: string;
|
||||
};
|
||||
|
||||
export type Token = {
|
||||
access_token: string;
|
||||
token_type?: string;
|
||||
@@ -1740,6 +1752,24 @@ export type AlertsRemoveWebpushSubscriptionData = {
|
||||
|
||||
export type AlertsRemoveWebpushSubscriptionResponse = (Message);
|
||||
|
||||
export type AlertsStartTelegramLinkData = {
|
||||
channelName: string;
|
||||
};
|
||||
|
||||
export type AlertsStartTelegramLinkResponse = (TelegramLink);
|
||||
|
||||
export type AlertsReadTelegramLinkData = {
|
||||
channelName: string;
|
||||
};
|
||||
|
||||
export type AlertsReadTelegramLinkResponse = (TelegramLinkStatus);
|
||||
|
||||
export type AlertsCancelTelegramLinkData = {
|
||||
channelName: string;
|
||||
};
|
||||
|
||||
export type AlertsCancelTelegramLinkResponse = (Message);
|
||||
|
||||
export type AlertsTestChannelData = {
|
||||
channelName: string;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user