24 lines
589 B
TypeScript
24 lines
589 B
TypeScript
|
|
export { botTag, formatThreadTime } from "@rakazo/core";
|
||
|
|
|
||
|
|
export function filterBots<T extends { name: string; title: string; preview: string }>(
|
||
|
|
bots: T[],
|
||
|
|
query: string,
|
||
|
|
): T[] {
|
||
|
|
const needle = query.trim().toLowerCase();
|
||
|
|
if (!needle) return bots;
|
||
|
|
return bots.filter((bot) =>
|
||
|
|
`${bot.name} ${bot.title} ${bot.preview}`.toLowerCase().includes(needle),
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
export function userInitials(name: string) {
|
||
|
|
const initials = name
|
||
|
|
.split(/\s+/)
|
||
|
|
.filter(Boolean)
|
||
|
|
.map((part) => part[0])
|
||
|
|
.join("")
|
||
|
|
.slice(0, 2)
|
||
|
|
.toUpperCase();
|
||
|
|
return initials || "?";
|
||
|
|
}
|