feat: 텔레그램 미니앱 연동

- sendMessageWithKeyboard 함수 추가
- /start 명령어에 미니앱 버튼 추가
- 메뉴 버튼으로 서비스 페이지 열기 지원

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
kappa
2026-01-14 13:57:21 +09:00
parent 4477551ae2
commit 72b0ae0133
2 changed files with 58 additions and 1 deletions

View File

@@ -82,6 +82,54 @@ export async function deleteWebhook(
return response.json();
}
// 인라인 키보드 타입
export interface InlineKeyboardButton {
text: string;
url?: string;
callback_data?: string;
web_app?: { url: string };
}
// 인라인 키보드와 함께 메시지 전송
export async function sendMessageWithKeyboard(
token: string,
chatId: number,
text: string,
keyboard: InlineKeyboardButton[][],
options?: {
parse_mode?: 'HTML' | 'Markdown' | 'MarkdownV2';
}
): Promise<boolean> {
try {
const response = await fetch(
`https://api.telegram.org/bot${token}/sendMessage`,
{
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
chat_id: chatId,
text,
parse_mode: options?.parse_mode || 'HTML',
reply_markup: {
inline_keyboard: keyboard,
},
}),
}
);
if (!response.ok) {
const error = await response.text();
console.error('Telegram API error:', error);
return false;
}
return true;
} catch (error) {
console.error('Failed to send message with keyboard:', error);
return false;
}
}
// 타이핑 액션 전송
export async function sendChatAction(
token: string,