diff --git a/.gitea/actions/telegram-message-escape/action.yaml b/.gitea/actions/telegram-message-escape/action.yaml index 89d80a8..9fe0d01 100644 --- a/.gitea/actions/telegram-message-escape/action.yaml +++ b/.gitea/actions/telegram-message-escape/action.yaml @@ -15,12 +15,23 @@ runs: using: 'composite' steps: - id: escape - shell: bash + shell: python env: RAW_MESSAGE: ${{ inputs.message }} + ESCAPED_MESSAGE: ${{ github.output }} run: | - ESCAPED_MESSAGE=$(echo "$RAW_MESSAGE" | sed "s|-|-\\\\-|g" | sed "s|\.|\ \ \ \ .|g" | sed "s|!|\\\\!|g") + import os + + raw_text = os.environ.get("RAW_MESSAGE", "") + output_file = os.environ.get("ESCAPED_MESSAGE") + + escape_chars = ["-", ".", "!"] - echo "result<> $GITHUB_OUTPUT - echo "$ESCAPED_MESSAGE" >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT + escaped_text = raw_text + for char in escape_chars: + escaped_text = escaped_text.replace(char, f"\\{char}") + + with open(output_file, "a", encoding="utf-8") as f: + f.write("result<