Source File
tdlib_ids.go
Belonging Package
github.com/gotd/td/constant
package constant
const (
// MaxTDLibChatID is maximum chat TDLib ID.
MaxTDLibChatID = 999999999999
// MaxTDLibChannelID is maximum channel TDLib ID.
MaxTDLibChannelID = 1000000000000 - int64(1<<31)
// ZeroTDLibChannelID is minimum channel TDLib ID.
ZeroTDLibChannelID = -1000000000000
// ZeroTDLibSecretChatID is minimum secret chat TDLib ID.
ZeroTDLibSecretChatID = -2000000000000
// MaxTDLibUserID is maximum user TDLib ID.
MaxTDLibUserID = (1 << 40) - 1
)
// TDLibPeerID is TDLib's peer ID.
type TDLibPeerID int64
// User sets TDLibPeerID value as user.
func ( *TDLibPeerID) ( int64) {
* = TDLibPeerID()
}
// Chat sets TDLibPeerID value as chat.
func ( *TDLibPeerID) ( int64) {
* = TDLibPeerID(-)
}
// Channel sets TDLibPeerID value as channel.
func ( *TDLibPeerID) ( int64) {
* = TDLibPeerID(ZeroTDLibChannelID + ( * -1))
}
// ToPlain converts TDLib ID to plain ID.
func ( TDLibPeerID) () ( int64) {
switch {
case .IsUser():
= int64()
case .IsChat():
= int64(-)
case .IsChannel():
= int64() - ZeroTDLibChannelID
= -
}
return
}
// IsUser whether that given ID is user ID.
func ( TDLibPeerID) () bool {
return > 0 && <= MaxTDLibUserID
}
// IsChat whether that given ID is chat ID.
func ( TDLibPeerID) () bool {
return < 0 && -MaxTDLibChatID <=
}
// IsChannel whether that given ID is channel ID.
func ( TDLibPeerID) () bool {
return < 0 &&
!= ZeroTDLibChannelID &&
!.IsChat() &&
ZeroTDLibChannelID-TDLibPeerID(MaxTDLibChannelID) <=
}
The pages are generated with Golds v0.6.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |