Archived
1
This repository has been archived on 2022-11-04. You can view files and clone it, but cannot push or open issues or pull requests.
fwzookeeper/vendor/gitlab.com/toby3d/telegram/utils_member.go

47 lines
1.2 KiB
Go
Raw Normal View History

2018-11-29 20:32:51 +04:00
package telegram
import (
"strings"
"time"
)
// IsCreator checks that current member is creator.
func (m *ChatMember) IsCreator() bool {
return m != nil && strings.EqualFold(m.Status, StatusCreator)
}
// IsAdministrator checks that current member is administrator.
func (m *ChatMember) IsAdministrator() bool {
return m != nil && strings.EqualFold(m.Status, StatusAdministrator)
}
// IsMember checks that current member is a m.
func (m *ChatMember) IsMember() bool {
return m != nil && strings.EqualFold(m.Status, StatusMember)
}
// IsRestricted checks that current member has been restricted.
func (m *ChatMember) IsRestricted() bool {
return m != nil && strings.EqualFold(m.Status, StatusRestricted)
}
// IsLeft checks that current member has left the chat.
func (m *ChatMember) IsLeft() bool {
return m != nil && strings.EqualFold(m.Status, StatusLeft)
}
// IsKicked checks that current member has been kicked.
func (m *ChatMember) IsKicked() bool {
return m != nil && strings.EqualFold(m.Status, StatusKicked)
}
// UntilTime parse UntilDate of restrictions and returns time.Time.
func (m *ChatMember) UntilTime() *time.Time {
if m == nil {
return nil
}
ut := time.Unix(m.UntilDate, 0)
return &ut
}