Skip to content
Merged
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
28 changes: 23 additions & 5 deletions .github/workflows/bot-api-watch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,42 @@ jobs:
code=$?
cat report.md
echo "status=$code" >> "$GITHUB_OUTPUT"
if grep -q "source may be stale" report.md; then
echo "stale=true" >> "$GITHUB_OUTPUT"
else
echo "stale=false" >> "$GITHUB_OUTPUT"
fi
[ "$code" -le 1 ]
- name: Open or update issue
if: steps.check.outputs.status == '1'
if: steps.check.outputs.status == '1' || steps.check.outputs.stale == 'true'
env:
GH_TOKEN: ${{ github.token }}
run: |
gh label create bot-api-update --color 2481cc --description "Telegram Bot API changed" 2>/dev/null || true
version=$(sed -n 's/^Spec: \*\*Bot API \([0-9.]*\)\*\*.*/\1/p' report.md)
stale="${{ steps.check.outputs.stale }}"
status="${{ steps.check.outputs.status }}"
{
echo "The Telegram Bot API spec differs from \`src/assets/js/data.js\`."
if [ "$status" = "1" ]; then
echo "The Telegram Bot API spec differs from \`src/assets/js/data.js\`."
else
echo "The Bot API spec source may be stale; the check could not confirm that the project is up to date."
fi
echo
cat report.md
echo
echo "To update: edit \`src/assets/js/data.js\` (lists and \`BOT_API_VERSION\`), add labels to all \`src/i18n/*.json\`, add new method parameters to \`METHOD_PARAMS\` in \`scripts/check-bot-api.mjs\`, then run \`npm test\` and \`node scripts/check-bot-api.mjs\`."
echo "If this is a real API change: edit \`src/assets/js/data.js\` (lists and \`BOT_API_VERSION\`), add labels to all \`src/i18n/*.json\`, add new method parameters to \`METHOD_PARAMS\` in \`scripts/check-bot-api.mjs\`, then run \`npm test\` and \`node scripts/check-bot-api.mjs\`."
echo
echo "If the spec source looks stale, verify https://core.telegram.org/bots/api before changing the project."
} > body.md
if [ "$stale" = "true" ] && [ "$status" != "1" ]; then
title="Bot API spec source may be stale"
else
title="Update to Telegram Bot API $version"
fi
existing=$(gh issue list --label bot-api-update --state open --json number --jq '.[0].number')
if [ -n "$existing" ]; then
gh issue edit "$existing" --title "Update to Telegram Bot API $version" --body-file body.md
gh issue edit "$existing" --title "$title" --body-file body.md
else
gh issue create --title "Update to Telegram Bot API $version" --label bot-api-update --body-file body.md
gh issue create --title "$title" --label bot-api-update --body-file body.md
fi
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 3.4.0 — 2026-11-21

### Changed
- Tab editors are imported only when a tab is opened; the landing page no longer downloads the whole editor module graph.
- The Bot API drift check also covers `InputProfilePhoto` subtypes.
- The weekly Bot API watch opens or updates an issue when the spec source looks stale, not only when fields differ.

## 3.3.1 — 2026-11-21

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Static site (GitHub Pages) that calls the Telegram Bot API from the browser. No

## Updating to a new Bot API version

1. `node scripts/check-bot-api.mjs` — lists new update types, admin rights, getMe flags, command scopes, BotCommand/MenuButton/WebhookInfo fields, parameters of every method the tool calls, and bot-settings methods (spec: PaulSonOfLars/telegram-bot-api-spec; core.telegram.org may be unreachable). It also warns when the spec release date is stale, so an outdated spec source is not mistaken for “no changes”.
1. `node scripts/check-bot-api.mjs` — lists new update types, admin rights, getMe flags, command scopes, BotCommand/MenuButton/InputProfilePhoto/WebhookInfo fields, parameters of every method the tool calls, and bot-settings methods (spec: PaulSonOfLars/telegram-bot-api-spec; core.telegram.org may be unreachable). It also warns when the spec release date is stale, and the weekly watch opens an issue for a stale source, so an outdated spec is not mistaken for “no changes”.
2. Update `src/assets/js/data.js`: `UPDATE_GROUPS` (mark `optIn` if the spec says it must be requested explicitly), `ADMIN_RIGHTS` (with `target`), `ME_FLAGS`, `COMMAND_SCOPES`, `BOT_API_VERSION`. If a new parameter appears on a method the tool already calls, add it to `METHOD_PARAMS` in `scripts/check-bot-api.mjs` and expose it in the UI when it matters.
3. Add labels for every new key to all five locale files (`app.updates.*`, `app.rights.*`, `app.me.*`, `app.scopes.*`). `npm test` lists anything missing.
4. A new bot-settings method that needs its own UI (a new tab or form) is a design change: describe it in the PR instead of building it silently.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ npm run build && node scripts/screenshots.mjs # e2e smoke test (Playwright + C
## Automation

- **CI** (`.github/workflows/ci.yml`, on pull requests): unit tests, build, end-to-end test in Chromium against a mocked Bot API, and a Lighthouse audit (accessibility ≥ 95, best practices ≥ 90 and SEO ≥ 95 are errors; performance ≥ 85 is a warning; reports are attached to the run).
- **Bot API watch** (`.github/workflows/bot-api-watch.yml`, weekly): compares the latest Bot API spec with `src/assets/js/data.js` via `scripts/check-bot-api.mjs` — update types, admin rights, `getMe` flags, scopes, `BotCommand`/`MenuButton`/`WebhookInfo` fields and the parameters of every method the tool calls — and opens an issue labelled `bot-api-update` when something is missing. A stale spec source is reported as a warning.
- **Bot API watch** (`.github/workflows/bot-api-watch.yml`, weekly): compares the latest Bot API spec with `src/assets/js/data.js` via `scripts/check-bot-api.mjs` — update types, admin rights, `getMe` flags, scopes, `BotCommand`/`MenuButton`/`InputProfilePhoto`/`WebhookInfo` fields and the parameters of every method the tool calls — and opens an issue labelled `bot-api-update` when something is missing or the spec source looks stale.
- **Agent instructions** for updating the project are in [`CLAUDE.md`](CLAUDE.md).

## FAQ
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "telegram-bot-manager",
"version": "3.3.1",
"version": "3.4.0",
"private": true,
"description": "Free online Telegram Bot Manager: set, check and delete webhooks, edit commands, profile, menu button and admin rights right in your browser.",
"type": "module",
Expand Down
5 changes: 4 additions & 1 deletion scripts/check-bot-api.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const WEBHOOK_INFO_FIELDS = [
];
export const BOT_COMMAND_FIELDS = ['command', 'description', 'is_ephemeral'];
export const MENU_BUTTON_TYPES = ['MenuButtonCommands', 'MenuButtonWebApp', 'MenuButtonDefault'];
export const INPUT_PROFILE_PHOTO_TYPES = ['InputProfilePhotoStatic', 'InputProfilePhotoAnimated'];

// A stale spec source is a silent-drift risk: it can look "up to date" while Telegram has
// already shipped a newer API. The report warns when the spec release date is older than this.
Expand Down Expand Up @@ -123,6 +124,7 @@ export async function checkBotApi(spec, { now = new Date(), maxSpecAgeDays = MAX
),
botCommandFields: diff(fields('BotCommand'), BOT_COMMAND_FIELDS),
menuButtonTypes: diff(spec.types.MenuButton?.subtypes ?? [], MENU_BUTTON_TYPES),
profilePhotoTypes: diff(spec.types.InputProfilePhoto?.subtypes ?? [], INPUT_PROFILE_PHOTO_TYPES),
webhookInfoFields: diff(fields('WebhookInfo'), WEBHOOK_INFO_FIELDS),
methodParams,
uncheckedMethods: { added: uncheckedMethods, removed: [] },
Expand All @@ -133,7 +135,7 @@ export async function checkBotApi(spec, { now = new Date(), maxSpecAgeDays = MAX
};
const sections = [
report.updateTypes, report.adminRights, report.meFlags, report.commandScopes,
report.botCommandFields, report.menuButtonTypes, report.webhookInfoFields,
report.botCommandFields, report.menuButtonTypes, report.profilePhotoTypes, report.webhookInfoFields,
report.methodParams, report.uncheckedMethods, report.botSettingsMethods,
];
report.upToDate = report.specVersion === report.ourVersion
Expand All @@ -154,6 +156,7 @@ export function toMarkdown(r) {
commandScopes: 'BotCommandScope types',
botCommandFields: 'BotCommand fields',
menuButtonTypes: 'MenuButton types',
profilePhotoTypes: 'InputProfilePhoto types',
webhookInfoFields: 'WebhookInfo fields',
methodParams: 'Method parameters',
uncheckedMethods: 'Used methods without a parameter check',
Expand Down
7 changes: 5 additions & 2 deletions scripts/screenshots.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ async function openApp({ theme = 'dark', lang = '', width = 1280, height = 900,
viewport: { width, height }, colorScheme: theme, deviceScaleFactor: 1, ...(locale ? { locale } : {}),
});
const page = await context.newPage();
const requests = [];
page.on('request', (request) => requests.push(request.url()));
page.on('pageerror', (e) => errors.push(`pageerror: ${e.message}`));
page.on('console', (m) => {
// Failed mocked requests (e.g. the deliberate 429) are logged by the browser; they are expected.
Expand All @@ -138,7 +140,7 @@ async function openApp({ theme = 'dark', lang = '', width = 1280, height = 900,
return route.fulfill({ status: json.ok ? 200 : json.error_code, contentType: 'application/json', body: JSON.stringify(json), headers: { 'access-control-allow-origin': '*' } });
});
await page.goto(`${base}${lang}`);
return { page, mock, context };
return { page, mock, context, requests };
}

async function shot(page, name, options = {}) {
Expand All @@ -161,9 +163,10 @@ async function connect(page) {
try {
// Landing page
{
const { page, context } = await openApp({ theme: 'light' });
const { page, context, requests } = await openApp({ theme: 'light' });
assert(await page.title() !== '', 'title');
assert((await page.locator('link[rel="alternate"][hreflang]').count()) === 6, 'hreflang links');
assert(!requests.some((url) => url.includes('/assets/js/tabs/')), 'tab modules load lazily');
await page.fill('#token', 'bad');
await page.click('#connect-form button[type="submit"]');
assert(await page.locator('.field-error').isVisible(), 'token validation');
Expand Down
38 changes: 28 additions & 10 deletions src/assets/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ import { DEFAULT_API_BASE, LANGUAGE_CODES, ME_FLAGS } from './data.js';
import { validateToken, validateApiBase, normalizeApiBase } from './validators.js';
import * as storage from './storage.js';
import { $, $$, el, describeError, withBusy, copyText, bindCounters, badge, showError, applyValidation } from './ui.js';
import webhookTab from './tabs/webhook.js';
import profileTab from './tabs/profile.js';
import commandsTab from './tabs/commands.js';
import menuTab from './tabs/menu.js';
import rightsTab from './tabs/rights.js';
import devTab from './tabs/dev.js';

const TABS = [webhookTab, profileTab, commandsTab, menuTab, rightsTab, devTab];
// Tab controllers are imported on first activation: the landing page only needs the
// connection form, so the editor code is not part of its initial module graph.
const TABS = [
{ id: 'webhook', loader: () => import('./tabs/webhook.js') },
{ id: 'profile', loader: () => import('./tabs/profile.js') },
{ id: 'commands', loader: () => import('./tabs/commands.js') },
{ id: 'menu', loader: () => import('./tabs/menu.js') },
{ id: 'rights', loader: () => import('./tabs/rights.js') },
{ id: 'dev', loader: () => import('./tabs/dev.js'), alwaysReload: true },
];
const LOG_LIMIT = 100;
const LANGUAGE_SUGGESTIONS = [
{ code: 'ru', prefix: 'ru/', name: 'Русский' },
Expand Down Expand Up @@ -40,6 +42,8 @@ const app = {
};

const loadedTabs = new Set();
const tabControllers = new Map();
const tabLoads = new Map();
let avatarUrl = null;
let activeTab = null;

Expand Down Expand Up @@ -210,14 +214,28 @@ function activateTab(id, { focus = false } = {}) {
loadTab(id);
}

async function ensureTab(tab) {
if (tabControllers.has(tab.id)) return tabControllers.get(tab.id);
if (!tabLoads.has(tab.id)) {
tabLoads.set(tab.id, tab.loader().then((module) => {
const controller = module.default;
controller.init(app);
tabControllers.set(tab.id, controller);
return controller;
}).finally(() => tabLoads.delete(tab.id)));
}
return tabLoads.get(tab.id);
}

async function loadTab(id, force = false) {
const tab = TABS.find((x) => x.id === id);
if (!app.api || (loadedTabs.has(id) && !force && !tab.alwaysReload)) return;
loadedTabs.add(id);
const panel = $(`#panel-${id}`);
panel.classList.add('is-loading');
try {
await tab.load(app);
const controller = await ensureTab(tab);
await controller.load(app);
} catch (error) {
loadedTabs.delete(id);
showError(error);
Expand All @@ -242,7 +260,7 @@ function initTabs() {
const id = tabFromHash();
if (id && app.api && id !== activeTab) activateTab(id);
});
for (const tab of TABS) tab.init(app);
// Controllers are imported and initialised on the first tab activation.
}

// ---------- Misc UI ----------
Expand Down
4 changes: 4 additions & 0 deletions tests/check-bot-api.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import assert from 'node:assert/strict';
import { readFile } from 'node:fs/promises';
import {
checkBotApi, toMarkdown, usedMethods, METHOD_PARAMS, WEBHOOK_INFO_FIELDS, BOT_COMMAND_FIELDS, MENU_BUTTON_TYPES,
INPUT_PROFILE_PHOTO_TYPES,
} from '../scripts/check-bot-api.mjs';
import { loadLocales, LANGS } from '../scripts/build.mjs';
import * as data from '../src/assets/js/data.js';
Expand All @@ -20,6 +21,7 @@ function specFromProject() {
BotCommandScope: { subtypes: scopeTypes },
BotCommand: { fields: BOT_COMMAND_FIELDS.map((n) => field(n)) },
MenuButton: { subtypes: [...MENU_BUTTON_TYPES] },
InputProfilePhoto: { subtypes: [...INPUT_PROFILE_PHOTO_TYPES] },
WebhookInfo: { fields: WEBHOOK_INFO_FIELDS.map((n) => field(n)) },
};
data.COMMAND_SCOPES.forEach((s, i) => {
Expand Down Expand Up @@ -60,13 +62,15 @@ test('detects new method parameters and object fields', async () => {
spec.types.WebhookInfo.fields.push(field('new_info_field'));
spec.types.BotCommand.fields.push(field('new_command_field'));
spec.types.MenuButton.subtypes.push('MenuButtonNew');
spec.types.InputProfilePhoto.subtypes.push('InputProfilePhotoNew');
const report = await checkBotApi(spec, { now: NOW });
assert.equal(report.upToDate, false);
assert.deepEqual(report.methodParams.added, ['setMyCommands.new_parameter']);
assert.deepEqual(report.methodParams.removed, ['setWebhook.secret_token']);
assert.deepEqual(report.webhookInfoFields.added, ['new_info_field']);
assert.deepEqual(report.botCommandFields.added, ['new_command_field']);
assert.deepEqual(report.menuButtonTypes.added, ['MenuButtonNew']);
assert.deepEqual(report.profilePhotoTypes.added, ['InputProfilePhotoNew']);
const md = toMarkdown(report);
assert.ok(md.includes('`setMyCommands.new_parameter`') && md.includes('### WebhookInfo fields'));
});
Expand Down
Loading