func (e MessageEntity) IsEmail() bool {
	return e.Type == "email"
}
IsEmail returns true if the type of the message entity is "email".
package tgbotapi
import (
	"encoding/json"
	"errors"
	"fmt"
	"net/url"
	"strings"
	"time"
)
type APIResponse struct {
	Ok          bool                `json:"ok"`
	Result      json.RawMessage     `json:"result"`
	ErrorCode   int                 `json:"error_code"`
	Description string              `json:"description"`
	Parameters  *ResponseParameters `json:"parameters"`
}
type ResponseParameters struct {
	MigrateToChatID int64 `json:"migrate_to_chat_id"`  
	RetryAfter      int   `json:"retry_after"`         
}
type Update struct {
	UpdateID int `json:"update_id"`
	Message *Message `json:"message"`
	EditedMessage *Message `json:"edited_message"`
	ChannelPost *Message `json:"channel_post"`
	EditedChannelPost *Message `json:"edited_channel_post"`
	InlineQuery *InlineQuery `json:"inline_query"`
	ChosenInlineResult *ChosenInlineResult `json:"chosen_inline_result"`
	CallbackQuery *CallbackQuery `json:"callback_query"`
	ShippingQuery *ShippingQuery `json:"shipping_query"`
	PreCheckoutQuery *PreCheckoutQuery `json:"pre_checkout_query"`
}
type UpdatesChannel <-chan Update
func (ch UpdatesChannel) Clear() {
	for len(ch) != 0 {
		<-ch
	}
}
type User struct {
	ID int `json:"id"`
	FirstName string `json:"first_name"`
	LastName string `json:"last_name"`
	UserName string `json:"username"`
	LanguageCode string `json:"language_code"`
	IsBot bool `json:"is_bot"`
}
func (u *User) String() string {
	if u == nil {
		return ""
	}
	if u.UserName != "" {
		return u.UserName
	}
	name := u.FirstName
	if u.LastName != "" {
		name += " " + u.LastName
	}
	return name
}
type GroupChat struct {
	ID    int    `json:"id"`
	Title string `json:"title"`
}
type ChatPhoto struct {
	SmallFileID string `json:"small_file_id"`
	BigFileID string `json:"big_file_id"`
}
type Chat struct {
	ID int64 `json:"id"`
	Type string `json:"type"`
	Title string `json:"title"`
	UserName string `json:"username"`
	FirstName string `json:"first_name"`
	LastName string `json:"last_name"`
	AllMembersAreAdmins bool `json:"all_members_are_administrators"`
	Photo *ChatPhoto `json:"photo"`
	Description string `json:"description,omitempty"`
	InviteLink string `json:"invite_link,omitempty"`
	PinnedMessage *Message `json:"pinned_message"`
}
func (c Chat) IsPrivate() bool {
	return c.Type == "private"
}
func (c Chat) IsGroup() bool {
	return c.Type == "group"
}
func (c Chat) IsSuperGroup() bool {
	return c.Type == "supergroup"
}
func (c Chat) IsChannel() bool {
	return c.Type == "channel"
}
func (c Chat) ChatConfig() ChatConfig {
	return ChatConfig{ChatID: c.ID}
}
type Message struct {
	MessageID int `json:"message_id"`
	From *User `json:"from"`
	Date int `json:"date"`
	Chat *Chat `json:"chat"`
	ForwardFrom *User `json:"forward_from"`
	ForwardFromChat *Chat `json:"forward_from_chat"`
	ForwardFromMessageID int `json:"forward_from_message_id"`
	ForwardDate int `json:"forward_date"`
	ReplyToMessage *Message `json:"reply_to_message"`
	ViaBot *User `json:"via_bot"`
	EditDate int `json:"edit_date"`
	MediaGroupID string `json:"media_group_id"`
	AuthorSignature string `json:"author_signature"`
	Text string `json:"text"`
	Entities *[]MessageEntity `json:"entities"`
	CaptionEntities *[]MessageEntity `json:"caption_entities"`
	Audio *Audio `json:"audio"`
	Document *Document `json:"document"`
	Animation *ChatAnimation `json:"animation"`
	Game *Game `json:"game"`
	Photo *[]PhotoSize `json:"photo"`
	Sticker *Sticker `json:"sticker"`
	Video *Video `json:"video"`
	VideoNote *VideoNote `json:"video_note"`
	Voice *Voice `json:"voice"`
	Caption string `json:"caption"`
	Contact *Contact `json:"contact"`
	Location *Location `json:"location"`
	Venue *Venue `json:"venue"`
	NewChatMembers *[]User `json:"new_chat_members"`
	LeftChatMember *User `json:"left_chat_member"`
	NewChatTitle string `json:"new_chat_title"`
	NewChatPhoto *[]PhotoSize `json:"new_chat_photo"`
	DeleteChatPhoto bool `json:"delete_chat_photo"`
	GroupChatCreated bool `json:"group_chat_created"`
	SuperGroupChatCreated bool `json:"supergroup_chat_created"`
	ChannelChatCreated bool `json:"channel_chat_created"`
	MigrateToChatID int64 `json:"migrate_to_chat_id"`
	MigrateFromChatID int64 `json:"migrate_from_chat_id"`
	PinnedMessage *Message `json:"pinned_message"`
	Invoice *Invoice `json:"invoice"`
	SuccessfulPayment *SuccessfulPayment `json:"successful_payment"`
	PassportData *PassportData `json:"passport_data,omitempty"`
}
func (m *Message) Time() time.Time {
	return time.Unix(int64(m.Date), 0)
}
func (m *Message) IsCommand() bool {
	if m.Entities == nil || len(*m.Entities) == 0 {
		return false
	}
	entity := (*m.Entities)[0]
	return entity.Offset == 0 && entity.IsCommand()
}
func (m *Message) Command() string {
	command := m.CommandWithAt()
	if i := strings.Index(command, "@"); i != -1 {
		command = command[:i]
	}
	return command
}
func (m *Message) CommandWithAt() string {
	if !m.IsCommand() {
		return ""
	}
	entity := (*m.Entities)[0]
	return m.Text[1:entity.Length]
}
func (m *Message) CommandArguments() string {
	if !m.IsCommand() {
		return ""
	}
	entity := (*m.Entities)[0]
	if len(m.Text) == entity.Length {
		return ""  
	}
	return m.Text[entity.Length+1:]
}
type MessageEntity struct {
	Type string `json:"type"`
	Offset int `json:"offset"`
	Length int `json:"length"`
	URL string `json:"url"`
	User *User `json:"user"`
}
func (e MessageEntity) ParseURL() (*url.URL, error) {
	if e.URL == "" {
		return nil, errors.New(ErrBadURL)
	}
	return url.Parse(e.URL)
}
func (e MessageEntity) IsMention() bool {
	return e.Type == "mention"
}
func (e MessageEntity) IsHashtag() bool {
	return e.Type == "hashtag"
}
func (e MessageEntity) IsCommand() bool {
	return e.Type == "bot_command"
}
func (e MessageEntity) IsUrl() bool {
	return e.Type == "url"
}