-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtelegram.js
33 lines (29 loc) · 943 Bytes
/
telegram.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const MIN_TELEGRAM_BOT_API = "6.9";
export const isTelegramAPISupported = () => {
return window.Telegram.WebApp.isVersionAtLeast(MIN_TELEGRAM_BOT_API);
};
export const getTelegramLanguage = () => {
return window.Telegram.WebApp.initDataUnsafe.user.language_code;
};
export const getCloudValue = (key) => {
return new Promise((resolve, reject) => {
window.Telegram.WebApp.CloudStorage.getItem(key, (err, value) => {
if (err != null) {
return reject(err);
} else {
return resolve(value);
}
});
});
};
export const setCloudValue = (key, value) => {
return new Promise((resolve, reject) => {
window.Telegram.WebApp.CloudStorage.setItem(key, value, (err, result) => {
if (err != null) {
return reject(err);
} else {
return resolve(result);
}
});
});
};