// 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{} ) // ProcessChatJoinRequestsRequest represents TL type `processChatJoinRequests#3e823dce`. type ProcessChatJoinRequestsRequest struct { // Chat identifier ChatID int64 // Invite link for which to process join requests. If empty, all join requests will be // processed. Requires administrator privileges and can_invite_users right in the chat // for own links and owner privileges for other links InviteLink string // Pass true to approve all requests; pass false to decline them Approve bool } // ProcessChatJoinRequestsRequestTypeID is TL type id of ProcessChatJoinRequestsRequest. const ProcessChatJoinRequestsRequestTypeID = 0x3e823dce // Ensuring interfaces in compile-time for ProcessChatJoinRequestsRequest. var ( _ bin.Encoder = &ProcessChatJoinRequestsRequest{} _ bin.Decoder = &ProcessChatJoinRequestsRequest{} _ bin.BareEncoder = &ProcessChatJoinRequestsRequest{} _ bin.BareDecoder = &ProcessChatJoinRequestsRequest{} ) func (p *ProcessChatJoinRequestsRequest) Zero() bool { if p == nil { return true } if !(p.ChatID == 0) { return false } if !(p.InviteLink == "") { return false } if !(p.Approve == false) { return false } return true } // String implements fmt.Stringer. func (p *ProcessChatJoinRequestsRequest) String() string { if p == nil { return "ProcessChatJoinRequestsRequest(nil)" } type Alias ProcessChatJoinRequestsRequest return fmt.Sprintf("ProcessChatJoinRequestsRequest%+v", Alias(*p)) } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*ProcessChatJoinRequestsRequest) TypeID() uint32 { return ProcessChatJoinRequestsRequestTypeID } // TypeName returns name of type in TL schema. func (*ProcessChatJoinRequestsRequest) TypeName() string { return "processChatJoinRequests" } // TypeInfo returns info about TL type. func (p *ProcessChatJoinRequestsRequest) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "processChatJoinRequests", ID: ProcessChatJoinRequestsRequestTypeID, } if p == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{ { Name: "ChatID", SchemaName: "chat_id", }, { Name: "InviteLink", SchemaName: "invite_link", }, { Name: "Approve", SchemaName: "approve", }, } return typ } // Encode implements bin.Encoder. func (p *ProcessChatJoinRequestsRequest) Encode(b *bin.Buffer) error { if p == nil { return fmt.Errorf("can't encode processChatJoinRequests#3e823dce as nil") } b.PutID(ProcessChatJoinRequestsRequestTypeID) return p.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (p *ProcessChatJoinRequestsRequest) EncodeBare(b *bin.Buffer) error { if p == nil { return fmt.Errorf("can't encode processChatJoinRequests#3e823dce as nil") } b.PutInt53(p.ChatID) b.PutString(p.InviteLink) b.PutBool(p.Approve) return nil } // Decode implements bin.Decoder. func (p *ProcessChatJoinRequestsRequest) Decode(b *bin.Buffer) error { if p == nil { return fmt.Errorf("can't decode processChatJoinRequests#3e823dce to nil") } if err := b.ConsumeID(ProcessChatJoinRequestsRequestTypeID); err != nil { return fmt.Errorf("unable to decode processChatJoinRequests#3e823dce: %w", err) } return p.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (p *ProcessChatJoinRequestsRequest) DecodeBare(b *bin.Buffer) error { if p == nil { return fmt.Errorf("can't decode processChatJoinRequests#3e823dce to nil") } { value, err := b.Int53() if err != nil { return fmt.Errorf("unable to decode processChatJoinRequests#3e823dce: field chat_id: %w", err) } p.ChatID = value } { value, err := b.String() if err != nil { return fmt.Errorf("unable to decode processChatJoinRequests#3e823dce: field invite_link: %w", err) } p.InviteLink = value } { value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode processChatJoinRequests#3e823dce: field approve: %w", err) } p.Approve = value } return nil } // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (p *ProcessChatJoinRequestsRequest) EncodeTDLibJSON(b tdjson.Encoder) error { if p == nil { return fmt.Errorf("can't encode processChatJoinRequests#3e823dce as nil") } b.ObjStart() b.PutID("processChatJoinRequests") b.Comma() b.FieldStart("chat_id") b.PutInt53(p.ChatID) b.Comma() b.FieldStart("invite_link") b.PutString(p.InviteLink) b.Comma() b.FieldStart("approve") b.PutBool(p.Approve) b.Comma() b.StripComma() b.ObjEnd() return nil } // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (p *ProcessChatJoinRequestsRequest) DecodeTDLibJSON(b tdjson.Decoder) error { if p == nil { return fmt.Errorf("can't decode processChatJoinRequests#3e823dce to nil") } return b.Obj(func(b tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := b.ConsumeID("processChatJoinRequests"); err != nil { return fmt.Errorf("unable to decode processChatJoinRequests#3e823dce: %w", err) } case "chat_id": value, err := b.Int53() if err != nil { return fmt.Errorf("unable to decode processChatJoinRequests#3e823dce: field chat_id: %w", err) } p.ChatID = value case "invite_link": value, err := b.String() if err != nil { return fmt.Errorf("unable to decode processChatJoinRequests#3e823dce: field invite_link: %w", err) } p.InviteLink = value case "approve": value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode processChatJoinRequests#3e823dce: field approve: %w", err) } p.Approve = value default: return b.Skip() } return nil }) } // GetChatID returns value of ChatID field. func (p *ProcessChatJoinRequestsRequest) GetChatID() (value int64) { if p == nil { return } return p.ChatID } // GetInviteLink returns value of InviteLink field. func (p *ProcessChatJoinRequestsRequest) GetInviteLink() (value string) { if p == nil { return } return p.InviteLink } // GetApprove returns value of Approve field. func (p *ProcessChatJoinRequestsRequest) GetApprove() (value bool) { if p == nil { return } return p.Approve } // ProcessChatJoinRequests invokes method processChatJoinRequests#3e823dce returning error if any. func (c *Client) ProcessChatJoinRequests(ctx context.Context, request *ProcessChatJoinRequestsRequest) error { var ok Ok if err := c.rpc.Invoke(ctx, request, &ok); err != nil { return err } return nil }