Created
April 18, 2022 20:38
-
-
Save Fuchsoria/c9bdcc8208dca9681762d6d912b18531 to your computer and use it in GitHub Desktop.
Telegram bot web apps: Type definitions for TypeScript (Beta)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare namespace TG { | |
type EventType = 'themeChanged' | 'viewportChanged' | 'mainButtonClicked'; | |
type Params = { | |
text?: string; | |
color?: string; | |
text_color?: string; | |
is_active?: boolean; | |
is_visible?: boolean; | |
}; | |
type ThemeParams = { | |
bg_color: string; | |
text_color: string; | |
hint_color: string; | |
link_color: string; | |
button_color: string; | |
button_text_color: string; | |
}; | |
type WebAppUser = { | |
id: number; | |
is_bot: boolean; | |
first_name: string; | |
last_name: string; | |
username: string; | |
language_code: string; | |
photo_url: string; | |
}; | |
type WebAppInitData = { | |
query_id: string; | |
user: WebAppUser; | |
receiver: WebAppUser; | |
start_param: string; | |
auth_date: number; | |
hash: string; | |
}; | |
type MainButton = { | |
text: string; | |
color: string; | |
textColor: string; | |
isVisible: boolean; | |
isActive: boolean; | |
isProgressVisible: boolean; | |
setText: (text) => void; | |
onClick: (callback) => void; | |
show: () => void; | |
hide: () => void; | |
enable: () => void; | |
disable: () => void; | |
showProgress: (leaveActive) => void; | |
hideProgress: () => void; | |
setParams: (params: Params) => void; | |
}; | |
type WebApp = { | |
initData: string; | |
initDataUnsafe: WebAppInitData; | |
colorScheme: string; | |
themeParams: ThemeParams; | |
isExpanded: boolean; | |
viewportHeight: number; | |
viewportStableHeight: number; | |
MainButton: MainButton; | |
onEvent(eventType: EventType, eventHandler); | |
offEvent(eventType: EventType, eventHandler); | |
sendData(data); | |
ready: () => void; | |
expand: () => void; | |
close: () => void; | |
}; | |
type Telegram = { | |
WebApp: WebApp; | |
}; | |
} | |
interface Window { | |
Telegram: TG.Telegram; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment