Skip to content

Commit 7f18533

Browse files
authored
Update README.md
1 parent 996d660 commit 7f18533

File tree

1 file changed

+103
-71
lines changed

1 file changed

+103
-71
lines changed

README.md

Lines changed: 103 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ and manage customization through messages and buttons on Telegram.
1414
## 📝 Information
1515

1616
- 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)
1818

1919
## 🎉 Features
2020

@@ -34,8 +34,8 @@ and manage customization through messages and buttons on Telegram.
3434

3535
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.
3636

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.
3939

4040
<p align="center">
4141
<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.
5454
[//]: # (features image)
5555

5656
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.
5959

6060
[//]: # (features image)
6161

6262
## 📋 Requirements
6363

6464
- 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)
6767

6868
## 🔧 Installation
6969

@@ -95,46 +95,46 @@ and the environment file `.env` will be created automatically.
9595
Some of the JSON files will be created automatically in the `storage` directory.
9696
These files are used to store the data and serve for features in this bot.
9797

98-
### Create a New Bot
98+
#### 1. Create a New Bot
9999

100100
To create a new bot, you need to talk to [BotFather](https://core.telegram.org/bots#6-botfather) and follow a few simple steps.
101101

102102
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.
106106

107107
```dotenv
108108
TELEGRAM_BOT_TOKEN=123456789:ABCDEFGHIJKLMNOPQRSTUVWXYZ
109109
```
110110

111-
### Get your Chat ID and add it to the .env file
111+
#### 2. Set up your domain and SSL certificate
112112

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.**
126114
You can build your own server or use a service like [Heroku](https://www.heroku.com/).
127115

128116
In this example, we will use localhost and [ngrok](https://ngrok.com/) to set up the domain and webhook:
129117
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.
133121

134122
```dotenv
135123
TGN_APP_URL=https://123456789.ngrok.io
136124
```
137125

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+
138138
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.
139139

140140
</details>
@@ -160,7 +160,7 @@ cd telegram-git-notifier-app
160160
cp .env.example .env
161161
```
162162

163-
### Update the environment variables
163+
#### 1. Update the environment variables
164164

165165
Open the `.env` file and update the following variables:
166166

@@ -169,16 +169,16 @@ PHP_VERSION_SELECTED=8.2
169169
APP_PORT=3180
170170
171171
# 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
173173
```
174174

175175
> **Note:**
176176
>
177177
> - 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.
180180
181-
### Install and run the container
181+
#### 2. Install and run the container
182182

183183
Run the following command to install and run the container:
184184

@@ -189,33 +189,22 @@ bash ./docker.sh
189189
Some of the JSON files will be created automatically in the `storage` directory.
190190
These files are used to store the data and serve for features in this bot.
191191

192-
### Create a New Bot
192+
#### 3. Create a New Bot
193193

194194
To create a new bot,
195195
you need to talk to [BotFather](https://core.telegram.org/bots#6-botfather) and follow a few simple steps.
196196

197197
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.
201201

202202
```dotenv
203203
TELEGRAM_BOT_TOKEN=123456789:ABCDEFGHIJKLMNOPQRSTUVWXYZ
204204
```
205205

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-
```
217206

218-
### Set up your domain and SSL certificate
207+
#### 4. Set up your domain and SSL certificate
219208

220209
In this way, we use the proxy in the container and [ngrok](https://ngrok.com/) to set up the domain and webhook:
221210
1. Check the proxy of the container: `docker inspect <CONTAINER_NAME>-nginx | grep IPAddress`
@@ -227,7 +216,7 @@ Example:
227216
![image](https://github.com/lbiltech/lemp-docker/assets/35853002/8dc8ba3f-b1e9-4bff-901d-6bb7747acda4)
228217

229218
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>`
231220

232221
> **Note:** Replace `<CONTAINER_IP>` is the IP address of the container in step 1.
233222
@@ -240,7 +229,19 @@ ngrok http 172.28.0.3
240229
3. Copy the HTTPS URL provided by ngrok and paste it into your `.env` file.
241230

242231
```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
244245
```
245246

246247
</details>
@@ -281,38 +282,69 @@ https://api.telegram.org/bot<YourTelegramBotToken>/setWebhook?url=<APP_URL>
281282
282283
### III. Add chat IDs you want to receive notifications to the .env file
283284

284-
You can add multiple chat IDs to the `.env` file.
285+
#### 1. Add multiple chat IDs to the `.env` file.
285286

286287
**These chat IDs will be the chat IDs of your groups, channels, or users.**
287288

288289
Also, you can add **the chat ID of this bot** to receive incoming notifications for itself.
289290

290291
```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;"
292311
```
293312

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
295318
296319
---
297320

298321
Now your configuration is complete. And the `.env` file will be like this:
299322

300323
```dotenv
301-
APP_NAME='Telegram GitHub/GitLab Notify Bot'
324+
TGN_APP_NAME='Telegram GitHub/GitLab Notify Bot'
302325
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
305328
306329
TELEGRAM_BOT_TOKEN=6162840106:AAH3g20lMQIkG_wHHu8R_ngdtG541uzoq4
307330
TELEGRAM_BOT_CHAT_ID=6872320129
308331
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;..."
310342
TELEGRAM_NOTIFY_CHAT_IDS="-978339113,-1001933979183"
311343
312344
TIMEZONE=Asia/Ho_Chi_Minh
313345
314346
PHP_VERSION_SELECTED=8.2
315-
CONTAINER_NAME=telegram-notify-bot
347+
CONTAINER_NAME=tgn-bot
316348
APP_PORT=3180
317349
```
318350

@@ -357,13 +389,13 @@ Now you will need to add the Webhook for your GitHub and GitLab repository to re
357389
## 📌 Add webhook on your GitHub repository to receive notifications
358390

359391
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.
367399

368400
Here is the first notification you will receive:
369401

@@ -374,11 +406,11 @@ Here is the first notification you will receive:
374406
## 📌 Add a webhook on your GitLab repository to receive notifications
375407

376408
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.
382414

383415
> **Note: You can set up this webhook for different repositories. Please similarly set up the webhook for each repository.**
384416

0 commit comments

Comments
 (0)