mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 07:30:43 +00:00
refactor: reuse telegram command keyboard helper
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import type { ReplyPayload } from "openclaw/plugin-sdk/reply-runtime";
|
||||
import { buildCommandsPaginationKeyboard } from "openclaw/plugin-sdk/telegram-command-ui";
|
||||
import {
|
||||
buildBrowseProvidersButton,
|
||||
buildModelsKeyboard,
|
||||
@@ -6,35 +7,7 @@ import {
|
||||
type ProviderInfo,
|
||||
} from "./model-buttons.js";
|
||||
|
||||
export function buildCommandsPaginationKeyboard(
|
||||
currentPage: number,
|
||||
totalPages: number,
|
||||
agentId?: string,
|
||||
): Array<Array<{ text: string; callback_data: string }>> {
|
||||
const buttons: Array<{ text: string; callback_data: string }> = [];
|
||||
const suffix = agentId ? `:${agentId}` : "";
|
||||
|
||||
if (currentPage > 1) {
|
||||
buttons.push({
|
||||
text: "◀ Prev",
|
||||
callback_data: `commands_page_${currentPage - 1}${suffix}`,
|
||||
});
|
||||
}
|
||||
|
||||
buttons.push({
|
||||
text: `${currentPage}/${totalPages}`,
|
||||
callback_data: `commands_page_noop${suffix}`,
|
||||
});
|
||||
|
||||
if (currentPage < totalPages) {
|
||||
buttons.push({
|
||||
text: "Next ▶",
|
||||
callback_data: `commands_page_${currentPage + 1}${suffix}`,
|
||||
});
|
||||
}
|
||||
|
||||
return [buttons];
|
||||
}
|
||||
export { buildCommandsPaginationKeyboard };
|
||||
|
||||
export function buildTelegramCommandsListChannelData(params: {
|
||||
currentPage: number;
|
||||
|
||||
@@ -1153,6 +1153,10 @@
|
||||
"types": "./dist/plugin-sdk/telegram-command-config.d.ts",
|
||||
"default": "./dist/plugin-sdk/telegram-command-config.js"
|
||||
},
|
||||
"./plugin-sdk/telegram-command-ui": {
|
||||
"types": "./dist/plugin-sdk/telegram-command-ui.d.ts",
|
||||
"default": "./dist/plugin-sdk/telegram-command-ui.js"
|
||||
},
|
||||
"./plugin-sdk/text-autolink-runtime": {
|
||||
"types": "./dist/plugin-sdk/text-autolink-runtime.d.ts",
|
||||
"default": "./dist/plugin-sdk/text-autolink-runtime.js"
|
||||
|
||||
@@ -274,6 +274,7 @@
|
||||
"state-paths",
|
||||
"target-resolver-runtime",
|
||||
"telegram-command-config",
|
||||
"telegram-command-ui",
|
||||
"text-autolink-runtime",
|
||||
"thread-ownership",
|
||||
"tlon",
|
||||
|
||||
Reference in New Issue
Block a user