helper functions on message

bot-api-6.1
Syfaro 2015-07-31 13:40:42 -04:00
parent f605a516c0
commit 196f515db7
1 changed files with 11 additions and 0 deletions

View File

@ -2,6 +2,7 @@ package tgbotapi
import ( import (
"encoding/json" "encoding/json"
"time"
) )
// APIResponse is a response from the Telegram API with the result stored raw. // APIResponse is a response from the Telegram API with the result stored raw.
@ -82,6 +83,16 @@ type Message struct {
GroupChatCreated bool `json:"group_chat_created"` GroupChatCreated bool `json:"group_chat_created"`
} }
// Time converts the message timestamp into a Time.
func (m *Message) Time() time.Time {
return time.Unix(int64(m.Date), 0)
}
// IsGroup returns if the message was sent to a group.
func (m *Message) IsGroup() bool {
return m.From.ID != m.Chat.ID
}
// PhotoSize contains information about photos, including ID and Width and Height. // PhotoSize contains information about photos, including ID and Width and Height.
type PhotoSize struct { type PhotoSize struct {
FileID string `json:"file_id"` FileID string `json:"file_id"`