You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When DNS records are updated, d2c.sh will send a notification to enabled services. Feel free to submit a pull request to add more notification services.
@@ -158,3 +159,20 @@ enabled = true
158
159
endpoint = "http://gotify.example.com"
159
160
token = "ccc"
160
161
```
162
+
163
+
#### 2. Telegram
164
+
165
+
To enable notifications via Telegram bot, add the following configuration to your `toml` file:
166
+
167
+
```toml
168
+
[telegram]
169
+
enabled = true
170
+
token = "aaabbb"# from BotFather
171
+
chat_id = "111234"
172
+
```
173
+
174
+
You can get your chat ID by sending a message to the bot and going to this URL to view the chat_id:
@@ -141,7 +146,17 @@ for config_file in $(ls ${config_file_dir}*.toml 2>/dev/null | sort -V); do
141
146
status_code=$(curl --silent --output /dev/null --write-out "%{http_code}""${gotify_endpoint}/message?token=${gotify_token}" -F "title=[d2c.sh] ${name} has changed" -F "message=Public IP for ${name} has changed (${public_ip})" -F "priority=5")
142
147
143
148
if [[ "$status_code"-ne 200 ]];then
144
-
echo"[d2c.sh] Failed to sent Gotify notification"
149
+
echo"[d2c.sh] Failed to send Gotify notification"
150
+
fi
151
+
fi
152
+
153
+
# check if Telegram is enabled
154
+
if [ "$telegram_enabled"=true ];then
155
+
# send changed ip notification
156
+
status_code=$(curl --silent --output /dev/null --write-out "%{http_code}" https://api.telegram.org/bot"${telegram_token}"/sendMessage -d chat_id="${telegram_chat_id}" -d disable_web_page_preview=true -d text="[d2c.sh] Public IP for ${name} has changed (${public_ip})")
157
+
158
+
if [[ "$status_code"-ne 200 ]];then
159
+
echo"[d2c.sh] Failed to send Telegram notification"
0 commit comments