mirror of
https://github.com/xCyanGrizzly/DragonsStash.git
synced 2026-05-10 22:01:16 +00:00
feat: support all chat types in channel discovery and enrich bot messages
Channel Discovery: - Remove channel/supergroup filter from getAccountChats — all chat types (private, groups, Saved Messages, etc.) are now discoverable as sources - Detect and label the self-chat as "Saved Messages" via getMe - Update channel picker dialog to accept any chat type string Bot Rich Messages: - Enhance package send preview with creator, file count, tags, and source channel info in MarkdownV2 caption - Include tags in new_package subscription notifications - Expand getPendingSendRequest to fetch richer package data Performance: - Reviewed pipeline for many-channel load — getChats pagination fix and per-channel getChat pre-load from prior commit address the main concerns - Channels with no new messages skip in 2-3 API calls Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -115,9 +115,15 @@ export async function getPendingSendRequest(requestId: string) {
|
||||
select: {
|
||||
id: true,
|
||||
fileName: true,
|
||||
fileSize: true,
|
||||
fileCount: true,
|
||||
creator: true,
|
||||
tags: true,
|
||||
archiveType: true,
|
||||
destChannelId: true,
|
||||
destMessageId: true,
|
||||
previewData: true,
|
||||
sourceChannel: { select: { title: true, telegramId: true } },
|
||||
},
|
||||
},
|
||||
telegramLink: true,
|
||||
|
||||
@@ -134,9 +134,22 @@ async function processSendRequest(requestId: string): Promise<void> {
|
||||
throw new Error("No global destination channel configured");
|
||||
}
|
||||
|
||||
// Send preview if available
|
||||
// Send preview with rich caption if available
|
||||
if (pkg.previewData) {
|
||||
const caption = `📦 *${pkg.fileName}*\n\nSent from Dragon's Stash`;
|
||||
const lines: string[] = [];
|
||||
lines.push(`📦 *${escapeMarkdown(pkg.fileName)}*`);
|
||||
if (pkg.creator) lines.push(`👤 ${escapeMarkdown(pkg.creator)}`);
|
||||
if (pkg.fileCount > 0) lines.push(`📁 ${pkg.fileCount} files`);
|
||||
if (pkg.tags && pkg.tags.length > 0) {
|
||||
lines.push(`🏷️ ${pkg.tags.map((t: string) => escapeMarkdown(t)).join(", ")}`);
|
||||
}
|
||||
if (pkg.sourceChannel) {
|
||||
lines.push(`📡 Source: ${escapeMarkdown(pkg.sourceChannel.title)}`);
|
||||
}
|
||||
lines.push("");
|
||||
lines.push("_Sent from Dragon's Stash_");
|
||||
|
||||
const caption = lines.join("\n");
|
||||
await sendPhotoMessage(targetUserId, Buffer.from(pkg.previewData), caption);
|
||||
}
|
||||
|
||||
@@ -189,6 +202,9 @@ async function handleNewPackage(payload: string): Promise<void> {
|
||||
`🔔 <b>New package matching your subscriptions:</b>`,
|
||||
``,
|
||||
`📦 <b>${escapeHtml(data.fileName)}</b>${creator}`,
|
||||
...(data.tags && data.tags.length > 0
|
||||
? [`🏷️ ${data.tags.map((t: string) => escapeHtml(t)).join(", ")}`]
|
||||
: []),
|
||||
``,
|
||||
`Matched: ${patterns.map((p) => `"${escapeHtml(p)}"`).join(", ")}`,
|
||||
``,
|
||||
@@ -213,3 +229,7 @@ async function handleNewPackage(payload: string): Promise<void> {
|
||||
function escapeHtml(text: string): string {
|
||||
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
||||
}
|
||||
|
||||
function escapeMarkdown(text: string): string {
|
||||
return text.replace(/([_*[\]()~`>#+\-=|{}.!\\])/g, "\\$1");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user