Skip to content

Instantly share code, notes, and snippets.

@zipizap
Created February 15, 2026 23:59
Show Gist options
  • Select an option

  • Save zipizap/1c74ba85fb0d19832b26a54df0c32b44 to your computer and use it in GitHub Desktop.

Select an option

Save zipizap/1c74ba85fb0d19832b26a54df0c32b44 to your computer and use it in GitHub Desktop.
tg_send_markdown.sh
#!/bin/bash
set -efu
# set -x
# Configuration
BOT_TOKEN="YOUR_BOT_TOKEN_HERE"
CHAT_ID="YOUR_CHAT_ID_HERE"
# Ensure an argument is passed
if [ -z "$1" ]; then
echo "Usage: $0 \"*Bold Text* _Italic_\""
exit 1
fi
MSG="$1"
# Send via curl using legacy Markdown
curl -s -X POST "https://api.telegram.org" \
-d chat_id="$CHAT_ID" \
-d text="$MSG" \
-d parse_mode="Markdown" > /dev/null
if [ $? -eq 0 ]; then
echo "Message sent successfully!"
else
echo "Failed to send message."
fi
@zipizap
Copy link
Author

zipizap commented Feb 16, 2026

original was not ok, AI close-miss
Corrected bellow:

#!/bin/bash
set -efu
# set -x

# Configuration
BOT_TOKEN="YOUR_BOT_TOKEN_HERE"
CHAT_ID="YOUR_CHAT_ID_HERE"

# Ensure an argument is passed
if [ -z "$1" ]; then
    echo "Usage: $0 \"*Bold Text* _Italic_\""
    exit 1
fi

MSG="$1"

# Send via curl using legacy Markdown

curl -sSfL -X POST "https://api.telegram.org/bot${BOT_TOKEN}/sendMessage" \
     -d chat_id="$CHAT_ID" \
     -d text="$MSG" \
     -d parse_mode="Markdown"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment