Skip to content

Instantly share code, notes, and snippets.

@shellscriptx
Created May 8, 2020 11:05
Show Gist options
  • Save shellscriptx/42bfce0155817ac446c1d5ec83995905 to your computer and use it in GitHub Desktop.
Save shellscriptx/42bfce0155817ac446c1d5ec83995905 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Função de escape (markdown)
esc(){
local str=$1
# Caracteres: *_`][
str=${str//\*/\\*}
str=${str//_/\\_}
str=${str//\`/\\\`}
str=${str//\[/\\[}
str=${str//\]/\\]}
echo "$str"
}
# Considere tratar separadamente a expressão cujo os
# caracteres precisam ser escapados.
exp="[Resultado]: 6*5=$((6*5))"
# Mensagem
ShellBot.sendMessage --chat_id xxxxx --text "*A soma dos valores é:\n$(esc "$exp")*" --parse_mode markdown
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment