Documentation
¶
Index ¶
Constants ¶
const (
Scheme = "telegram"
)
Scheme is the identifying part of this service's configuration URL
Variables ¶
var ParseModes = &parseModeVals{ None: 0, Markdown: 1, HTML: 2, MarkdownV2: 3, Enum: format.CreateEnumFormatter( []string{ "None", "Markdown", "HTML", "MarkdownV2", }), }
ParseModes is an enum helper for parseMode
Functions ¶
func GetErrorResponse ¶
GetErrorResponse retrieves the error message from a failed request
Types ¶
type Chat ¶
type Chat struct {
ID int64 `json:"id"`
Type string `json:"type"`
Title string `json:"title"`
Username string `json:"username"`
}
Chat represents a telegram conversation
type ChatMember ¶
type ChatMember struct {
// The member's status in the chat
Status string `json:"status"`
// Information about the user
User *User `json:"user"`
}
ChatMember represents the membership state for a user in a telegram chat
type ChatMemberUpdate ¶
type ChatMemberUpdate struct {
// Chat the user belongs to
Chat *Chat `json:"chat"`
// Performer of the action, which resulted in the change
From *User `json:"from"`
// Date the change was done in Unix time
Date int `json:"date"`
// Previous information about the chat member
OldChatMember *ChatMember `json:"old_chat_member"`
// New information about the chat member
NewChatMember *ChatMember `json:"new_chat_member"`
}
ChatMemberUpdate represents a member update in a telegram chat
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client for Telegram API
func (*Client) GetBotInfo ¶
GetBotInfo returns the bot User info
func (*Client) GetUpdates ¶
func (c *Client) GetUpdates(offset int, limit int, timeout int, allowedUpdates []string) ([]Update, error)
GetUpdates retrieves the latest updates
func (*Client) SendMessage ¶
func (c *Client) SendMessage(message *SendMessagePayload) (*Message, error)
SendMessage sends the specified Message
type Config ¶
type Config struct {
Token string `url:"user"`
Preview bool `key:"preview" default:"Yes" desc:"If disabled, no web page preview will be displayed for URLs"`
Notification bool `key:"notification" default:"Yes" desc:"If disabled, sends Message silently"`
ParseMode parseMode `key:"parsemode" default:"None" desc:"How the text Message should be parsed"`
Chats []string `key:"chats,channels" desc:"Chat IDs or Channel names (using @channel-name)"`
Title string `key:"title" default:"" desc:"Notification title, optionally set by the sender"`
}
Config for use within the telegram plugin
func (*Config) Enums ¶
func (config *Config) Enums() map[string]types.EnumFormatter
Enums returns the fields that should use a corresponding EnumFormatter to Print/Parse their values
type Generator ¶
type Generator struct {
Reader io.Reader
Writer io.Writer
// contains filtered or unexported fields
}
Generator is the telegram-specific URL generator
type Message ¶
type Message struct {
MessageID int64 `json:"message_id"`
Text string `json:"text"`
From *User `json:"from"`
Chat *Chat `json:"chat"`
}
Message represents one chat message
type SendMessagePayload ¶
type SendMessagePayload struct {
Text string `json:"text"`
ID string `json:"chat_id"`
MessageThreadID *int `json:"message_thread_id,omitempty"`
ParseMode string `json:"parse_mode,omitempty"`
DisablePreview bool `json:"disable_web_page_preview"`
DisableNotification bool `json:"disable_notification"`
ReplyMarkup *replyMarkup `json:"reply_markup,omitempty"`
Entities []entity `json:"entities,omitempty"`
ReplyTo int64 `json:"reply_to_message_id"`
MessageID int64 `json:"message_id,omitempty"`
}
SendMessagePayload is the notification payload for the telegram notification service
type Service ¶
Service sends notifications to a given telegram chat
func (*Service) Initialize ¶
Initialize loads ServiceConfig from configURL and sets logger for this Service
type Update ¶
type Update struct {
// The Update's unique identifier. Update identifiers start from a certain positive number and increase sequentially. This ID becomes especially handy if you're using Webhooks, since it allows you to ignore repeated updates or to restore the correct Update sequence, should they get out of order. If there are no new updates for at least a week, then identifier of the next Update will be chosen randomly instead of sequentially.
UpdateID int `json:"update_id"`
// Optional. New incoming Message of any kind — text, photo, sticker, etc.
Message *Message `json:"Message"`
// Optional. New version of a Message that is known to the bot and was edited
EditedMessage *Message `json:"edited_message"`
// Optional. New incoming channel post of any kind — text, photo, sticker, etc.
ChannelPost *Message `json:"channel_post"`
// Optional. New version of a channel post that is known to the bot and was edited
EditedChannelPost *Message `json:"edited_channel_post"`
// Optional. New incoming inline query
InlineQuery *inlineQuery `json:"inline_query"`
//// Optional. The result of an inline query that was chosen by a User and sent to their chat partner. Please see our documentation on the feedback collecting for details on how to enable these updates for your bot.
ChosenInlineResult *chosenInlineResult `json:"chosen_inline_result"`
//// Optional. New incoming callback query
CallbackQuery *callbackQuery `json:"callback_query"`
ChatMemberUpdate *ChatMemberUpdate `json:"my_chat_member"`
}
Update contains state changes since the previous Update
type User ¶
type User struct {
// Unique identifier for this User or bot
ID int64 `json:"id"`
// True, if this User is a bot
IsBot bool `json:"is_bot"`
// User's or bot's first name
FirstName string `json:"first_name"`
// Optional. User's or bot's last name
LastName string `json:"last_name"`
// Optional. User's or bot's username
Username string `json:"username"`
// Optional. IETF language tag of the User's language
LanguageCode string `json:"language_code"`
// Optional. True, if the bot can be invited to groups. Returned only in getMe.
CanJoinGroups bool `json:"can_join_groups"`
// Optional. True, if privacy mode is disabled for the bot. Returned only in getMe.
CanReadAllGroupMessages bool `json:"can_read_all_group_messages"`
// Optional. True, if the bot supports inline queries. Returned only in getMe.
SupportsInlineQueries bool `json:"supports_inline_queries"`
}
User contains information about a telegram user or bot