// Code generated by gotdgen, DO NOT EDIT. package tdapi 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{} ) // BusinessBotManageBar represents TL type `businessBotManageBar#ed706a82`. type BusinessBotManageBar struct { // User identifier of the bot BotUserID int64 // URL to be opened to manage the bot ManageURL string // True, if the bot is paused. Use toggleBusinessConnectedBotChatIsPaused to change the // value of the field IsBotPaused bool // True, if the bot can reply CanBotReply bool } // BusinessBotManageBarTypeID is TL type id of BusinessBotManageBar. const BusinessBotManageBarTypeID = 0xed706a82 // Ensuring interfaces in compile-time for BusinessBotManageBar. var ( _ bin.Encoder = &BusinessBotManageBar{} _ bin.Decoder = &BusinessBotManageBar{} _ bin.BareEncoder = &BusinessBotManageBar{} _ bin.BareDecoder = &BusinessBotManageBar{} ) func (b *BusinessBotManageBar) Zero() bool { if b == nil { return true } if !(b.BotUserID == 0) { return false } if !(b.ManageURL == "") { return false } if !(b.IsBotPaused == false) { return false } if !(b.CanBotReply == false) { return false } return true } // String implements fmt.Stringer. func (b *BusinessBotManageBar) String() string { if b == nil { return "BusinessBotManageBar(nil)" } type Alias BusinessBotManageBar return fmt.Sprintf("BusinessBotManageBar%+v", Alias(*b)) } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*BusinessBotManageBar) TypeID() uint32 { return BusinessBotManageBarTypeID } // TypeName returns name of type in TL schema. func (*BusinessBotManageBar) TypeName() string { return "businessBotManageBar" } // TypeInfo returns info about TL type. func (b *BusinessBotManageBar) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "businessBotManageBar", ID: BusinessBotManageBarTypeID, } if b == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{ { Name: "BotUserID", SchemaName: "bot_user_id", }, { Name: "ManageURL", SchemaName: "manage_url", }, { Name: "IsBotPaused", SchemaName: "is_bot_paused", }, { Name: "CanBotReply", SchemaName: "can_bot_reply", }, } return typ } // Encode implements bin.Encoder. func (b *BusinessBotManageBar) Encode(buf *bin.Buffer) error { if b == nil { return fmt.Errorf("can't encode businessBotManageBar#ed706a82 as nil") } buf.PutID(BusinessBotManageBarTypeID) return b.EncodeBare(buf) } // EncodeBare implements bin.BareEncoder. func (b *BusinessBotManageBar) EncodeBare(buf *bin.Buffer) error { if b == nil { return fmt.Errorf("can't encode businessBotManageBar#ed706a82 as nil") } buf.PutInt53(b.BotUserID) buf.PutString(b.ManageURL) buf.PutBool(b.IsBotPaused) buf.PutBool(b.CanBotReply) return nil } // Decode implements bin.Decoder. func (b *BusinessBotManageBar) Decode(buf *bin.Buffer) error { if b == nil { return fmt.Errorf("can't decode businessBotManageBar#ed706a82 to nil") } if err := buf.ConsumeID(BusinessBotManageBarTypeID); err != nil { return fmt.Errorf("unable to decode businessBotManageBar#ed706a82: %w", err) } return b.DecodeBare(buf) } // DecodeBare implements bin.BareDecoder. func (b *BusinessBotManageBar) DecodeBare(buf *bin.Buffer) error { if b == nil { return fmt.Errorf("can't decode businessBotManageBar#ed706a82 to nil") } { value, err := buf.Int53() if err != nil { return fmt.Errorf("unable to decode businessBotManageBar#ed706a82: field bot_user_id: %w", err) } b.BotUserID = value } { value, err := buf.String() if err != nil { return fmt.Errorf("unable to decode businessBotManageBar#ed706a82: field manage_url: %w", err) } b.ManageURL = value } { value, err := buf.Bool() if err != nil { return fmt.Errorf("unable to decode businessBotManageBar#ed706a82: field is_bot_paused: %w", err) } b.IsBotPaused = value } { value, err := buf.Bool() if err != nil { return fmt.Errorf("unable to decode businessBotManageBar#ed706a82: field can_bot_reply: %w", err) } b.CanBotReply = value } return nil } // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (b *BusinessBotManageBar) EncodeTDLibJSON(buf tdjson.Encoder) error { if b == nil { return fmt.Errorf("can't encode businessBotManageBar#ed706a82 as nil") } buf.ObjStart() buf.PutID("businessBotManageBar") buf.Comma() buf.FieldStart("bot_user_id") buf.PutInt53(b.BotUserID) buf.Comma() buf.FieldStart("manage_url") buf.PutString(b.ManageURL) buf.Comma() buf.FieldStart("is_bot_paused") buf.PutBool(b.IsBotPaused) buf.Comma() buf.FieldStart("can_bot_reply") buf.PutBool(b.CanBotReply) buf.Comma() buf.StripComma() buf.ObjEnd() return nil } // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (b *BusinessBotManageBar) DecodeTDLibJSON(buf tdjson.Decoder) error { if b == nil { return fmt.Errorf("can't decode businessBotManageBar#ed706a82 to nil") } return buf.Obj(func(buf tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := buf.ConsumeID("businessBotManageBar"); err != nil { return fmt.Errorf("unable to decode businessBotManageBar#ed706a82: %w", err) } case "bot_user_id": value, err := buf.Int53() if err != nil { return fmt.Errorf("unable to decode businessBotManageBar#ed706a82: field bot_user_id: %w", err) } b.BotUserID = value case "manage_url": value, err := buf.String() if err != nil { return fmt.Errorf("unable to decode businessBotManageBar#ed706a82: field manage_url: %w", err) } b.ManageURL = value case "is_bot_paused": value, err := buf.Bool() if err != nil { return fmt.Errorf("unable to decode businessBotManageBar#ed706a82: field is_bot_paused: %w", err) } b.IsBotPaused = value case "can_bot_reply": value, err := buf.Bool() if err != nil { return fmt.Errorf("unable to decode businessBotManageBar#ed706a82: field can_bot_reply: %w", err) } b.CanBotReply = value default: return buf.Skip() } return nil }) } // GetBotUserID returns value of BotUserID field. func (b *BusinessBotManageBar) GetBotUserID() (value int64) { if b == nil { return } return b.BotUserID } // GetManageURL returns value of ManageURL field. func (b *BusinessBotManageBar) GetManageURL() (value string) { if b == nil { return } return b.ManageURL } // GetIsBotPaused returns value of IsBotPaused field. func (b *BusinessBotManageBar) GetIsBotPaused() (value bool) { if b == nil { return } return b.IsBotPaused } // GetCanBotReply returns value of CanBotReply field. func (b *BusinessBotManageBar) GetCanBotReply() (value bool) { if b == nil { return } return b.CanBotReply }