// 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{} ) // ShareChatWithBotRequest represents TL type `shareChatWithBot#a6530ae2`. type ShareChatWithBotRequest struct { // Identifier of the chat with the bot ChatID int64 // Identifier of the message with the button MessageID int64 // Identifier of the button ButtonID int32 // Identifier of the shared chat SharedChatID int64 // Pass true to check that the chat can be shared by the button instead of actually // sharing it. Doesn't check bot_is_member and bot_administrator_rights restrictions. OnlyCheck bool } // ShareChatWithBotRequestTypeID is TL type id of ShareChatWithBotRequest. const ShareChatWithBotRequestTypeID = 0xa6530ae2 // Ensuring interfaces in compile-time for ShareChatWithBotRequest. var ( _ bin.Encoder = &ShareChatWithBotRequest{} _ bin.Decoder = &ShareChatWithBotRequest{} _ bin.BareEncoder = &ShareChatWithBotRequest{} _ bin.BareDecoder = &ShareChatWithBotRequest{} ) func (s *ShareChatWithBotRequest) Zero() bool { if s == nil { return true } if !(s.ChatID == 0) { return false } if !(s.MessageID == 0) { return false } if !(s.ButtonID == 0) { return false } if !(s.SharedChatID == 0) { return false } if !(s.OnlyCheck == false) { return false } return true } // String implements fmt.Stringer. func (s *ShareChatWithBotRequest) String() string { if s == nil { return "ShareChatWithBotRequest(nil)" } type Alias ShareChatWithBotRequest return fmt.Sprintf("ShareChatWithBotRequest%+v", Alias(*s)) } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*ShareChatWithBotRequest) TypeID() uint32 { return ShareChatWithBotRequestTypeID } // TypeName returns name of type in TL schema. func (*ShareChatWithBotRequest) TypeName() string { return "shareChatWithBot" } // TypeInfo returns info about TL type. func (s *ShareChatWithBotRequest) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "shareChatWithBot", ID: ShareChatWithBotRequestTypeID, } if s == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{ { Name: "ChatID", SchemaName: "chat_id", }, { Name: "MessageID", SchemaName: "message_id", }, { Name: "ButtonID", SchemaName: "button_id", }, { Name: "SharedChatID", SchemaName: "shared_chat_id", }, { Name: "OnlyCheck", SchemaName: "only_check", }, } return typ } // Encode implements bin.Encoder. func (s *ShareChatWithBotRequest) Encode(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't encode shareChatWithBot#a6530ae2 as nil") } b.PutID(ShareChatWithBotRequestTypeID) return s.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (s *ShareChatWithBotRequest) EncodeBare(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't encode shareChatWithBot#a6530ae2 as nil") } b.PutInt53(s.ChatID) b.PutInt53(s.MessageID) b.PutInt32(s.ButtonID) b.PutInt53(s.SharedChatID) b.PutBool(s.OnlyCheck) return nil } // Decode implements bin.Decoder. func (s *ShareChatWithBotRequest) Decode(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't decode shareChatWithBot#a6530ae2 to nil") } if err := b.ConsumeID(ShareChatWithBotRequestTypeID); err != nil { return fmt.Errorf("unable to decode shareChatWithBot#a6530ae2: %w", err) } return s.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (s *ShareChatWithBotRequest) DecodeBare(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't decode shareChatWithBot#a6530ae2 to nil") } { value, err := b.Int53() if err != nil { return fmt.Errorf("unable to decode shareChatWithBot#a6530ae2: field chat_id: %w", err) } s.ChatID = value } { value, err := b.Int53() if err != nil { return fmt.Errorf("unable to decode shareChatWithBot#a6530ae2: field message_id: %w", err) } s.MessageID = value } { value, err := b.Int32() if err != nil { return fmt.Errorf("unable to decode shareChatWithBot#a6530ae2: field button_id: %w", err) } s.ButtonID = value } { value, err := b.Int53() if err != nil { return fmt.Errorf("unable to decode shareChatWithBot#a6530ae2: field shared_chat_id: %w", err) } s.SharedChatID = value } { value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode shareChatWithBot#a6530ae2: field only_check: %w", err) } s.OnlyCheck = value } return nil } // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (s *ShareChatWithBotRequest) EncodeTDLibJSON(b tdjson.Encoder) error { if s == nil { return fmt.Errorf("can't encode shareChatWithBot#a6530ae2 as nil") } b.ObjStart() b.PutID("shareChatWithBot") b.Comma() b.FieldStart("chat_id") b.PutInt53(s.ChatID) b.Comma() b.FieldStart("message_id") b.PutInt53(s.MessageID) b.Comma() b.FieldStart("button_id") b.PutInt32(s.ButtonID) b.Comma() b.FieldStart("shared_chat_id") b.PutInt53(s.SharedChatID) b.Comma() b.FieldStart("only_check") b.PutBool(s.OnlyCheck) b.Comma() b.StripComma() b.ObjEnd() return nil } // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (s *ShareChatWithBotRequest) DecodeTDLibJSON(b tdjson.Decoder) error { if s == nil { return fmt.Errorf("can't decode shareChatWithBot#a6530ae2 to nil") } return b.Obj(func(b tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := b.ConsumeID("shareChatWithBot"); err != nil { return fmt.Errorf("unable to decode shareChatWithBot#a6530ae2: %w", err) } case "chat_id": value, err := b.Int53() if err != nil { return fmt.Errorf("unable to decode shareChatWithBot#a6530ae2: field chat_id: %w", err) } s.ChatID = value case "message_id": value, err := b.Int53() if err != nil { return fmt.Errorf("unable to decode shareChatWithBot#a6530ae2: field message_id: %w", err) } s.MessageID = value case "button_id": value, err := b.Int32() if err != nil { return fmt.Errorf("unable to decode shareChatWithBot#a6530ae2: field button_id: %w", err) } s.ButtonID = value case "shared_chat_id": value, err := b.Int53() if err != nil { return fmt.Errorf("unable to decode shareChatWithBot#a6530ae2: field shared_chat_id: %w", err) } s.SharedChatID = value case "only_check": value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode shareChatWithBot#a6530ae2: field only_check: %w", err) } s.OnlyCheck = value default: return b.Skip() } return nil }) } // GetChatID returns value of ChatID field. func (s *ShareChatWithBotRequest) GetChatID() (value int64) { if s == nil { return } return s.ChatID } // GetMessageID returns value of MessageID field. func (s *ShareChatWithBotRequest) GetMessageID() (value int64) { if s == nil { return } return s.MessageID } // GetButtonID returns value of ButtonID field. func (s *ShareChatWithBotRequest) GetButtonID() (value int32) { if s == nil { return } return s.ButtonID } // GetSharedChatID returns value of SharedChatID field. func (s *ShareChatWithBotRequest) GetSharedChatID() (value int64) { if s == nil { return } return s.SharedChatID } // GetOnlyCheck returns value of OnlyCheck field. func (s *ShareChatWithBotRequest) GetOnlyCheck() (value bool) { if s == nil { return } return s.OnlyCheck } // ShareChatWithBot invokes method shareChatWithBot#a6530ae2 returning error if any. func (c *Client) ShareChatWithBot(ctx context.Context, request *ShareChatWithBotRequest) error { var ok Ok if err := c.rpc.Invoke(ctx, request, &ok); err != nil { return err } return nil }