all repos — telegram-bot-api @ 196f515db776397f82c925f1b26c1ad62a16b7d8

Golang bindings for the Telegram Bot API

helper functions on message
Syfaro syfaro@foxpaw.in
Fri, 31 Jul 2015 13:40:42 -0400
commit

196f515db776397f82c925f1b26c1ad62a16b7d8

parent

f605a516c08839642762afae21c793be36659996

1 files changed, 11 insertions(+), 0 deletions(-)

jump to
M types.gotypes.go

@@ -2,6 +2,7 @@ package tgbotapi

import ( "encoding/json" + "time" ) // APIResponse is a response from the Telegram API with the result stored raw.

@@ -80,6 +81,16 @@ NewChatTitle string `json:"new_chat_title"`

NewChatPhoto string `json:"new_chat_photo"` DeleteChatPhoto bool `json:"delete_chat_photo"` 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.