Documentation
¶
Overview ¶
Package telegramtest is a stand-in for the Telegram Bot API, for tests and preview stands: nothing in the suite ever talks to api.telegram.org.
Index ¶
- type Bot
- func (b *Bot) AddFile(id, path string, data []byte)
- func (b *Bot) Answers() []string
- func (b *Bot) Calls() []string
- func (b *Bot) Close()
- func (b *Bot) EditsUnchanged(n int)
- func (b *Bot) Messages() []Sent
- func (b *Bot) Pending() int
- func (b *Bot) Pinned(id int64) bool
- func (b *Bot) Press(chatID, msgID int64, data string)
- func (b *Bot) RateLimit(n, retryAfter int)
- func (b *Bot) RefusePins()
- func (b *Bot) RefuseURLButtons()
- func (b *Bot) Reply(chatID int64, replyTo int64, text string)
- func (b *Bot) Say(chatID int64, firstName, text string)
- func (b *Bot) SayIn(chatID int64, chatType, firstName, text string, replyTo int64)
- func (b *Bot) SayOld(chatID int64, text string, age time.Duration)
- func (b *Bot) Send(chatID int64, m telegram.Message)
- func (b *Bot) Sent() []Sent
- func (b *Bot) URL() string
- type Sent
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bot ¶
Bot is a fake Bot API serving one bot.
func (*Bot) AddFile ¶ added in v0.137.0
AddFile makes a file fetchable with getFile under id, served at path on the file server.
func (*Bot) EditsUnchanged ¶ added in v0.148.0
EditsUnchanged makes the next n edits answer as Telegram answers an edit that changes nothing: 400 "message is not modified".
func (*Bot) RefusePins ¶ added in v0.148.0
func (b *Bot) RefusePins()
RefusePins makes pinChatMessage fail as Telegram fails a bot without the right to pin.
func (*Bot) RefuseURLButtons ¶
func (b *Bot) RefuseURLButtons()
RefuseURLButtons makes a message with a URL button fail as Telegram fails one whose address it will not open.
func (*Bot) Send ¶ added in v0.137.0
Send queues a message from a private chat as m describes it — a forward, a photo, a voice note — with its date, sender and chat filled in.
type Sent ¶
type Sent struct {
Method string
ChatID string
Text string
ParseMode string
MessageID int64
// ReplyTo is the message a sent one is threaded under; for an edit or a
// reaction, the message it changes.
ReplyTo int64
// Buttons are the inline buttons' callback data (or "url:" + the URL),
// row by row flattened.
Buttons []string
// ForceReply says the message asked for a reply.
ForceReply bool
Emoji string
// Photo is a sendPhoto's file; Text is then its caption.
Photo []byte
// Silent is a pin asked for without a notification.
Silent bool
At time.Time
}
Sent is one call the fake received that changes the chat: a message, an edit of its buttons, or a reaction.