very first commit

This commit is contained in:
sdarbinyan
2026-01-18 18:57:06 +04:00
commit bd80896886
152 changed files with 28211 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
import { Injectable } from '@angular/core';
import type { } from '../types/telegram.types';
@Injectable({
providedIn: 'root'
})
export class TelegramService {
private tg = typeof window !== 'undefined' ? window.Telegram?.WebApp : null;
isTelegramApp(): boolean {
return !!this.tg;
}
getUser() {
return this.tg?.initDataUnsafe?.user || null;
}
getUserId(): number | null {
return this.tg?.initDataUnsafe?.user?.id || null;
}
getUsername(): string | null {
return this.tg?.initDataUnsafe?.user?.username || null;
}
getFirstName(): string | null {
return this.tg?.initDataUnsafe?.user?.first_name || null;
}
getFullName(): string | null {
const user = this.getUser();
if (!user) return null;
return `${user.first_name}${user.last_name ? ' ' + user.last_name : ''}`;
}
getDisplayName(): string {
return this.getUsername() || this.getFullName() || 'Пользователь';
}
}