// 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{} ) // BotsSendCustomRequestRequest represents TL type `bots.sendCustomRequest#aa2769ed`. // Sends a custom request; for bots only // // See https://core.telegram.org/method/bots.sendCustomRequest for reference. type BotsSendCustomRequestRequest struct { // The method name CustomMethod string // JSON-serialized method parameters Params DataJSON } // BotsSendCustomRequestRequestTypeID is TL type id of BotsSendCustomRequestRequest. const BotsSendCustomRequestRequestTypeID = 0xaa2769ed // Ensuring interfaces in compile-time for BotsSendCustomRequestRequest. var ( _ bin.Encoder = &BotsSendCustomRequestRequest{} _ bin.Decoder = &BotsSendCustomRequestRequest{} _ bin.BareEncoder = &BotsSendCustomRequestRequest{} _ bin.BareDecoder = &BotsSendCustomRequestRequest{} ) func (s *BotsSendCustomRequestRequest) Zero() bool { if s == nil { return true } if !(s.CustomMethod == "") { return false } if !(s.Params.Zero()) { return false } return true } // String implements fmt.Stringer. func (s *BotsSendCustomRequestRequest) String() string { if s == nil { return "BotsSendCustomRequestRequest(nil)" } type Alias BotsSendCustomRequestRequest return fmt.Sprintf("BotsSendCustomRequestRequest%+v", Alias(*s)) } // FillFrom fills BotsSendCustomRequestRequest from given interface. func (s *BotsSendCustomRequestRequest) FillFrom(from interface { GetCustomMethod() (value string) GetParams() (value DataJSON) }) { s.CustomMethod = from.GetCustomMethod() s.Params = from.GetParams() } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*BotsSendCustomRequestRequest) TypeID() uint32 { return BotsSendCustomRequestRequestTypeID } // TypeName returns name of type in TL schema. func (*BotsSendCustomRequestRequest) TypeName() string { return "bots.sendCustomRequest" } // TypeInfo returns info about TL type. func (s *BotsSendCustomRequestRequest) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "bots.sendCustomRequest", ID: BotsSendCustomRequestRequestTypeID, } if s == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{ { Name: "CustomMethod", SchemaName: "custom_method", }, { Name: "Params", SchemaName: "params", }, } return typ } // Encode implements bin.Encoder. func (s *BotsSendCustomRequestRequest) Encode(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't encode bots.sendCustomRequest#aa2769ed as nil") } b.PutID(BotsSendCustomRequestRequestTypeID) return s.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (s *BotsSendCustomRequestRequest) EncodeBare(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't encode bots.sendCustomRequest#aa2769ed as nil") } b.PutString(s.CustomMethod) if err := s.Params.Encode(b); err != nil { return fmt.Errorf("unable to encode bots.sendCustomRequest#aa2769ed: field params: %w", err) } return nil } // Decode implements bin.Decoder. func (s *BotsSendCustomRequestRequest) Decode(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't decode bots.sendCustomRequest#aa2769ed to nil") } if err := b.ConsumeID(BotsSendCustomRequestRequestTypeID); err != nil { return fmt.Errorf("unable to decode bots.sendCustomRequest#aa2769ed: %w", err) } return s.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (s *BotsSendCustomRequestRequest) DecodeBare(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't decode bots.sendCustomRequest#aa2769ed to nil") } { value, err := b.String() if err != nil { return fmt.Errorf("unable to decode bots.sendCustomRequest#aa2769ed: field custom_method: %w", err) } s.CustomMethod = value } { if err := s.Params.Decode(b); err != nil { return fmt.Errorf("unable to decode bots.sendCustomRequest#aa2769ed: field params: %w", err) } } return nil } // GetCustomMethod returns value of CustomMethod field. func (s *BotsSendCustomRequestRequest) GetCustomMethod() (value string) { if s == nil { return } return s.CustomMethod } // GetParams returns value of Params field. func (s *BotsSendCustomRequestRequest) GetParams() (value DataJSON) { if s == nil { return } return s.Params } // BotsSendCustomRequest invokes method bots.sendCustomRequest#aa2769ed returning error if any. // Sends a custom request; for bots only // // Possible errors: // // 400 DATA_JSON_INVALID: The provided JSON data is invalid. // 400 METHOD_INVALID: The specified method is invalid. // 400 USER_BOT_REQUIRED: This method can only be called by a bot. // // See https://core.telegram.org/method/bots.sendCustomRequest for reference. func (c *Client) BotsSendCustomRequest(ctx context.Context, request *BotsSendCustomRequestRequest) (*DataJSON, error) { var result DataJSON if err := c.rpc.Invoke(ctx, request, &result); err != nil { return nil, err } return &result, nil }