mirror of
https://github.com/harivansh-afk/pi-telegram-webhook.git
synced 2026-04-15 08:03:45 +00:00
initial: webhook telegram adapter for pi with streaming replies
- webhook server with secret validation, rate limiting, body guards - streaming replies via sendMessage + editMessageText throttled loop - RPC session management for persistent conversations - 15/15 tests passing
This commit is contained in:
parent
809e9b1df5
commit
ce9abc2a8e
18 changed files with 6991 additions and 1 deletions
66
src/types.ts
Normal file
66
src/types.ts
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
/**
|
||||
* pi-telegram-webhook — Type definitions.
|
||||
*/
|
||||
|
||||
export interface Config {
|
||||
botToken: string;
|
||||
webhookUrl: string;
|
||||
webhookPort?: number;
|
||||
webhookHost?: string;
|
||||
webhookPath?: string;
|
||||
webhookSecret: string;
|
||||
allowedChatIds?: string[];
|
||||
streamingThrottleMs?: number;
|
||||
minInitialChars?: number;
|
||||
trustedProxies?: string[];
|
||||
maxConcurrent?: number;
|
||||
timeoutMs?: number;
|
||||
idleTimeoutMinutes?: number;
|
||||
model?: string;
|
||||
extensions?: string[];
|
||||
}
|
||||
|
||||
export interface TelegramMessage {
|
||||
message_id: number;
|
||||
from?: {
|
||||
id: number;
|
||||
username?: string;
|
||||
first_name?: string;
|
||||
};
|
||||
chat: {
|
||||
id: number;
|
||||
type: string;
|
||||
title?: string;
|
||||
};
|
||||
date: number;
|
||||
text?: string;
|
||||
}
|
||||
|
||||
export interface TelegramUpdate {
|
||||
update_id: number;
|
||||
message?: TelegramMessage;
|
||||
}
|
||||
|
||||
export interface SenderSession {
|
||||
chatId: string;
|
||||
queue: QueuedMessage[];
|
||||
processing: boolean;
|
||||
abortController: AbortController | null;
|
||||
messageCount: number;
|
||||
startedAt: number;
|
||||
}
|
||||
|
||||
export interface QueuedMessage {
|
||||
id: string;
|
||||
chatId: string;
|
||||
text: string;
|
||||
enqueuedAt: number;
|
||||
}
|
||||
|
||||
export interface RunResult {
|
||||
ok: boolean;
|
||||
response: string;
|
||||
error?: string;
|
||||
durationMs: number;
|
||||
exitCode: number;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue