@@ -14,7 +14,7 @@ and manage customization through messages and buttons on Telegram.
14
14
## 📝 Information
15
15
16
16
- Send notifications of your GitHub/GitLab repositories to Telegram Bots, Groups, Super Groups (Multiple Topics), and Channels.
17
- - The bot must be created using the [ BotFather] ( https://core.telegram.org/bots#6-botfather )
17
+ - The bot must be created using the [ BotFather] ( https://core.telegram.org/bots#6-botfather )
18
18
19
19
## 🎉 Features
20
20
@@ -34,8 +34,8 @@ and manage customization through messages and buttons on Telegram.
34
34
35
35
4 . ** Event Management** : You can manage specific events that you want to receive notifications for, allowing you to focus on what's most important for your projects.
36
36
37
- - Support for multiple platforms: GitHub and GitLab.
38
- - Manage event notifications separately between platforms.
37
+ - Support for multiple platforms: GitHub and GitLab.
38
+ - Manage event notifications separately between platforms.
39
39
40
40
<p align =" center " >
41
41
<img alt =" Event Management to Telegram " src =" https://github.com/lbiltech/telegram-git-notifier-app/assets/35853002/e217a2ad-49b5-4936-a2cd-fe4af66e2bfb " />
@@ -54,16 +54,16 @@ and manage customization through messages and buttons on Telegram.
54
54
[ // ] : # ( features image )
55
55
56
56
7 . ** For premium users, you can use the following features:**
57
- - ** Support for multiple topics** : You can add multiple topics to the ` .env ` file.
58
- These topics will be the topics of your supergroups.
57
+ - ** Support for multiple topics** : You can add multiple topics to the ` .env ` file.
58
+ These topics will be the topics of your supergroups.
59
59
60
60
[ // ] : # ( features image )
61
61
62
62
## 📋 Requirements
63
63
64
64
- PHP ^8.0
65
- - [ Composer] ( https://getcomposer.org/ )
66
- - Core: [ Telegram Git Notifier] ( https://github.com/lbiltech/telegram-git-notifier )
65
+ - [ Composer] ( https://getcomposer.org/ )
66
+ - Core: [ Telegram Git Notifier] ( https://github.com/lbiltech/telegram-git-notifier )
67
67
68
68
## 🔧 Installation
69
69
@@ -95,46 +95,46 @@ and the environment file `.env` will be created automatically.
95
95
Some of the JSON files will be created automatically in the ` storage ` directory.
96
96
These files are used to store the data and serve for features in this bot.
97
97
98
- ### Create a New Bot
98
+ #### 1. Create a New Bot
99
99
100
100
To create a new bot, you need to talk to [ BotFather] ( https://core.telegram.org/bots#6-botfather ) and follow a few simple steps.
101
101
102
102
1 . Open a chat with [ BotFather] ( https://telegram.me/botfather ) and send ` /newbot ` command.
103
- 2 . Enter a friendly name for your bot. This name will be displayed in contact details and elsewhere.
104
- 3 . Enter a unique username for your bot. It must end in ` bot ` . Like this, for example: ` TetrisBot ` or ` tetris_bot ` .
105
- 4 . Copy the HTTP API access token provided by [ BotFather] ( https://telegram.me/botfather ) and paste it into your ` .env ` file.
103
+ 2 . Enter a friendly name for your bot. This name will be displayed in contact details and elsewhere.
104
+ 3 . Enter a unique username for your bot. It must end in ` bot ` . Like this, for example: ` TetrisBot ` or ` tetris_bot ` .
105
+ 4 . Copy the HTTP API access token provided by [ BotFather] ( https://telegram.me/botfather ) and paste it into your ` .env ` file.
106
106
107
107
``` dotenv
108
108
TELEGRAM_BOT_TOKEN=123456789:ABCDEFGHIJKLMNOPQRSTUVWXYZ
109
109
```
110
110
111
- ### Get your Chat ID and add it to the .env file
111
+ #### 2. Set up your domain and SSL certificate
112
112
113
- 1 . Open a chat with your bot.
114
- 2 . Send any message to your bot. (This handle needs to get your chat ID)
115
- 3 . Go to the following URL: ` https://api.telegram.org/bot<YourTelegramBotToken>/getUpdates `
116
- 4 . Look for the ` "chat":{"id": ` field and copy the number after it. This is your Chat ID.
117
- 5 . Paste the Chat ID in your ` .env ` file.
118
-
119
- ``` dotenv
120
- TELEGRAM_BOT_CHAT_ID=123456789
121
- ```
122
-
123
- ### Set up your domain and SSL certificate
124
-
125
- ** We recommend that you use HTTPS to set up your domain and webhook.**
113
+ ** We recommend that you use HTTPS to set up your domain and webhook.**
126
114
You can build your own server or use a service like [ Heroku] ( https://www.heroku.com/ ) .
127
115
128
116
In this example, we will use localhost and [ ngrok] ( https://ngrok.com/ ) to set up the domain and webhook:
129
117
1 . Download and install [ ngrok] ( https://ngrok.com/download ) .
130
- 2 . Go to this project directory and run the command in the terminal: ` php -S localhost:8000 `
131
- 3 . Continue to run the command in the terminal: ` ngrok http 8000 `
132
- 4 . Copy the HTTPS URL provided by ngrok and paste it into your ` .env ` file.
118
+ 2 . Go to this project directory and run the command in the terminal: ` php -S localhost:8000 `
119
+ 3 . Continue to run the command in the terminal: ` ngrok http 8000 `
120
+ 4 . Copy the HTTPS URL provided by ngrok and paste it into your ` .env ` file.
133
121
134
122
``` dotenv
135
123
TGN_APP_URL=https://123456789.ngrok.io
136
124
```
137
125
126
+ #### 3. Get your Chat ID and add it to the .env file
127
+
128
+ 1 . Open a chat with your bot.
129
+ 2 . Send any message to your bot. (This handle needs to get your chat ID)
130
+ 3 . Go to the following URL: ` <TGN_APP_URL>/webhook/getUpdate.php `
131
+ 4 . Look for the ` "chat":{"id": ` field and copy the number after it. This is your Chat ID.
132
+ 5 . Paste the Chat ID in your ` .env ` file.
133
+
134
+ ``` dotenv
135
+ TELEGRAM_BOT_CHAT_ID=123456789
136
+ ```
137
+
138
138
At this time, the source launch process is done, please skip way 2 and go to step [ II. Set the webhook] ( #ii-set-the-webhook ) to continue.
139
139
140
140
</details >
@@ -160,7 +160,7 @@ cd telegram-git-notifier-app
160
160
cp .env.example .env
161
161
```
162
162
163
- ### Update the environment variables
163
+ #### 1. Update the environment variables
164
164
165
165
Open the ` .env ` file and update the following variables:
166
166
@@ -169,16 +169,16 @@ PHP_VERSION_SELECTED=8.2
169
169
APP_PORT=3180
170
170
171
171
# You can customize the container name to suit your needs using GitHub and GitLab
172
- CONTAINER_NAME=telegram-notify-bot
172
+ CONTAINER_NAME=tgn-app
173
173
```
174
174
175
175
> ** Note:**
176
176
>
177
177
> - The ` PHP_VERSION_SELECTED ` variable is the PHP version you want to use in the container.
178
- > - The ` APP_PORT ` variable is the port of the container. (Please don't set the same port as the host)
179
- > - The ` CONTAINER_NAME ` variable is the name of the container you want to create.
178
+ > - The ` APP_PORT ` variable is the port of the container. (Please don't set the same port as the host)
179
+ > - The ` CONTAINER_NAME ` variable is the name of the container you want to create.
180
180
181
- ### Install and run the container
181
+ #### 2. Install and run the container
182
182
183
183
Run the following command to install and run the container:
184
184
@@ -189,33 +189,22 @@ bash ./docker.sh
189
189
Some of the JSON files will be created automatically in the ` storage ` directory.
190
190
These files are used to store the data and serve for features in this bot.
191
191
192
- ### Create a New Bot
192
+ #### 3. Create a New Bot
193
193
194
194
To create a new bot,
195
195
you need to talk to [ BotFather] ( https://core.telegram.org/bots#6-botfather ) and follow a few simple steps.
196
196
197
197
1 . Open a chat with [ BotFather] ( https://telegram.me/botfather ) and send ` /newbot ` command.
198
- 2 . Enter a friendly name for your bot. This name will be displayed in contact details and elsewhere.
199
- 3 . Enter a unique username for your bot. It must end in ` bot ` . Like this, for example: ` TetrisBot ` or ` tetris_bot ` .
200
- 4 . Copy the HTTP API access token provided by [ BotFather] ( https://telegram.me/botfather ) and paste it into your ` .env ` file.
198
+ 2 . Enter a friendly name for your bot. This name will be displayed in contact details and elsewhere.
199
+ 3 . Enter a unique username for your bot. It must end in ` bot ` . Like this, for example: ` TetrisBot ` or ` tetris_bot ` .
200
+ 4 . Copy the HTTP API access token provided by [ BotFather] ( https://telegram.me/botfather ) and paste it into your ` .env ` file.
201
201
202
202
``` dotenv
203
203
TELEGRAM_BOT_TOKEN=123456789:ABCDEFGHIJKLMNOPQRSTUVWXYZ
204
204
```
205
205
206
- ### Get your Chat ID and add it to the .env file
207
-
208
- 1 . Open a chat with your bot.
209
- 2 . Send any message to your bot. (This handle needs to get your chat ID)
210
- 3 . Go to the following URL: ` https://api.telegram.org/bot<YourTelegramBotToken>/getUpdates `
211
- 4 . Look for the ` "chat":{"id": ` field and copy the number after it. This is your Chat ID.
212
- 5 . Paste the Chat ID in your ` .env ` file.
213
-
214
- ``` dotenv
215
- TELEGRAM_BOT_CHAT_ID=123456789
216
- ```
217
206
218
- ### Set up your domain and SSL certificate
207
+ #### 4. Set up your domain and SSL certificate
219
208
220
209
In this way, we use the proxy in the container and [ ngrok] ( https://ngrok.com/ ) to set up the domain and webhook:
221
210
1 . Check the proxy of the container: ` docker inspect <CONTAINER_NAME>-nginx | grep IPAddress `
@@ -227,7 +216,7 @@ Example:
227
216
![ image] ( https://github.com/lbiltech/lemp-docker/assets/35853002/8dc8ba3f-b1e9-4bff-901d-6bb7747acda4 )
228
217
229
218
2 . Download and install [ ngrok] ( https://ngrok.com/download ) .
230
- 2 . Continue to run the command in the terminal: ` ngrok http <CONTAINER_IP> `
219
+ 2 . Continue to run the command in the terminal: ` ngrok http <CONTAINER_IP> `
231
220
232
221
> ** Note:** Replace ` <CONTAINER_IP> ` is the IP address of the container in step 1.
233
222
@@ -240,7 +229,19 @@ ngrok http 172.28.0.3
240
229
3 . Copy the HTTPS URL provided by ngrok and paste it into your ` .env ` file.
241
230
242
231
``` dotenv
243
- APP_URL=https://123456789.ngrok-free.app
232
+ TGN_APP_URL=https://123456789.ngrok-free.app
233
+ ```
234
+
235
+ #### 5. Get your Chat ID and add it to the .env file
236
+
237
+ 1 . Open a chat with your bot.
238
+ 2 . Send any message to your bot. (This handle needs to get your chat ID)
239
+ 3 . Go to the following URL: ` <TGN_APP_URL>/webhook/getUpdate.php `
240
+ 4 . Look for the ` "chat":{"id": ` field and copy the number after it. This is your Chat ID.
241
+ 5 . Paste the Chat ID in your ` .env ` file.
242
+
243
+ ``` dotenv
244
+ TELEGRAM_BOT_CHAT_ID=123456789
244
245
```
245
246
246
247
</details >
@@ -281,38 +282,69 @@ https://api.telegram.org/bot<YourTelegramBotToken>/setWebhook?url=<APP_URL>
281
282
282
283
### III. Add chat IDs you want to receive notifications to the .env file
283
284
284
- You can add multiple chat IDs to the ` .env ` file.
285
+ #### 1. Add multiple chat IDs to the ` .env ` file.
285
286
286
287
** These chat IDs will be the chat IDs of your groups, channels, or users.**
287
288
288
289
Also, you can add ** the chat ID of this bot** to receive incoming notifications for itself.
289
290
290
291
``` dotenv
291
- TELEGRAM_NOTIFY_CHAT_IDS="-978339113,-1001933979183"
292
+ TELEGRAM_NOTIFY_CHAT_IDS="-978339113;-1001933979183"
293
+ ```
294
+
295
+ #### 2. Add a topic for supergroups with premium users (Thread ID)
296
+
297
+ You can add topic for supergroups with premium users (Thread ID).
298
+
299
+ ** These topics will be the topics of your supergroups.**
300
+
301
+ ``` dotenv
302
+ TELEGRAM_NOTIFY_CHAT_IDS="-978339113;-1001933979183:topic_1;"
303
+ ```
304
+
305
+ #### 3. Add multiple topics for supergroups with premium users (Thread IDs)
306
+
307
+ You can add multiple topics for each supergroup with premium users (Thread IDs).
308
+
309
+ ``` dotenv
310
+ TELEGRAM_NOTIFY_CHAT_IDS="-978339113;-1001933979183:topic_1,topic_2;"
292
311
```
293
312
294
- > ** Note:** Please use commas to separate chat IDs.
313
+ > ** Note:**
314
+ >
315
+ > - Please use semicolon ";" to separate chat ids
316
+ > - And use a colon ":" to separate chat ID and topic
317
+ > - And use the comma "," if you want to add multiple topics
295
318
296
319
---
297
320
298
321
Now your configuration is complete. And the ` .env ` file will be like this:
299
322
300
323
``` dotenv
301
- APP_NAME ='Telegram GitHub/GitLab Notify Bot'
324
+ TGN_APP_NAME ='Telegram GitHub/GitLab Notify Bot'
302
325
303
- # Set your app URL here
304
- APP_URL =https://123456789.ngrok.io
326
+ # Set your app URL here (Required for the bot to work properly)
327
+ TGN_APP_URL =https://123456789.ngrok.io
305
328
306
329
TELEGRAM_BOT_TOKEN=6162840106:AAH3g20lMQIkG_wHHu8R_ngdtG541uzoq4
307
330
TELEGRAM_BOT_CHAT_ID=6872320129
308
331
309
- # Set your telegram group chat IDs here ( please use comma to separate )
332
+ # Set the chat IDs that will receive notifications here.
333
+ # You can add the owner bot ID, group id, ...
334
+ # -------------------------------------------------------
335
+ # Note:
336
+ # Please use semicolon ";" to separate chat ids
337
+ # And use colon ":" to separate chat ID and thread ID
338
+ # And use comma "," if you want to add multiple thread ids
339
+ # -------------------------------------------------------
340
+ # The environment variable is expected to be in the format:
341
+ # "chat_id1;chat_id2:thread_id2;chat_id3:thread_id3_1,thread_id3_2;..."
310
342
TELEGRAM_NOTIFY_CHAT_IDS="-978339113,-1001933979183"
311
343
312
344
TIMEZONE=Asia/Ho_Chi_Minh
313
345
314
346
PHP_VERSION_SELECTED=8.2
315
- CONTAINER_NAME=telegram-notify -bot
347
+ CONTAINER_NAME=tgn -bot
316
348
APP_PORT=3180
317
349
```
318
350
@@ -357,13 +389,13 @@ Now you will need to add the Webhook for your GitHub and GitLab repository to re
357
389
## 📌 Add webhook on your GitHub repository to receive notifications
358
390
359
391
1 . Go to your repository settings.
360
- 2 . Go to the ` Webhooks ` section.
361
- 3 . Click on ` Add webhook ` .
362
- 4 . Set ` Payload URL ` to ` <APP_URL> ` .
363
- 5 . Set ` Content type ` to ` application/x-www-form-urlencoded ` .
364
- 6 . Which events would you like to trigger this webhook? Select ` Let me select individual events. ` .
365
- 7 . Click on the ` Active ` checkbox and Add webhook button.
366
- 8 . Done. You will receive a notification when your repository has a new event.
392
+ 2 . Go to the ` Webhooks ` section.
393
+ 3 . Click on ` Add webhook ` .
394
+ 4 . Set ` Payload URL ` to ` <APP_URL> ` .
395
+ 5 . Set ` Content type ` to ` application/x-www-form-urlencoded ` .
396
+ 6 . Which events would you like to trigger this webhook? Select ` Let me select individual events. ` .
397
+ 7 . Click on the ` Active ` checkbox and Add webhook button.
398
+ 8 . Done. You will receive a notification when your repository has a new event.
367
399
368
400
Here is the first notification you will receive:
369
401
@@ -374,11 +406,11 @@ Here is the first notification you will receive:
374
406
## 📌 Add a webhook on your GitLab repository to receive notifications
375
407
376
408
1 . Go to your repository settings.
377
- 2 . Go to the ` Webhooks ` section.
378
- 3 . Click on ` Add new webhook ` .
379
- 4 . Set ` URL ` to ` <APP_URL> ` .
380
- 5 . Choose any ` Trigger ` you want.
381
- 6 . Click on the ` Enable SSL verification ` checkbox and Add webhook button.
409
+ 2 . Go to the ` Webhooks ` section.
410
+ 3 . Click on ` Add new webhook ` .
411
+ 4 . Set ` URL ` to ` <APP_URL> ` .
412
+ 5 . Choose any ` Trigger ` you want.
413
+ 6 . Click on the ` Enable SSL verification ` checkbox and Add webhook button.
382
414
383
415
> ** Note: You can set up this webhook for different repositories. Please similarly set up the webhook for each repository.**
384
416
0 commit comments