// 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{} ) // GetBotSimilarBotsRequest represents TL type `getBotSimilarBots#ced15fb5`. type GetBotSimilarBotsRequest struct { // User identifier of the target bot BotUserID int64 } // GetBotSimilarBotsRequestTypeID is TL type id of GetBotSimilarBotsRequest. const GetBotSimilarBotsRequestTypeID = 0xced15fb5 // Ensuring interfaces in compile-time for GetBotSimilarBotsRequest. var ( _ bin.Encoder = &GetBotSimilarBotsRequest{} _ bin.Decoder = &GetBotSimilarBotsRequest{} _ bin.BareEncoder = &GetBotSimilarBotsRequest{} _ bin.BareDecoder = &GetBotSimilarBotsRequest{} ) func (g *GetBotSimilarBotsRequest) Zero() bool { if g == nil { return true } if !(g.BotUserID == 0) { return false } return true } // String implements fmt.Stringer. func (g *GetBotSimilarBotsRequest) String() string { if g == nil { return "GetBotSimilarBotsRequest(nil)" } type Alias GetBotSimilarBotsRequest return fmt.Sprintf("GetBotSimilarBotsRequest%+v", Alias(*g)) } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*GetBotSimilarBotsRequest) TypeID() uint32 { return GetBotSimilarBotsRequestTypeID } // TypeName returns name of type in TL schema. func (*GetBotSimilarBotsRequest) TypeName() string { return "getBotSimilarBots" } // TypeInfo returns info about TL type. func (g *GetBotSimilarBotsRequest) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "getBotSimilarBots", ID: GetBotSimilarBotsRequestTypeID, } if g == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{ { Name: "BotUserID", SchemaName: "bot_user_id", }, } return typ } // Encode implements bin.Encoder. func (g *GetBotSimilarBotsRequest) Encode(b *bin.Buffer) error { if g == nil { return fmt.Errorf("can't encode getBotSimilarBots#ced15fb5 as nil") } b.PutID(GetBotSimilarBotsRequestTypeID) return g.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (g *GetBotSimilarBotsRequest) EncodeBare(b *bin.Buffer) error { if g == nil { return fmt.Errorf("can't encode getBotSimilarBots#ced15fb5 as nil") } b.PutInt53(g.BotUserID) return nil } // Decode implements bin.Decoder. func (g *GetBotSimilarBotsRequest) Decode(b *bin.Buffer) error { if g == nil { return fmt.Errorf("can't decode getBotSimilarBots#ced15fb5 to nil") } if err := b.ConsumeID(GetBotSimilarBotsRequestTypeID); err != nil { return fmt.Errorf("unable to decode getBotSimilarBots#ced15fb5: %w", err) } return g.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (g *GetBotSimilarBotsRequest) DecodeBare(b *bin.Buffer) error { if g == nil { return fmt.Errorf("can't decode getBotSimilarBots#ced15fb5 to nil") } { value, err := b.Int53() if err != nil { return fmt.Errorf("unable to decode getBotSimilarBots#ced15fb5: field bot_user_id: %w", err) } g.BotUserID = value } return nil } // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (g *GetBotSimilarBotsRequest) EncodeTDLibJSON(b tdjson.Encoder) error { if g == nil { return fmt.Errorf("can't encode getBotSimilarBots#ced15fb5 as nil") } b.ObjStart() b.PutID("getBotSimilarBots") b.Comma() b.FieldStart("bot_user_id") b.PutInt53(g.BotUserID) b.Comma() b.StripComma() b.ObjEnd() return nil } // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (g *GetBotSimilarBotsRequest) DecodeTDLibJSON(b tdjson.Decoder) error { if g == nil { return fmt.Errorf("can't decode getBotSimilarBots#ced15fb5 to nil") } return b.Obj(func(b tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := b.ConsumeID("getBotSimilarBots"); err != nil { return fmt.Errorf("unable to decode getBotSimilarBots#ced15fb5: %w", err) } case "bot_user_id": value, err := b.Int53() if err != nil { return fmt.Errorf("unable to decode getBotSimilarBots#ced15fb5: field bot_user_id: %w", err) } g.BotUserID = value default: return b.Skip() } return nil }) } // GetBotUserID returns value of BotUserID field. func (g *GetBotSimilarBotsRequest) GetBotUserID() (value int64) { if g == nil { return } return g.BotUserID } // GetBotSimilarBots invokes method getBotSimilarBots#ced15fb5 returning error if any. func (c *Client) GetBotSimilarBots(ctx context.Context, botuserid int64) (*Users, error) { var result Users request := &GetBotSimilarBotsRequest{ BotUserID: botuserid, } if err := c.rpc.Invoke(ctx, request, &result); err != nil { return nil, err } return &result, nil }