// 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{} ) // SetChatDescriptionRequest represents TL type `setChatDescription#74a8b45d`. type SetChatDescriptionRequest struct { // Identifier of the chat ChatID int64 // Changes information about a chat. Available for basic groups, supergroups, and // channels. Requires can_change_info member right Description string } // SetChatDescriptionRequestTypeID is TL type id of SetChatDescriptionRequest. const SetChatDescriptionRequestTypeID = 0x74a8b45d // Ensuring interfaces in compile-time for SetChatDescriptionRequest. var ( _ bin.Encoder = &SetChatDescriptionRequest{} _ bin.Decoder = &SetChatDescriptionRequest{} _ bin.BareEncoder = &SetChatDescriptionRequest{} _ bin.BareDecoder = &SetChatDescriptionRequest{} ) func (s *SetChatDescriptionRequest) Zero() bool { if s == nil { return true } if !(s.ChatID == 0) { return false } if !(s.Description == "") { return false } return true } // String implements fmt.Stringer. func (s *SetChatDescriptionRequest) String() string { if s == nil { return "SetChatDescriptionRequest(nil)" } type Alias SetChatDescriptionRequest return fmt.Sprintf("SetChatDescriptionRequest%+v", Alias(*s)) } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*SetChatDescriptionRequest) TypeID() uint32 { return SetChatDescriptionRequestTypeID } // TypeName returns name of type in TL schema. func (*SetChatDescriptionRequest) TypeName() string { return "setChatDescription" } // TypeInfo returns info about TL type. func (s *SetChatDescriptionRequest) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "setChatDescription", ID: SetChatDescriptionRequestTypeID, } if s == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{ { Name: "ChatID", SchemaName: "chat_id", }, { Name: "Description", SchemaName: "description", }, } return typ } // Encode implements bin.Encoder. func (s *SetChatDescriptionRequest) Encode(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't encode setChatDescription#74a8b45d as nil") } b.PutID(SetChatDescriptionRequestTypeID) return s.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (s *SetChatDescriptionRequest) EncodeBare(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't encode setChatDescription#74a8b45d as nil") } b.PutInt53(s.ChatID) b.PutString(s.Description) return nil } // Decode implements bin.Decoder. func (s *SetChatDescriptionRequest) Decode(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't decode setChatDescription#74a8b45d to nil") } if err := b.ConsumeID(SetChatDescriptionRequestTypeID); err != nil { return fmt.Errorf("unable to decode setChatDescription#74a8b45d: %w", err) } return s.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (s *SetChatDescriptionRequest) DecodeBare(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't decode setChatDescription#74a8b45d to nil") } { value, err := b.Int53() if err != nil { return fmt.Errorf("unable to decode setChatDescription#74a8b45d: field chat_id: %w", err) } s.ChatID = value } { value, err := b.String() if err != nil { return fmt.Errorf("unable to decode setChatDescription#74a8b45d: field description: %w", err) } s.Description = value } return nil } // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (s *SetChatDescriptionRequest) EncodeTDLibJSON(b tdjson.Encoder) error { if s == nil { return fmt.Errorf("can't encode setChatDescription#74a8b45d as nil") } b.ObjStart() b.PutID("setChatDescription") b.Comma() b.FieldStart("chat_id") b.PutInt53(s.ChatID) b.Comma() b.FieldStart("description") b.PutString(s.Description) b.Comma() b.StripComma() b.ObjEnd() return nil } // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (s *SetChatDescriptionRequest) DecodeTDLibJSON(b tdjson.Decoder) error { if s == nil { return fmt.Errorf("can't decode setChatDescription#74a8b45d to nil") } return b.Obj(func(b tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := b.ConsumeID("setChatDescription"); err != nil { return fmt.Errorf("unable to decode setChatDescription#74a8b45d: %w", err) } case "chat_id": value, err := b.Int53() if err != nil { return fmt.Errorf("unable to decode setChatDescription#74a8b45d: field chat_id: %w", err) } s.ChatID = value case "description": value, err := b.String() if err != nil { return fmt.Errorf("unable to decode setChatDescription#74a8b45d: field description: %w", err) } s.Description = value default: return b.Skip() } return nil }) } // GetChatID returns value of ChatID field. func (s *SetChatDescriptionRequest) GetChatID() (value int64) { if s == nil { return } return s.ChatID } // GetDescription returns value of Description field. func (s *SetChatDescriptionRequest) GetDescription() (value string) { if s == nil { return } return s.Description } // SetChatDescription invokes method setChatDescription#74a8b45d returning error if any. func (c *Client) SetChatDescription(ctx context.Context, request *SetChatDescriptionRequest) error { var ok Ok if err := c.rpc.Invoke(ctx, request, &ok); err != nil { return err } return nil }