Files
mautrix-telegram/pkg/gotd/tg/tl_web_authorization_gen.go
T
2025-06-27 20:03:37 -07:00

382 lines
7.9 KiB
Go
Generated

// Code generated by gotdgen, DO NOT EDIT.
package tg
import (
"context"
"errors"
"fmt"
"sort"
"strings"
"go.uber.org/multierr"
"go.mau.fi/mautrix-telegram/pkg/gotd/bin"
"go.mau.fi/mautrix-telegram/pkg/gotd/tdjson"
"go.mau.fi/mautrix-telegram/pkg/gotd/tdp"
"go.mau.fi/mautrix-telegram/pkg/gotd/tgerr"
)
// No-op definition for keeping imports.
var (
_ = bin.Buffer{}
_ = context.Background()
_ = fmt.Stringer(nil)
_ = strings.Builder{}
_ = errors.Is
_ = multierr.AppendInto
_ = sort.Ints
_ = tdp.Format
_ = tgerr.Error{}
_ = tdjson.Encoder{}
)
// WebAuthorization represents TL type `webAuthorization#a6f8f452`.
// Represents a bot logged in using the Telegram login widget¹
//
// Links:
// 1. https://core.telegram.org/widgets/login
//
// See https://core.telegram.org/constructor/webAuthorization for reference.
type WebAuthorization struct {
// Authorization hash
Hash int64
// Bot ID
BotID int64
// The domain name of the website on which the user has logged in.
Domain string
// Browser user-agent
Browser string
// Platform
Platform string
// When was the web session created
DateCreated int
// When was the web session last active
DateActive int
// IP address
IP string
// Region, determined from IP address
Region string
}
// WebAuthorizationTypeID is TL type id of WebAuthorization.
const WebAuthorizationTypeID = 0xa6f8f452
// Ensuring interfaces in compile-time for WebAuthorization.
var (
_ bin.Encoder = &WebAuthorization{}
_ bin.Decoder = &WebAuthorization{}
_ bin.BareEncoder = &WebAuthorization{}
_ bin.BareDecoder = &WebAuthorization{}
)
func (w *WebAuthorization) Zero() bool {
if w == nil {
return true
}
if !(w.Hash == 0) {
return false
}
if !(w.BotID == 0) {
return false
}
if !(w.Domain == "") {
return false
}
if !(w.Browser == "") {
return false
}
if !(w.Platform == "") {
return false
}
if !(w.DateCreated == 0) {
return false
}
if !(w.DateActive == 0) {
return false
}
if !(w.IP == "") {
return false
}
if !(w.Region == "") {
return false
}
return true
}
// String implements fmt.Stringer.
func (w *WebAuthorization) String() string {
if w == nil {
return "WebAuthorization(nil)"
}
type Alias WebAuthorization
return fmt.Sprintf("WebAuthorization%+v", Alias(*w))
}
// FillFrom fills WebAuthorization from given interface.
func (w *WebAuthorization) FillFrom(from interface {
GetHash() (value int64)
GetBotID() (value int64)
GetDomain() (value string)
GetBrowser() (value string)
GetPlatform() (value string)
GetDateCreated() (value int)
GetDateActive() (value int)
GetIP() (value string)
GetRegion() (value string)
}) {
w.Hash = from.GetHash()
w.BotID = from.GetBotID()
w.Domain = from.GetDomain()
w.Browser = from.GetBrowser()
w.Platform = from.GetPlatform()
w.DateCreated = from.GetDateCreated()
w.DateActive = from.GetDateActive()
w.IP = from.GetIP()
w.Region = from.GetRegion()
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*WebAuthorization) TypeID() uint32 {
return WebAuthorizationTypeID
}
// TypeName returns name of type in TL schema.
func (*WebAuthorization) TypeName() string {
return "webAuthorization"
}
// TypeInfo returns info about TL type.
func (w *WebAuthorization) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "webAuthorization",
ID: WebAuthorizationTypeID,
}
if w == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "Hash",
SchemaName: "hash",
},
{
Name: "BotID",
SchemaName: "bot_id",
},
{
Name: "Domain",
SchemaName: "domain",
},
{
Name: "Browser",
SchemaName: "browser",
},
{
Name: "Platform",
SchemaName: "platform",
},
{
Name: "DateCreated",
SchemaName: "date_created",
},
{
Name: "DateActive",
SchemaName: "date_active",
},
{
Name: "IP",
SchemaName: "ip",
},
{
Name: "Region",
SchemaName: "region",
},
}
return typ
}
// Encode implements bin.Encoder.
func (w *WebAuthorization) Encode(b *bin.Buffer) error {
if w == nil {
return fmt.Errorf("can't encode webAuthorization#a6f8f452 as nil")
}
b.PutID(WebAuthorizationTypeID)
return w.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (w *WebAuthorization) EncodeBare(b *bin.Buffer) error {
if w == nil {
return fmt.Errorf("can't encode webAuthorization#a6f8f452 as nil")
}
b.PutLong(w.Hash)
b.PutLong(w.BotID)
b.PutString(w.Domain)
b.PutString(w.Browser)
b.PutString(w.Platform)
b.PutInt(w.DateCreated)
b.PutInt(w.DateActive)
b.PutString(w.IP)
b.PutString(w.Region)
return nil
}
// Decode implements bin.Decoder.
func (w *WebAuthorization) Decode(b *bin.Buffer) error {
if w == nil {
return fmt.Errorf("can't decode webAuthorization#a6f8f452 to nil")
}
if err := b.ConsumeID(WebAuthorizationTypeID); err != nil {
return fmt.Errorf("unable to decode webAuthorization#a6f8f452: %w", err)
}
return w.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (w *WebAuthorization) DecodeBare(b *bin.Buffer) error {
if w == nil {
return fmt.Errorf("can't decode webAuthorization#a6f8f452 to nil")
}
{
value, err := b.Long()
if err != nil {
return fmt.Errorf("unable to decode webAuthorization#a6f8f452: field hash: %w", err)
}
w.Hash = value
}
{
value, err := b.Long()
if err != nil {
return fmt.Errorf("unable to decode webAuthorization#a6f8f452: field bot_id: %w", err)
}
w.BotID = value
}
{
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode webAuthorization#a6f8f452: field domain: %w", err)
}
w.Domain = value
}
{
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode webAuthorization#a6f8f452: field browser: %w", err)
}
w.Browser = value
}
{
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode webAuthorization#a6f8f452: field platform: %w", err)
}
w.Platform = value
}
{
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode webAuthorization#a6f8f452: field date_created: %w", err)
}
w.DateCreated = value
}
{
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode webAuthorization#a6f8f452: field date_active: %w", err)
}
w.DateActive = value
}
{
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode webAuthorization#a6f8f452: field ip: %w", err)
}
w.IP = value
}
{
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode webAuthorization#a6f8f452: field region: %w", err)
}
w.Region = value
}
return nil
}
// GetHash returns value of Hash field.
func (w *WebAuthorization) GetHash() (value int64) {
if w == nil {
return
}
return w.Hash
}
// GetBotID returns value of BotID field.
func (w *WebAuthorization) GetBotID() (value int64) {
if w == nil {
return
}
return w.BotID
}
// GetDomain returns value of Domain field.
func (w *WebAuthorization) GetDomain() (value string) {
if w == nil {
return
}
return w.Domain
}
// GetBrowser returns value of Browser field.
func (w *WebAuthorization) GetBrowser() (value string) {
if w == nil {
return
}
return w.Browser
}
// GetPlatform returns value of Platform field.
func (w *WebAuthorization) GetPlatform() (value string) {
if w == nil {
return
}
return w.Platform
}
// GetDateCreated returns value of DateCreated field.
func (w *WebAuthorization) GetDateCreated() (value int) {
if w == nil {
return
}
return w.DateCreated
}
// GetDateActive returns value of DateActive field.
func (w *WebAuthorization) GetDateActive() (value int) {
if w == nil {
return
}
return w.DateActive
}
// GetIP returns value of IP field.
func (w *WebAuthorization) GetIP() (value string) {
if w == nil {
return
}
return w.IP
}
// GetRegion returns value of Region field.
func (w *WebAuthorization) GetRegion() (value string) {
if w == nil {
return
}
return w.Region
}