feat(watcher,api,frontend): archive who writes to watched bots over mtproto
This commit is contained in:
1 parent
089a31db8d
commit
4bd031f21e
30 files changed
+1863
-10
No files matched your search
@@ -4,6 +4,8 @@ import type {
|
||||
Alert,
|
||||
Annotation,
|
||||
AvatarHistoryView,
|
||||
BotStats,
|
||||
BotUpdate,
|
||||
CallbackView,
|
||||
CaptureToggles,
|
||||
Chat,
|
||||
@@ -34,6 +36,7 @@ import type {
|
||||
StoryView,
|
||||
VolumeBucket,
|
||||
Watch,
|
||||
WatchedBot,
|
||||
} from "$lib/api/types";
|
||||
import { accounts } from "$lib/stores/accounts.svelte";
|
||||
|
||||
@@ -568,3 +571,32 @@ export function updateAnnotation(
|
||||
export function deleteAnnotation(id: number): Promise<void> {
|
||||
return request<void>(`/annotations/${id}`, { method: "DELETE" });
|
||||
}
|
||||
|
||||
export function listWatchedBots(): Promise<WatchedBot[]> {
|
||||
return request<WatchedBot[]>("/bots");
|
||||
}
|
||||
|
||||
export function addWatchedBot(token: string): Promise<WatchedBot> {
|
||||
return request<WatchedBot>("/bots", { method: "POST", body: { token } });
|
||||
}
|
||||
|
||||
export function removeWatchedBot(botId: number): Promise<void> {
|
||||
return request<void>(`/bots/${botId}`, { method: "DELETE" });
|
||||
}
|
||||
|
||||
export function botStats(botId: number, days = 90): Promise<BotStats> {
|
||||
return request<BotStats>(`/bots/${botId}/stats`, { query: { days } });
|
||||
}
|
||||
|
||||
export function botUpdates(
|
||||
botId: number,
|
||||
options: { limit?: number; offset?: number; senderId?: number } = {}
|
||||
): Promise<BotUpdate[]> {
|
||||
return request<BotUpdate[]>(`/bots/${botId}/updates`, {
|
||||
query: {
|
||||
limit: options.limit,
|
||||
offset: options.offset,
|
||||
sender_id: options.senderId,
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -546,3 +546,82 @@ export interface ShareSubject {
|
||||
storyId?: number;
|
||||
versionId?: number;
|
||||
}
|
||||
|
||||
export interface WatchedBot {
|
||||
added_at: string;
|
||||
backfilled_at: string | null;
|
||||
bot_id: number;
|
||||
checked_at: string | null;
|
||||
enabled: boolean;
|
||||
incoming: number;
|
||||
last_ts: string | null;
|
||||
senders: number;
|
||||
status: string;
|
||||
status_detail: string | null;
|
||||
title: string | null;
|
||||
username: string | null;
|
||||
}
|
||||
|
||||
export interface BotSummary {
|
||||
chats: number;
|
||||
first_ts: string | null;
|
||||
incoming: number;
|
||||
last_ts: string | null;
|
||||
outgoing: number;
|
||||
senders: number;
|
||||
}
|
||||
|
||||
export interface BotSender {
|
||||
chat_id: number | null;
|
||||
first_ts: string;
|
||||
incoming: number;
|
||||
is_bot: boolean | null;
|
||||
last_ts: string;
|
||||
name: string | null;
|
||||
sender_id: number;
|
||||
username: string | null;
|
||||
}
|
||||
|
||||
export interface BotBucket {
|
||||
bucket: string;
|
||||
incoming: number;
|
||||
senders: number;
|
||||
}
|
||||
|
||||
export interface BotCount {
|
||||
incoming: number;
|
||||
key: string;
|
||||
}
|
||||
|
||||
export interface BotHour {
|
||||
hour: number;
|
||||
incoming: number;
|
||||
}
|
||||
|
||||
export interface BotStats {
|
||||
bot: WatchedBot;
|
||||
hours: BotHour[];
|
||||
kinds: BotCount[];
|
||||
media: BotCount[];
|
||||
senders: BotSender[];
|
||||
summary: BotSummary;
|
||||
timeline: BotBucket[];
|
||||
}
|
||||
|
||||
export interface BotUpdate {
|
||||
chat_id: number;
|
||||
chat_title: string | null;
|
||||
chat_type: string | null;
|
||||
edited_at: string | null;
|
||||
item_id: number;
|
||||
kind: string;
|
||||
media_kind: string | null;
|
||||
outgoing: boolean;
|
||||
sender_id: number | null;
|
||||
sender_is_bot: boolean | null;
|
||||
sender_name: string | null;
|
||||
sender_username: string | null;
|
||||
source: string;
|
||||
text: string | null;
|
||||
ts: string;
|
||||
}
|
||||
Reference in new issue
Block a user