fix: improve telegram configuration safety

This commit is contained in:
Peter Steinberger
2026-01-11 03:57:44 +01:00
parent 11f897b7df
commit 36a21ae9b0
11 changed files with 177 additions and 19 deletions

View File

@@ -643,6 +643,30 @@ export async function handleCommands(params: {
return { shouldContinue: false, reply };
}
const whoamiRequested = command.commandBodyNormalized === "/whoami";
if (allowTextCommands && whoamiRequested) {
const senderId = ctx.SenderId ?? "";
const senderUsername = ctx.SenderUsername ?? "";
const lines = ["🧭 Identity", `Provider: ${command.provider}`];
if (senderId) lines.push(`User id: ${senderId}`);
if (senderUsername) {
const handle = senderUsername.startsWith("@")
? senderUsername
: `@${senderUsername}`;
lines.push(`Username: ${handle}`);
}
if (ctx.ChatType === "group" && ctx.From) {
lines.push(`Chat: ${ctx.From}`);
}
if (ctx.MessageThreadId != null) {
lines.push(`Thread: ${ctx.MessageThreadId}`);
}
if (senderId) {
lines.push(`AllowFrom: ${senderId}`);
}
return { shouldContinue: false, reply: { text: lines.join("\n") } };
}
const configCommand = allowTextCommands
? parseConfigCommand(command.commandBodyNormalized)
: null;