No description
README.md | ||
tg.sh |
telegram.sh, a telegram bot api library in bash
This library aims to make creating quick-and-dirty bots in Bash as easy as possible. To create a basic bot, all you need is the following:
#!/bin/bash
source tg.sh
TELEGRAM_TOKEN="<token>"
function _on_msg() {
echo "${event[from_username]}: ${event[text]}"
if [[ "${event[text]}" == "o/" ]]; then
tg_send ${event[chat_id]} "$(_escape '\o')"
fi
}
tg_start
Please note how you need to escape the text if there are any characters
which would conflict with the MarkdownV2 standard. If you wish to use MD
styling, the tg_send
call could look like that:
tg_send ${event[chat_id]} "[$(_escape "^_^")]($(_escape "https://example.org"))"
Alternatively, if you decide that you don't want to run _escape
on every
string, set ESCAPE_ALL
to true
after loading the library.