@@ -51,7 +51,23 @@ and manage customization through messages and buttons on Telegram.
5151- Composer
5252- Telegram Bot
5353
54- ## ⚙ Installation
54+ ## 🔧 Installation
55+
56+ As for the installation and configuration,
57+ this project provides two different installation ways depending on your preference or suitable for your system.
58+
59+ > ** Way 1:** Install by composer directly on the system (Requires the system to install composer, previous PHP version)
60+ >
61+ > ** Way 2:** Install by Docker (Requires the system to install Docker, Docker Compose)
62+
63+ ### I. Installation and configuration 🛠
64+
65+ Please choose only one of the following two ways to set up the project.
66+
67+ <details open >
68+
69+ <summary ><b >Way 1: Install by composer directly on the system ⚙</b ></summary >
70+ <br />
5571
5672First, please clone and install this project via [ Composer] ( https://getcomposer.org/ ) :
5773
@@ -64,7 +80,6 @@ and the environment file `.env` will be created automatically.
6480
6581Some the json files will be created automatically in the ` storage ` directory.
6682These files are used to store the data and serve for features in this bot.
67- (You can change the storage directory in the ` .env ` file)
6883
6984### Create a New Bot
7085
@@ -106,7 +121,115 @@ In this example, we will use localhost and [ngrok](https://ngrok.com/) to set up
106121APP_URL=https://123456789.ngrok.io
107122```
108123
109- ### Set the webhook
124+ 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.
125+
126+ </details >
127+
128+ ---
129+
130+ <details >
131+
132+ <summary ><b >Way 2: Install by Docker :whale:</b ></summary >
133+ <br />
134+
135+ > ** Note:** This way requires the system to install Docker and Docker Compose.
136+ >
137+ > ⚠ ** If you set up the project by way one, please can skip this way.** 🚸
138+ >
139+ > And go to step [ II. Set the webhook] ( #ii-set-the-webhook ) to continue.
140+
141+ First, please clone this project and copy the environment file ` .env.example ` to ` .env ` :
142+
143+ ``` bash
144+ git clone git@github.com:lbiltech/telegram-bot-github-notify.git
145+ cd telegram-bot-github-notify
146+ cp .env.example .env
147+ ```
148+
149+ ### Update the environment variables
150+
151+ Open the ` .env ` file and update the following variables:
152+
153+ ``` shell
154+ PHP_VERSION_SELECTED=8.2
155+ CONTAINER_NAME=telegram-notify-bot
156+ APP_PORT=3180
157+ ```
158+
159+ > ** Note:**
160+ >
161+ > - The ` PHP_VERSION_SELECTED ` variable is the PHP version you want to use in the container.
162+ > - The ` CONTAINER_NAME ` variable is the name of the container you want to create.
163+ > - The ` APP_PORT ` variable is the port of the container. (Please don't set the same port as the host)
164+
165+ ### Install and run the container
166+
167+ Run the following command to install and run the container:
168+
169+ ``` bash
170+ bash ./docker.sh
171+ ```
172+
173+ Some the json files will be created automatically in the ` storage ` directory.
174+ These files are used to store the data and serve for features in this bot.
175+
176+ ### Create a New Bot
177+
178+ To create a new bot,
179+ you need to talk to [ BotFather] ( https://core.telegram.org/bots#6-botfather ) and follow a few simple steps.
180+
181+ 1 . Open a chat with [ BotFather] ( https://telegram.me/botfather ) and send ` /newbot ` command.
182+ 2 . Enter a friendly name for your bot. This name will be displayed in contact details and elsewhere.
183+ 3 . Enter a unique username for your bot. It must end in ` bot ` . Like this, for example: ` TetrisBot ` or ` tetris_bot ` .
184+ 4 . Copy the HTTP API access token provided by [ BotFather] ( https://telegram.me/botfather ) and paste it into your ` .env ` file.
185+
186+ ``` shell
187+ TELEGRAM_BOT_TOKEN=123456789:ABCDEFGHIJKLMNOPQRSTUVWXYZ
188+ ```
189+
190+ ### Get your Chat ID and add it to the .env file
191+
192+ 1 . Open a chat with your bot.
193+ 2 . Send any message to your bot. (This handle needs to get your chat id)
194+ 3 . Go to the following URL: ` https://api.telegram.org/bot<YourTelegramBotToken>/getUpdates `
195+ 4 . Look for the ` "chat":{"id": ` field and copy the number after it. This is your Chat ID.
196+ 5 . Paste the Chat ID in your ` .env ` file.
197+
198+ ``` shell
199+ TELEGRAM_BOT_CHAT_ID=123456789
200+ ```
201+
202+ ### Set up your domain and SSL certificate
203+
204+ In this way, we use the proxy in container and [ ngrok] ( https://ngrok.com/ ) to set up the domain and webhook:
205+ 1 . Check the proxy of the container: ` docker inspect <CONTAINER_NAME>-nginx | grep IPAddress `
206+
207+ > ** Note:** Replace ` <CONTAINER_NAME> ` with the name of the container in .env file.
208+
209+ Example:
210+
211+ ![ image] ( https://github.com/lbiltech/lemp-docker/assets/35853002/8dc8ba3f-b1e9-4bff-901d-6bb7747acda4 )
212+
213+ 2 . Download and install [ ngrok] ( https://ngrok.com/download ) .
214+ 2 . Continue to run command in terminal: ` ngrok http <CONTAINER_IP> `
215+
216+ > ** Note:** Replace ` <CONTAINER_IP> ` is the IP address of the container in step 1.
217+
218+ Example:
219+
220+ ``` bash
221+ ngrok http 172.28.0.3
222+ ```
223+
224+ 3 . Copy the HTTPS URL provided by ngrok and paste it into your ` .env ` file.
225+
226+ ``` shell
227+ APP_URL=https://123456789.ngrok-free.app
228+ ```
229+
230+ </details >
231+
232+ ### II. Set the webhook
110233
111234We have two ways to set the webhook:
112235
@@ -140,7 +263,7 @@ https://api.telegram.org/bot<YourTelegramBotToken>/setWebhook?url=<APP_URL>
140263
141264> ** Note:** Replace ` <YourTelegramBotToken> ` with your bot token and ` <APP_URL> ` with your app URL in .env file.
142265
143- ### Add chat ids you want to receive notifications to the .env file
266+ ### III. Add chat ids you want to receive notifications to the .env file
144267
145268You can add multiple chat ids to the ` .env ` file.
146269
0 commit comments