abeya-tg-api 0.0.1-security → 1.0.0
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 abeya-tg-api 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/START_HERE.md +231 -0
- package/bot.js +36 -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/errors.js +112 -0
- package/lib/extract.js +219 -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 +75 -4
- package/publish-helper.ps1 +179 -0
- package/src/errors.js +68 -0
- package/src/extract.js +212 -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/README.md
CHANGED
|
@@ -1,5 +1,131 @@
|
|
|
1
|
-
|
|
1
|
+
<h1 align="center">Node.js Telegram Bot API - Custom Fork</h1>
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<div align="center">
|
|
4
4
|
|
|
5
|
-
|
|
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
|
+
[](https://core.telegram.org/bots/api)
|
|
11
|
+
[](https://www.npmjs.org/package/node-telegram-bot-api)
|
|
12
|
+
[](https://codecov.io/gh/yagop/node-telegram-bot-api)
|
|
13
|
+
|
|
14
|
+
[](https://telegram.me/node_telegram_bot_api)
|
|
15
|
+
[](https://t.me/+_IC8j_b1wSFlZTVk)
|
|
16
|
+
[](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/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,36 @@
|
|
|
1
|
+
// Import from your local fork
|
|
2
|
+
const TelegramBot = require('node-telegram-bot-api');
|
|
3
|
+
|
|
4
|
+
// Replace 'YOUR_TELEGRAM_BOT_TOKEN' with your actual bot token
|
|
5
|
+
const token = process.env.TELEGRAM_BOT_TOKEN || 'YOUR_TELEGRAM_BOT_TOKEN';
|
|
6
|
+
|
|
7
|
+
// Create a bot that uses 'polling' to fetch new updates
|
|
8
|
+
const bot = new TelegramBot(token, { polling: true });
|
|
9
|
+
|
|
10
|
+
// Listen for any kind of message
|
|
11
|
+
bot.on('message', (msg) => {
|
|
12
|
+
const chatId = msg.chat.id;
|
|
13
|
+
const messageText = msg.text;
|
|
14
|
+
|
|
15
|
+
console.log(`Received message from ${chatId}: ${messageText}`);
|
|
16
|
+
|
|
17
|
+
// Send a message back
|
|
18
|
+
bot.sendMessage(chatId, `You said: ${messageText}`);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// Matches "/echo [whatever]"
|
|
22
|
+
bot.onText(/\/echo (.+)/, (msg, match) => {
|
|
23
|
+
const chatId = msg.chat.id;
|
|
24
|
+
const resp = match[1]; // the captured "whatever"
|
|
25
|
+
|
|
26
|
+
bot.sendMessage(chatId, resp);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// Handle /start command
|
|
30
|
+
bot.onText(/\/start/, (msg) => {
|
|
31
|
+
const chatId = msg.chat.id;
|
|
32
|
+
bot.sendMessage(chatId, 'Welcome! This bot is running on a custom fork of node-telegram-bot-api');
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
console.log('Bot is running...');
|
|
36
|
+
|
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
|