From: vados-dev <192440777+vados-dev@users.noreply.github.com> Date: Mon, 9 Mar 2026 06:06:03 +0000 (+0300) Subject: go X-Git-Url: https://git.vados.ru/gitweb.cgi?a=commitdiff_plain;h=0fbec5f40bd4763a7553b5f04d75469341f8aab4;p=Mikrotiks%2Fros.vados.ru.git go --- diff --git a/.config/config.mk b/.config/config.mk index ca800393f..b0e58c65e 100644 --- a/.config/config.mk +++ b/.config/config.mk @@ -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 diff --git a/Makefile b/Makefile index 49a174146..a4bafd783 100644 --- 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 index 000000000..93c7876d1 --- /dev/null +++ b/bin/notify_telegram copy.sh @@ -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 diff --git a/bin/notify_telegram.sh b/bin/notify_telegram.sh index af2a3ce1f..3977de945 100755 --- a/bin/notify_telegram.sh +++ b/bin/notify_telegram.sh @@ -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 index 000000000..e69de29bb