Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hunghg255/telegram-sdk
This repository offers an npm package for developing web applications for your Telegram bot.
https://github.com/hunghg255/telegram-sdk
biometricmanager disableverticalswipes sdk telegram telegram-api telegram-bot telegram-bot-api telegram-bots telegram-sdk telegramapi telegrambot
Last synced: 3 months ago
JSON representation
This repository offers an npm package for developing web applications for your Telegram bot.
- Host: GitHub
- URL: https://github.com/hunghg255/telegram-sdk
- Owner: hunghg255
- License: mit
- Created: 2024-07-29T09:12:14.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-07-29T10:35:49.000Z (7 months ago)
- Last Synced: 2024-11-15T22:13:38.187Z (3 months ago)
- Topics: biometricmanager, disableverticalswipes, sdk, telegram, telegram-api, telegram-bot, telegram-bot-api, telegram-bots, telegram-sdk, telegramapi, telegrambot
- Language: JavaScript
- Homepage:
- Size: 70.3 KB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
This repository offers an npm package for developing web applications for your Telegram bot. It re-exports the API provided by Telegram's JS module. The benefit of this package is that it includes TypeScript types, simplifying project setup.## Installation
```bash
pnpm add telegram-sdk
```
you don't need to install the Telegram JS module separately, as it is included in this package.## Setup
- Import core module in root file of your project.
```ts
import 'telegram-sdk/core';
```## Usage
- Use the API provided by the Telegram JS module.
```typescript
import { WebApp, WebView } from 'telegram-sdk';// to display the initData
console.log(WebApp.initData);// to show the main button
WebApp.MainButton.show();// to set the app background color
WebApp.setBackgroundColor('#f60000')// to set the app header color
WebApp.setHeaderColor('bg_color');// Display a swipe vertical by event
WebView.postEvent('web_app_setup_swipe_behavior', false, {
allow_vertical_swipe: false,
});// ready method must come last
WebApp.ready();
```## disableVerticalSwipes
```ts
import { WebApp, WebView } from 'telegram-sdk';// Config something...
WebApp.expand(); // Expand app
WebApp.disableClosingConfirmation();
WebApp.disableVerticalSwipes(); // Disable Vertical Swiper// ready method must come last
WebApp.ready();
```## Documentation
- Refer to the official [Telegram documentation](https://core.telegram.org/bots/webapps#initializing-web-apps) for Web Apps to explore additional features available through WebApp.
- Core script is available in the [Telegram JS module](https://telegram.org/js/telegram-web-app.js)