]> Git [git.vados.ru] :: Repos - Mikrotiks/ros.vados.ru.git/commitdiff
go
authorvados-dev <192440777+vados-dev@users.noreply.github.com>
Mon, 9 Mar 2026 06:06:03 +0000 (09:06 +0300)
committervados-dev <192440777+vados-dev@users.noreply.github.com>
Mon, 9 Mar 2026 06:06:03 +0000 (09:06 +0300)
.config/config.mk
Makefile
bin/notify_telegram copy.sh [new file with mode: 0755]
bin/notify_telegram.sh
log.txt [new file with mode: 0644]

index ca800393fc3a97f0fef5f54c3823c8dac6ee0b8e..b0e58c65e867701a9fbd54eec0b96e3fba79210c 100644 (file)
@@ -1,4 +1,6 @@
   export BOT_TOKEN ?= "8390868324:AAG3_d1hfVR2M6pGAgDK6ZvhOe4J97nyopw"
   export CHAT_ID ?= "454403445"
+  export TGDisableWebPagePreview ?= "True"
+  export TGParseMode ?= "html"
   export REPO_DIR ?= $(BUILD_DIR)
   export DRY_RUN ?= 0
index 49a1741462f4f603b0ed1d3fe95043f697e5742a..a4bafd7836857f9a3970c363466d397f70c10447 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -10,7 +10,8 @@ ALL_RSC         := $(wildcard html/*.rsc html/*/*.rsc)
 GLOB_RSC        := $(wildcard html/AM-GlobalFunc.rsc)
 
 DATE            ?= $(shell (date '+%T %d.%m.%Y'))
-DTSTAMP         ?= $(shell (date '+%Y%d%m%H%M%S'))
+DTSTAMP_FMT            ?= "+%Y%m%d%H%M"
+DTSTAMP         ?= $(shell (date $(DTSTAMP_FMT)))
 VERSION         ?= $(shell git symbolic-ref --short HEAD 2>/dev/null)/$(shell git rev-list --count HEAD 2>/dev/null)/$(shell git rev-parse --short=8 HEAD 2>/dev/null)
 RUN_OWNER       := $(shell whoami 2>/dev/null)
 COMM_REPO              := $(shell git rev-parse --show-toplevel | rev | cut -d/ -f1 | rev 2>/dev/nul)
@@ -24,8 +25,8 @@ TAG_VERS :=$(TAG:v%=%)
 # get the latest commit hash in the short form
 COMM_HASH := $(shell git rev-parse --short=8 HEAD 2>/dev/null) # Get short commit hash
 #COMMIT := $(shell git rev-parse --short HEAD)
-# get the latest commit date in the form of YYYYmmdd
-COMM_DATE := $(shell git log -1 --format=%cd --date=format:"%Y%m%d%H%M")
+# get the latest commit date in the form of YYYYmmddHHMM ($(DTSTAMP_FMT))
+COMM_DATE := $(shell git log -1 --format=%cd --date=format:$(DTSTAMP_FMT))
 ifneq ($(COMM_HASH), $(COMM_TAG))
     TAG_VERS :=$(TAG_VERS)-next-$(COMM_HASH)-$(COMM_DATE)
 endif
@@ -41,8 +42,12 @@ COMM_INFO       := $(shell echo -e "Autocommit in repo: $(COMM_REPO), generated
 
 export BUILD_DIR BIN_DIR HTML_DIR DATE DTSTAMP VERSION COMMIT_ID COMM_TAG COMM_HASH COMM_INFO
 
-.ONESHELL:
 SHELL := /bin/bash
+
+export BUILD_DIR BIN_DIR HTML_DIR DATE DTSTAMP VERSION COMMIT_ID COMM_TAG COMM_HASH COMM_INFO COMM_DATE
+
+.ONESHELL:
+
 .DEFAULT_GOAL := run
 
 export BUILD_DIR BIN_DIR HTML_DIR DATE DTSTAMP VERSION COMMIT_ID COMM_TAG COMM_HASH COMM_INFO
diff --git a/bin/notify_telegram copy.sh b/bin/notify_telegram copy.sh
new file mode 100755 (executable)
index 0000000..93c7876
--- /dev/null
@@ -0,0 +1,23 @@
+#!/usr/bin/env bash
+
+msg=${1:-no message}
+
+if [[ "${DRY_RUN:-0}" == "1" ]]; then
+  echo "[notify][dry-run] $msg"
+  exit 0
+fi
+
+if [[ -z "${BOT_TOKEN:-}" || -z "${CHAT_ID:-}" ]]; then
+  echo "[notify] BOT_TOKEN/CHAT_ID not set, skip"
+  exit 0
+fi
+#echo "https://api.telegram.org/bot${BOT_TOKEN}/sendMessage?chat_id=${CHAT_ID}&text=$msg&parse_mode=$TGParseMode&disable_web_page_preview=$TGDisableWebPagePreview"
+#exit 0
+curl -fsS --connect-timeout 5 --max-time 10 \
+  -X POST "https://api.telegram.org/bot"${BOT_TOKEN}"/sendMessage" \
+  -d "chat_id=${CHAT_ID}" \
+  -d "parse_mode=html" \
+  -d "disable_web_page_preview=True" \
+  --data-urlencode "text=${msg}"
+  # >/dev/null
+# || true
index af2a3ce1f81ecb3ee46c3c72f42e380fc34d8bc5..3977de945ea2e7b44c0d57abd99fe55a858e9522 100755 (executable)
@@ -1,17 +1,49 @@
 #!/usr/bin/env bash
 
-
 msg="${1:-no message}"
 
-  if [[ "${DRY_RUN:-0}" == "1" ]]; then
-    echo "[notify][dry-run] $msg"
-    exit 0
-  if [[ -z "${BOT_TOKEN:-}" || -z "${CHAT_ID:-}" ]]; then
-    echo "[notify] BOT_TOKEN/CHAT_ID not set, skip"
-    exit 0
+trim_wrapping_quotes() {
+  local v="${1-}"
+  if [[ "$v" =~ ^\"(.*)\"$ ]]; then
+    printf '%s' "${BASH_REMATCH[1]}"
+    return
+  fi
+  if [[ "$v" =~ ^\'(.*)\'$ ]]; then
+    printf '%s' "${BASH_REMATCH[1]}"
+    return
   fi
+  printf '%s' "$v"
+}
+
+if [[ "${DRY_RUN:-0}" == "1" ]]; then
+  echo "[notify][dry-run] $msg"
+  exit 0
+fi
+
+BOT_TOKEN_CLEAN="$(trim_wrapping_quotes "${BOT_TOKEN:-}")"
+CHAT_ID_CLEAN="$(trim_wrapping_quotes "${CHAT_ID:-}")"
+TG_PARSE_MODE_CLEAN="$(trim_wrapping_quotes "${TGParseMode:-}")"
+TG_DISABLE_PREVIEW_CLEAN="$(trim_wrapping_quotes "${TGDisableWebPagePreview:-}")"
+
+if [[ -z "$BOT_TOKEN_CLEAN" || -z "$CHAT_ID_CLEAN" ]]; then
+  echo "[notify] BOT_TOKEN/CHAT_ID not set, skip"
+  exit 0
+fi
+curl_args=(
+  -fsS
+  --connect-timeout 5
+  --max-time 10
+  -X POST "https://api.telegram.org/bot${BOT_TOKEN_CLEAN}/sendMessage"
+  -d "chat_id=${CHAT_ID_CLEAN}"
+  --data-urlencode "text=${msg}"
+)
+
+if [[ -n "$TG_PARSE_MODE_CLEAN" ]]; then
+  curl_args+=( -d "parse_mode=${TG_PARSE_MODE_CLEAN}" )
+fi
+
+if [[ -n "$TG_DISABLE_PREVIEW_CLEAN" ]]; then
+  curl_args+=( -d "disable_web_page_preview=${TG_DISABLE_PREVIEW_CLEAN}" )
+fi
 
-  curl -fsS --connect-timeout 5 --max-time 10 \
-    -X POST "https://api.telegram.org/bot${BOT_TOKEN}/sendMessage" \
-    -d "chat_id=${CHAT_ID}" \
-    --data-urlencode "text=${msg}" >/dev/null || true
+curl "${curl_args[@]}" >/dev/null
diff --git a/log.txt b/log.txt
new file mode 100644 (file)
index 0000000..e69de29