Go to file
Dominika Liberda ac6d4bca62 * fixes in how curl are called because... semicolons 2022-04-08 21:46:14 +02:00
README.md * fixes with md parser 2022-04-03 17:28:50 +02:00
tg.sh * fixes in how curl are called because... semicolons 2022-04-08 21:46:14 +02:00

README.md

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.