refactor: telegram config via pos config telegram; fix listener pipe + entertainment bugs
- Drop sender 'config'/'config set' subcommand — redundant with 'pos config telegram' (same POS_CONFIG registry: masked token input/display, chat-id validation, chmod 600); sender/listener error hints now point there. - Listener: load_map now uses a \x1f delimiter, so mapped /commands containing '|' are no longer truncated at the first pipe. - entertainment send: forward extra plugin args (previously dropped); pass '--' before the message so leading '-' plugin output isn't parsed as an option. - write_config_key/cfg_write: replace unescaped sed writes with grep-v+append so values with &, |, \ round-trip safely. - sync_systemd: daemon-reload after removing timer units. - config-ui: 'digits' validation accepts negative group/supergroup chat ids.
This commit is contained in:
@@ -24,13 +24,12 @@ config_value() {
|
||||
}
|
||||
|
||||
write_config_key() {
|
||||
local key="$1" val="$2"
|
||||
local key="$1" val="$2" tmp
|
||||
mkdir -p "$CONFIG_DIR"
|
||||
if [ -f "$CONFIG_FILE" ] && grep -q "^${key}=" "$CONFIG_FILE" 2>/dev/null; then
|
||||
sed -i "s|^${key}=.*|${key}=\"${val}\"|" "$CONFIG_FILE"
|
||||
else
|
||||
echo "${key}=\"${val}\"" >>"$CONFIG_FILE"
|
||||
fi
|
||||
tmp="$(mktemp)"
|
||||
grep -v "^${key}=" "$CONFIG_FILE" 2>/dev/null >"$tmp" || true
|
||||
printf '%s="%s"\n' "$key" "$val" >>"$tmp"
|
||||
mv "$tmp" "$CONFIG_FILE"
|
||||
chmod 600 "$CONFIG_FILE"
|
||||
}
|
||||
|
||||
@@ -336,7 +335,7 @@ sync_systemd() {
|
||||
fi
|
||||
done
|
||||
|
||||
local f p
|
||||
local f p removed=0
|
||||
for f in "$USER_SYSTEMD_DIR"/${TIMER_PREFIX}-*.timer; do
|
||||
[ -f "$f" ] || continue
|
||||
p="${f##*/}"; p="${p#${TIMER_PREFIX}-}"; p="${p%.timer}"
|
||||
@@ -344,7 +343,9 @@ sync_systemd() {
|
||||
systemctl --user disable --now "$(unit_name "$p").timer" >/dev/null 2>&1 || true
|
||||
rm -f "$USER_SYSTEMD_DIR/$(unit_name "$p").timer" "$USER_SYSTEMD_DIR/$(unit_name "$p").service"
|
||||
log "removed timer for '$p'"
|
||||
removed=1
|
||||
fi
|
||||
done
|
||||
[ "$removed" -eq 1 ] && systemctl --user daemon-reload >/dev/null 2>&1 || true
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user