Documentation
¶
Index ¶
- Constants
- Variables
- func ChatIdToMtproto(id int64) int64
- func FileFromMessage(m *gotgbot.Message) *model.File
- func FileSizeToString(n int64) string
- func FormatString(template string, values map[string]string) string
- func FormatUnixTimestamp(timestamp int64) string
- func GetChatFromUsername(bot *gotgbot.Bot, username string) (*gotgbot.ChatFullInfo, error)
- func HasMedia(m *gotgbot.Message) bool
- func MtprotoToChatId(id int64) int64
- func RandString(length int) string
- func RemoveExtension(input string) string
- func RemoveSymbols(input string) string
- type FloodWaitError
- type MessageLink
Constants ¶
const MaxChannelID int64 = -1000000000000
Variables ¶
var ErrFileNotFound = errors.New("no media was found in the message")
Functions ¶
func ChatIdToMtproto ¶
ChatIdToMtproto converts a bot api channel id starting with -100 to an mtproto id.
func FileFromMessage ¶
FileFromMessage extracts data about a file from the message.
func FileSizeToString ¶
FileSizeToString converts file size in bytes to a user friendly string.
func FormatString ¶
FormatString formats a Pythonic syntax string using a map of key-value pairs.
func FormatUnixTimestamp ¶
FormatUnixTimestamp converts a unix timestamp into a string in the dd/mm/yyyy format.
func GetChatFromUsername ¶
GetChatFromUsername constructs a getChat request using a username.
func HasMedia ¶
func HasMedia(m *gotgbot.Message) bool
HasMedia reports whether message contains media.
func MtprotoToChatId ¶
MtprotoToChatId converts a mtproto chat id to a bot api one. Should only be used for channel or supergroup ids.
func RandString ¶
RandString creates a randomly generated string of given length.
func RemoveExtension ¶
RemoveExtension removes the extension from a file name if any.
func RemoveSymbols ¶
RemoveSymbols returns a copy of the string will all non alpha-numeric characters removed.
Types ¶
type FloodWaitError ¶
FloodWaitError is a telegram rate limit error.
func AsFloodWait ¶
func AsFloodWait(e error) (*FloodWaitError, bool)
AsFloodWait attemots to parse a telegram bot API floodwait error as a FloodWaitError.
func (*FloodWaitError) Error ¶
func (f *FloodWaitError) Error() string
type MessageLink ¶
MessageLink is parsed data from a message link.
func ParseMessageLink ¶
func ParseMessageLink(s string) (*MessageLink, error)
ParseMessageLink parses a message link in the format t.me/c/<id> or t.me/<username>.
func (*MessageLink) GetChat ¶
func (m *MessageLink) GetChat(bot *gotgbot.Bot) (*gotgbot.ChatFullInfo, error)
GetChat gets a chat using it's id or username.