mirror of
https://github.com/domfelipe/mika-agent-assist.git
synced 2026-08-07 15:16:50 +00:00
Changes
Co-authored-by: domfelipe <53182096+domfelipe@users.noreply.github.com>
This commit is contained in:
parent
75397543e8
commit
bebe095d6e
4 changed files with 188 additions and 2 deletions
25
src/lib/telegram-username.ts
Normal file
25
src/lib/telegram-username.ts
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
"use client";
|
||||
|
||||
/**
|
||||
* Sanitiza um primeiro nome para uso em sugestões de username do Telegram.
|
||||
* - remove acentos via NFD
|
||||
* - remove caracteres não-alfanuméricos
|
||||
* - lowercase
|
||||
*/
|
||||
export function sanitizeForUsername(name: string): string {
|
||||
return (name || "")
|
||||
.normalize("NFD")
|
||||
.replace(/[\u0300-\u036f]/g, "")
|
||||
.replace(/[^a-zA-Z0-9]/g, "")
|
||||
.toLowerCase();
|
||||
}
|
||||
|
||||
export function suggestBotName(fullName: string | null | undefined): string {
|
||||
const first = (fullName || "").trim().split(/\s+/)[0] || "Você";
|
||||
return `Mika de ${first}`;
|
||||
}
|
||||
|
||||
export function suggestBotUsername(fullName: string | null | undefined): string {
|
||||
const first = sanitizeForUsername((fullName || "").trim().split(/\s+/)[0] || "voce");
|
||||
return `mika_${first || "voce"}_bot`;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue