@nitra/telegram 1.5.0 → 1.5.2
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.
- package/package.json +3 -3
- package/src/index.js +6 -4
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nitra/telegram",
|
|
3
3
|
"description": "telegram helper",
|
|
4
|
-
"version": "1.5.
|
|
4
|
+
"version": "1.5.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"files": [
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"homepage": "https://github.com/nitra/telegram",
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@nitra/check-env": "^
|
|
27
|
-
"@nitra/pino": "^2.
|
|
26
|
+
"@nitra/check-env": "^4.1.0",
|
|
27
|
+
"@nitra/pino": "^2.8.1"
|
|
28
28
|
},
|
|
29
29
|
"engines": {
|
|
30
30
|
"node": ">=22.0.0"
|
package/src/index.js
CHANGED
|
@@ -22,9 +22,11 @@ export const sendMessage = async (text, params) => {
|
|
|
22
22
|
url += '&parse_mode=HTML'
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
// Якщо в неробочий час або відключено сповіщення, то додаємо параметр disable_notification
|
|
25
26
|
if (!(currentHour >= 8 && currentHour <= 18) || params?.disable_notification === true) {
|
|
26
27
|
url += '&disable_notification=true'
|
|
27
28
|
}
|
|
29
|
+
|
|
28
30
|
let res
|
|
29
31
|
try {
|
|
30
32
|
res = await fetch(url)
|
|
@@ -32,11 +34,11 @@ export const sendMessage = async (text, params) => {
|
|
|
32
34
|
log.error(error)
|
|
33
35
|
return false
|
|
34
36
|
}
|
|
37
|
+
|
|
35
38
|
if (res.status >= 400) {
|
|
36
|
-
|
|
39
|
+
const data = await res.json()
|
|
40
|
+
|
|
41
|
+
log.error(data.description, text)
|
|
37
42
|
return false
|
|
38
43
|
}
|
|
39
|
-
// } else {
|
|
40
|
-
// log.info('Telegram message skipped, not in working hours: ', text)
|
|
41
|
-
// }
|
|
42
44
|
}
|