3.0 KiB
title | description | menu | weight | cascade | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
telegram package | The `telegram` package provides functions for sending messages to [Telegram](https://telegram.org/) using the [Telegram Bot API](https://core.telegram.org/bots/api). |
|
31 |
|
The telegram
package provides functions for sending messages to Telegram
using the Telegram Bot API.
Import the contrib/sranka/telegram
package:
import "contrib/sranka/telegram"
Set up a Telegram bot
The Telegram Bot API requires a bot token and a channel ID. To set up a Telegram bot and obtain the required bot token and channel ID:
-
Create a new Telegram account or use an existing account.
-
Create a Telegram bot. Telegram provides a bot token for the newly created bot.
-
Use the Telegram application to create a new channel.
-
Add the new bot to the channel as an Administrator. Ensure the bot has permissions necessary to post messages.
-
Send a message to bot in the channel.
-
Send a request to
https://api.telegram.org/bot$token/getUpdates
.curl https://api.telegram.org/bot$token/getUpdates
Find your channel ID in the
id
field of the response.
Options
option telegram.defaultDisableWebPagePreview = false
option telegram.defaultParseMode = "MarkdownV2"
option telegram.defaultSilent = true
option telegram.defaultURL = "https://api.telegram.org/bot"
defaultDisableWebPagePreview
defaultDisableWebPagePreview
- Use Telegram web page preview by default. Default is false
.
defaultParseMode
defaultParseMode
is the default Telegram parse mode. Default is MarkdownV2
.
defaultSilent
defaultSilent
- Send silent Telegram notifications by default. Default is true
.
defaultURL
defaultURL
is the default Telegram bot URL. Default is https://api.telegram.org/bot
.
Functions
{{< children type="functions" show="pages" >}}