Skip to content

Commit e5ec053

Browse files
committed
chore: init
0 parents  commit e5ec053

13 files changed

+4405
-0
lines changed

.gitattributes

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

.gitignore

+134
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
lerna-debug.log*
8+
.pnpm-debug.log*
9+
10+
# Diagnostic reports (https://nodejs.org/api/report.html)
11+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
12+
13+
# Runtime data
14+
pids
15+
*.pid
16+
*.seed
17+
*.pid.lock
18+
19+
# Directory for instrumented libs generated by jscoverage/JSCover
20+
lib-cov
21+
22+
# Coverage directory used by tools like istanbul
23+
coverage
24+
*.lcov
25+
26+
# nyc test coverage
27+
.nyc_output
28+
29+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
30+
.grunt
31+
32+
# Bower dependency directory (https://bower.io/)
33+
bower_components
34+
35+
# node-waf configuration
36+
.lock-wscript
37+
38+
# Compiled binary addons (https://nodejs.org/api/addons.html)
39+
build/Release
40+
41+
# Dependency directories
42+
node_modules/
43+
jspm_packages/
44+
45+
# Snowpack dependency directory (https://snowpack.dev/)
46+
web_modules/
47+
48+
# TypeScript cache
49+
*.tsbuildinfo
50+
51+
# Optional npm cache directory
52+
.npm
53+
54+
# Optional eslint cache
55+
.eslintcache
56+
57+
# Optional stylelint cache
58+
.stylelintcache
59+
60+
# Microbundle cache
61+
.rpt2_cache/
62+
.rts2_cache_cjs/
63+
.rts2_cache_es/
64+
.rts2_cache_umd/
65+
66+
# Optional REPL history
67+
.node_repl_history
68+
69+
# Output of 'npm pack'
70+
*.tgz
71+
72+
# Yarn Integrity file
73+
.yarn-integrity
74+
75+
# dotenv environment variable files
76+
.env
77+
.env.development.local
78+
.env.test.local
79+
.env.production.local
80+
.env.local
81+
82+
# parcel-bundler cache (https://parceljs.org/)
83+
.cache
84+
.parcel-cache
85+
86+
# Next.js build output
87+
.next
88+
out
89+
90+
# Nuxt.js build / generate output
91+
.nuxt
92+
dist
93+
94+
# Gatsby files
95+
.cache/
96+
# Comment in the public line in if your project uses Gatsby and not Next.js
97+
# https://nextjs.org/blog/next-9-1#public-directory-support
98+
# public
99+
100+
# vuepress build output
101+
.vuepress/dist
102+
103+
# vuepress v2.x temp and cache directory
104+
.temp
105+
.cache
106+
107+
# Docusaurus cache and generated files
108+
.docusaurus
109+
110+
# Serverless directories
111+
.serverless/
112+
113+
# FuseBox cache
114+
.fusebox/
115+
116+
# DynamoDB Local files
117+
.dynamodb/
118+
119+
# TernJS port file
120+
.tern-port
121+
122+
# Stores VSCode versions used for testing VSCode extensions
123+
.vscode-test
124+
125+
# yarn v2
126+
.yarn/cache
127+
.yarn/unplugged
128+
.yarn/build-state.yml
129+
.yarn/install-state.gz
130+
.pnp.*
131+
.DS_Store
132+
.idea
133+
.changeset
134+
package-lock.json

.npmignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/src
2+
/node_modules
3+
.idea
4+
.changeset
5+
.DS_Store
6+
tsconfig.json
7+
tsup.config.ts

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 hunghg255
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<p align="center">
2+
<a href="https://www.npmjs.com/package/telegram-sdk" target="_blank" rel="noopener noreferrer">
3+
<img src="https://api.iconify.design/logos:telegram.svg?color=%23bbdf58" alt="logo" width='100'/></a>
4+
</p>
5+
6+
<p align="center">
7+
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.
8+
</p>
9+
10+
<p align="center">
11+
<a href="https://www.npmjs.com/package/telegram-sdk" target="_blank" rel="noopener noreferrer"><img src="https://badge.fury.io/js/telegram-sdk.svg" alt="NPM Version" /></a>
12+
<a href="https://www.npmjs.com/package/telegram-sdk" target="_blank" rel="noopener noreferrer"><img src="https://img.shields.io/npm/dt/telegram-sdk.svg?logo=npm" alt="NPM Downloads" /></a>
13+
<a href="https://bundlephobia.com/result?p=telegram-sdk" target="_blank" rel="noopener noreferrer"><img src="https://img.shields.io/bundlephobia/minzip/telegram-sdk" alt="Minizip" /></a>
14+
<a href="https://github.com/hunghg255/telegram-sdk/graphs/contributors" target="_blank" rel="noopener noreferrer"><img src="https://img.shields.io/badge/all_contributors-1-orange.svg" alt="Contributors" /></a>
15+
<a href="https://github.com/hunghg255/telegram-sdk/blob/main/LICENSE" target="_blank" rel="noopener noreferrer"><img src="https://badgen.net/github/license/hunghg255/telegram-sdk" alt="License" /></a>
16+
</p>
17+
18+
19+
20+
## Installation
21+
22+
```bash
23+
pnpm add telegram-sdk
24+
```
25+
you don't need to install the Telegram JS module separately, as it is included in this package.
26+
27+
## Setup
28+
29+
- Import core module in root file of your project.
30+
31+
```ts
32+
import 'telegram-sdk/core';
33+
```
34+
35+
36+
## Usage
37+
38+
- Use the API provided by the Telegram JS module.
39+
40+
```typescript
41+
import { WebApp, WebView } from 'telegram-sdk';
42+
43+
// to display the initData
44+
console.log(WebApp.initData);
45+
46+
// to show the main button
47+
WebApp.MainButton.show();
48+
49+
// to set the app background color
50+
WebApp.setBackgroundColor('#f60000')
51+
52+
// to set the app header color
53+
WebApp.setHeaderColor('bg_color');
54+
55+
// Display a simple view
56+
WebView.postEvent('web_app_setup_swipe_behavior', false, {
57+
allow_vertical_swipe: false,
58+
});
59+
```
60+
61+
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.

package.json

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{
2+
"name": "telegram-sdk",
3+
"version": "0.0.3",
4+
"description": "Telegram Web App - (Uses July 7, 2024, Bot API 7.7)",
5+
"main": "dist/index.js",
6+
"module": "dist/index.mjs",
7+
"types": "dist/index.d.ts",
8+
"exports": {
9+
".": {
10+
"import": {
11+
"types": "./dist/index.d.mts",
12+
"default": "./dist/index.mjs"
13+
},
14+
"require": {
15+
"types": "./dist/index.d.ts",
16+
"default": "./dist/index.js"
17+
}
18+
},
19+
"./core": {
20+
"import": {
21+
"types": "./dist/core.d.mts",
22+
"default": "./dist/core.mjs"
23+
},
24+
"require": {
25+
"types": "./dist/core.d.ts",
26+
"default": "./dist/core.js"
27+
}
28+
},
29+
"./package.json": "./package.json"
30+
},
31+
"scripts": {
32+
"build": "tsup"
33+
},
34+
"repository": {
35+
"type": "git",
36+
"url": "git+https://github.com/hunghg255/telegram-sdk.git"
37+
},
38+
"files": [
39+
"dist"
40+
],
41+
"keywords": [
42+
"telegram-web-app",
43+
"telegram-mini-app",
44+
"telegram",
45+
"telegram-bot",
46+
"telegram web apps",
47+
"telegram mini apps",
48+
"telegram bot",
49+
"telegram bot api",
50+
"telegram-sdk"
51+
],
52+
"author": "hunghg255",
53+
"license": "MIT",
54+
"bugs": {
55+
"url": "https://github.com/hunghg255/telegram-sdk/issues"
56+
},
57+
"homepage": "https://github.com/hunghg255/telegram-sdk#readme",
58+
"devDependencies": {
59+
"tsup": "^8.2.3",
60+
"typescript": "^5.5.4"
61+
}
62+
}

0 commit comments

Comments
 (0)