feat: режим отправки медиа через инлайн

This commit is contained in:
2026-10-11 00:31:45 +04:00
parent 2a41ac9423
commit 4d588c89fb
10 changed files with 303 additions and 13 deletions
+22 -6
View File
@@ -2,11 +2,16 @@
import { User, Users, Megaphone } from 'lucide-svelte'
import { onMount } from 'svelte'
import { api } from '../lib/api.js'
import { getQueryId, getChatName, getChatType, close as tgClose, showAlert } from '../lib/telegram.js'
import {
getQueryId, getChatName, getChatType,
isInlineMode, switchInlineQuery,
close as tgClose, showAlert,
} from '../lib/telegram.js'
const queryId = getQueryId()
const chatName = getChatName()
const chatType = getChatType()
const inlineMode = isInlineMode()
const queryId = getQueryId()
const chatName = getChatName()
const chatType = getChatType()
const PREVIEWABLE = new Set(['Photo', 'Video', 'Animation', 'Sticker'])
@@ -45,6 +50,17 @@
async function send(id) {
if (sending) return
sending = id
if (inlineMode) {
// Inline-режим: передаём управление боту через switchInlineQuery.
// Telegram вставляет «@bot send:<id>» в поле ввода — пользователь тапает результат.
switchInlineQuery(`send:${id}`)
// switchInlineQuery закрывает Mini App сам, но на случай если нет — подстрахуемся
tgClose()
return
}
// Attachment-режим (query_id): отправляем через answerWebAppQuery
try {
await api.sendToChat(id, queryId)
tgClose()
@@ -65,8 +81,8 @@
<div class="page">
<div class="header">
<div class="title">Отправить в чат</div>
{#if chatName}
<div class="title">{inlineMode ? 'Выберите медиа' : 'Отправить в чат'}</div>
{#if chatName && !inlineMode}
<div class="chat-name">
{#if chatType === 'private'}
<User size={14} strokeWidth={2} />