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/.github/ISSUE_TEMPLATE.md +68 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +23 -0
- package/CHANGELOG.md +565 -0
- package/CODE_OF_CONDUCT.md +74 -0
- package/CONTRIBUTING.md +45 -0
- package/FORK_GUIDE.md +223 -0
- package/LICENSE.md +21 -0
- package/PUBLISHING_CHECKLIST.md +167 -0
- package/QUICK_START.md +96 -0
- package/README.md +129 -3
- package/README_FORK_SETUP.md +156 -0
- package/SETUP_GUIDE.md +211 -0
- package/START_HERE.md +231 -0
- package/bot.js +38 -0
- package/doc/api.hbs +19 -0
- package/doc/api.md +2772 -12
- package/doc/experimental.md +28 -0
- package/doc/help.md +151 -0
- package/doc/tutorials.md +12 -0
- package/doc/usage.md +269 -0
- package/index.js +13 -0
- package/lib/dependencies.js +371 -0
- package/lib/errors.js +112 -0
- package/lib/telegram.js +4741 -0
- package/lib/telegramPolling.js +245 -0
- package/lib/telegramWebHook.js +192 -0
- package/lib/utils.js +7 -0
- package/package.json +78 -4
- package/publish-helper.ps1 +179 -0
- package/src/dependencies.js +354 -0
- package/src/errors.js +68 -0
- package/src/telegram.js +3838 -0
- package/src/telegramPolling.js +202 -0
- package/src/telegramWebHook.js +158 -0
- package/src/utils.js +3 -0
- package/test-bot-example.js +71 -0
package/START_HERE.md
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
# 🎉 START HERE - Your Custom Fork Setup Complete!
|
|
2
|
+
|
|
3
|
+
## ✅ Setup Status: COMPLETE
|
|
4
|
+
|
|
5
|
+
Your fork of `node-telegram-bot-api` is **fully configured** and ready to use!
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
Package Name: myown-node-telegram-bot-api
|
|
9
|
+
Version: 1.0.0
|
|
10
|
+
Status: ✓ Built Successfully
|
|
11
|
+
Dependencies: ✓ Installed
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## 🚀 Quick Start (Choose One)
|
|
17
|
+
|
|
18
|
+
### Option 1: Test It Right Now (5 minutes) ⚡
|
|
19
|
+
|
|
20
|
+
1. Get a bot token from [@BotFather](https://t.me/BotFather) on Telegram
|
|
21
|
+
2. Open `test-bot-example.js`
|
|
22
|
+
3. Replace `'YOUR_BOT_TOKEN'` with your token
|
|
23
|
+
4. Run:
|
|
24
|
+
```bash
|
|
25
|
+
node test-bot-example.js
|
|
26
|
+
```
|
|
27
|
+
5. Message your bot on Telegram!
|
|
28
|
+
|
|
29
|
+
### Option 2: Publish to NPM (15 minutes) 📦
|
|
30
|
+
|
|
31
|
+
**Use the automated helper:**
|
|
32
|
+
```powershell
|
|
33
|
+
.\publish-helper.ps1
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**Or follow the manual checklist:**
|
|
37
|
+
- See `PUBLISHING_CHECKLIST.md` for step-by-step instructions
|
|
38
|
+
|
|
39
|
+
### Option 3: Customize First (Your time) 🛠️
|
|
40
|
+
|
|
41
|
+
1. Edit files in `src/` directory
|
|
42
|
+
2. Build: `npm run build`
|
|
43
|
+
3. Test: `node test-bot-example.js`
|
|
44
|
+
4. Repeat!
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## 📚 Documentation Files
|
|
49
|
+
|
|
50
|
+
| File | Purpose |
|
|
51
|
+
|------|---------|
|
|
52
|
+
| 📖 **START_HERE.md** (this file) | Quick overview and next steps |
|
|
53
|
+
| ⚡ **QUICK_START.md** | Fast reference guide |
|
|
54
|
+
| 📘 **FORK_GUIDE.md** | Comprehensive publishing guide |
|
|
55
|
+
| ✅ **PUBLISHING_CHECKLIST.md** | Step-by-step checklist |
|
|
56
|
+
| 🤖 **test-bot-example.js** | Simple bot to test locally |
|
|
57
|
+
| 🔧 **publish-helper.ps1** | Automated publishing assistant |
|
|
58
|
+
| 📄 **README.md** | Main project documentation |
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## 🎯 What You Need to Do
|
|
63
|
+
|
|
64
|
+
### Required Before Publishing:
|
|
65
|
+
|
|
66
|
+
1. **Update Author Information** (2 minutes)
|
|
67
|
+
- Open `package.json`
|
|
68
|
+
- Line 26: Change `"author": "Your Name <your-email@example.com>"`
|
|
69
|
+
|
|
70
|
+
2. **Update GitHub Username** (1 minute)
|
|
71
|
+
- Open `package.json`
|
|
72
|
+
- Lines 68, 71, 73: Replace `YOUR-USERNAME` with your GitHub username
|
|
73
|
+
|
|
74
|
+
3. **Verify Package Name** (30 seconds)
|
|
75
|
+
```bash
|
|
76
|
+
npm view myown-node-telegram-bot-api
|
|
77
|
+
```
|
|
78
|
+
- If it shows 404: ✓ Name is available!
|
|
79
|
+
- If it shows package info: ✗ Name is taken, choose another
|
|
80
|
+
|
|
81
|
+
### Optional But Recommended:
|
|
82
|
+
|
|
83
|
+
4. **Create GitHub Repository**
|
|
84
|
+
- Go to https://github.com/new
|
|
85
|
+
- Name: `myown-node-telegram-bot-api`
|
|
86
|
+
- Don't initialize with README
|
|
87
|
+
|
|
88
|
+
5. **Test Locally**
|
|
89
|
+
- Follow "Option 1" above to test your bot
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## 📦 Publishing Commands (When Ready)
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
# 1. Login to NPM (first time only)
|
|
97
|
+
npm login
|
|
98
|
+
|
|
99
|
+
# 2. Build the project
|
|
100
|
+
npm run build
|
|
101
|
+
|
|
102
|
+
# 3. Publish
|
|
103
|
+
npm publish --access public
|
|
104
|
+
|
|
105
|
+
# 4. Verify it worked
|
|
106
|
+
npm view myown-node-telegram-bot-api
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
**After publishing, anyone can install it:**
|
|
110
|
+
```bash
|
|
111
|
+
npm install myown-node-telegram-bot-api
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## 🎨 Making Custom Changes
|
|
117
|
+
|
|
118
|
+
### Edit Source Code:
|
|
119
|
+
```
|
|
120
|
+
src/
|
|
121
|
+
├── telegram.js ← Main bot class (start here!)
|
|
122
|
+
├── telegramPolling.js ← Polling implementation
|
|
123
|
+
├── telegramWebHook.js ← Webhook implementation
|
|
124
|
+
└── utils.js ← Utility functions
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### After Each Change:
|
|
128
|
+
```bash
|
|
129
|
+
npm run build # Compile src/ → lib/
|
|
130
|
+
node test-bot-example.js # Test your changes
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## 🔄 Update & Republish Workflow
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
# 1. Make changes in src/
|
|
139
|
+
# 2. Build
|
|
140
|
+
npm run build
|
|
141
|
+
|
|
142
|
+
# 3. Test
|
|
143
|
+
npm test
|
|
144
|
+
|
|
145
|
+
# 4. Update version
|
|
146
|
+
npm version patch # 1.0.0 → 1.0.1 (bug fixes)
|
|
147
|
+
# OR
|
|
148
|
+
npm version minor # 1.0.0 → 1.1.0 (new features)
|
|
149
|
+
# OR
|
|
150
|
+
npm version major # 1.0.0 → 2.0.0 (breaking changes)
|
|
151
|
+
|
|
152
|
+
# 5. Publish
|
|
153
|
+
npm publish
|
|
154
|
+
|
|
155
|
+
# 6. Push to GitHub
|
|
156
|
+
git push && git push --tags
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## ⚡ Quick Commands
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
# Build project
|
|
165
|
+
npm run build
|
|
166
|
+
|
|
167
|
+
# Run tests
|
|
168
|
+
npm test
|
|
169
|
+
|
|
170
|
+
# Lint code
|
|
171
|
+
npm run eslint
|
|
172
|
+
|
|
173
|
+
# Check NPM login
|
|
174
|
+
npm whoami
|
|
175
|
+
|
|
176
|
+
# Test bot locally
|
|
177
|
+
node test-bot-example.js
|
|
178
|
+
|
|
179
|
+
# Use automated helper
|
|
180
|
+
.\publish-helper.ps1
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## 🆘 Need Help?
|
|
186
|
+
|
|
187
|
+
### Quick References:
|
|
188
|
+
- **Publishing questions?** → See `PUBLISHING_CHECKLIST.md`
|
|
189
|
+
- **Detailed guide?** → See `FORK_GUIDE.md`
|
|
190
|
+
- **Fast lookup?** → See `QUICK_START.md`
|
|
191
|
+
|
|
192
|
+
### External Resources:
|
|
193
|
+
- [NPM Publishing Guide](https://docs.npmjs.com/packages-and-modules/contributing-packages-to-the-registry)
|
|
194
|
+
- [Original node-telegram-bot-api Docs](https://github.com/yagop/node-telegram-bot-api)
|
|
195
|
+
- [Telegram Bot API](https://core.telegram.org/bots/api)
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
## 💡 Pro Tips
|
|
200
|
+
|
|
201
|
+
1. **Always test before publishing**: Run `npm test` and test with `test-bot-example.js`
|
|
202
|
+
2. **Use semantic versioning**: Let users know what changed
|
|
203
|
+
3. **Keep changelog updated**: Document your custom features
|
|
204
|
+
4. **Credit the original**: Keep the MIT license and attribution
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
## 🎊 You're Ready to Go!
|
|
209
|
+
|
|
210
|
+
Your custom fork is:
|
|
211
|
+
- ✅ Configured with a unique package name
|
|
212
|
+
- ✅ Built and working
|
|
213
|
+
- ✅ Ready to customize
|
|
214
|
+
- ✅ Ready to publish
|
|
215
|
+
|
|
216
|
+
**Choose your path above and get started!** 🚀
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
## 📞 Support
|
|
221
|
+
|
|
222
|
+
- **Original API Issues**: https://github.com/yagop/node-telegram-bot-api/issues
|
|
223
|
+
- **NPM Help**: https://docs.npmjs.com/
|
|
224
|
+
- **Telegram Bot API**: https://core.telegram.org/bots
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
<p align="center">
|
|
229
|
+
<strong>Happy Coding! 🤖</strong>
|
|
230
|
+
</p>
|
|
231
|
+
|
package/bot.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// Import from your local fork
|
|
4
|
+
const TelegramBot = require('./index.js');
|
|
5
|
+
|
|
6
|
+
// Replace 'YOUR_TELEGRAM_BOT_TOKEN' with your actual bot token
|
|
7
|
+
const token = process.env.TELEGRAM_BOT_TOKEN || '8201276291:AAFZkFZOKvUAQYpCBcw4VTZpxXUG8emnCqs';
|
|
8
|
+
|
|
9
|
+
// Create a bot that uses 'polling' to fetch new updates
|
|
10
|
+
const bot = new TelegramBot(token, { polling: true });
|
|
11
|
+
|
|
12
|
+
// Listen for any kind of message
|
|
13
|
+
bot.on('message', (msg) => {
|
|
14
|
+
const chatId = msg.chat.id;
|
|
15
|
+
const messageText = msg.text;
|
|
16
|
+
|
|
17
|
+
console.log(`Received message from ${chatId}: ${messageText}`);
|
|
18
|
+
|
|
19
|
+
// Send a message back
|
|
20
|
+
bot.sendMessage(chatId, `You said: ${messageText}`);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// Matches "/echo [whatever]"
|
|
24
|
+
bot.onText(/\/echo (.+)/, (msg, match) => {
|
|
25
|
+
const chatId = msg.chat.id;
|
|
26
|
+
const resp = match[1]; // the captured "whatever"
|
|
27
|
+
|
|
28
|
+
bot.sendMessage(chatId, resp);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
// Handle /start command
|
|
32
|
+
bot.onText(/\/start/, (msg) => {
|
|
33
|
+
const chatId = msg.chat.id;
|
|
34
|
+
bot.sendMessage(chatId, 'Welcome! This bot is running on a custom fork of node-telegram-bot-api');
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
console.log('Bot is running...');
|
|
38
|
+
|
package/doc/api.hbs
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# API Reference
|
|
2
|
+
|
|
3
|
+
**Note:** If you are looking for available [events](usage.md#events) or usage of api, please refer [`usage.md`](usage.md).
|
|
4
|
+
|
|
5
|
+
{{#class name="TelegramBot"~}}
|
|
6
|
+
{{>header~}}
|
|
7
|
+
{{>body~}}
|
|
8
|
+
{{>member-index~}}
|
|
9
|
+
{{>members~}}
|
|
10
|
+
{{/class}}
|
|
11
|
+
* * *
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
[usage-sending-files-performance]:https://github.com/yagop/node-telegram-bot-api/tree/master/doc/usage.md#sending-files-performance
|
|
15
|
+
[setWebHook-v0.25.0]:https://github.com/yagop/node-telegram-bot-api/tree/4e5a493cadfaad5589a8d79e55d9e0d103000ce4#telegrambotsetwebhookurl-cert
|
|
16
|
+
[getUpdates-v0.25.0]:https://github.com/yagop/node-telegram-bot-api/tree/4e5a493cadfaad5589a8d79e55d9e0d103000ce4#TelegramBot+getUpdates
|
|
17
|
+
[getUserProfilePhotos-v0.25.0]:https://github.com/yagop/node-telegram-bot-api/tree/4e5a493cadfaad5589a8d79e55d9e0d103000ce4#TelegramBot+getUserProfilePhotos
|
|
18
|
+
[answerCallbackQuery-v0.27.1]:https://github.com/yagop/node-telegram-bot-api/blob/v0.27.1/doc/api.md#TelegramBot+answerCallbackQuery
|
|
19
|
+
[answerCallbackQuery-v0.29.0]:https://github.com/yagop/node-telegram-bot-api/blob/v0.29.0/doc/api.md#TelegramBot+answerCallbackQuery
|