Update tg issues

This commit is contained in:
xCyanGrizzly
2026-03-16 16:51:30 +01:00
parent 2763de2711
commit d7bbb7587e
13 changed files with 450 additions and 70 deletions

View File

@@ -143,6 +143,28 @@ export async function sendPhotoMessage(
}
}
/**
* Get basic info about a Telegram user (name, username).
*/
export async function getUser(
userId: number
): Promise<{ firstName: string; lastName?: string; username?: string }> {
if (!client) throw new Error("Bot client not initialized");
const user = (await client.invoke({
_: "getUser",
user_id: userId,
})) as {
first_name?: string;
last_name?: string;
usernames?: { editable_username?: string };
};
return {
firstName: user.first_name ?? "User",
lastName: user.last_name || undefined,
username: user.usernames?.editable_username || undefined,
};
}
/**
* Get updates from TDLib. The bot listens for new messages this way.
*/