// 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{} ) // AnswerCallbackQueryRequest represents TL type `answerCallbackQuery#bb462e76`. type AnswerCallbackQueryRequest struct { // Identifier of the callback query CallbackQueryID int64 // Text of the answer Text string // Pass true to show an alert to the user instead of a toast notification ShowAlert bool // URL to be opened URL string // Time during which the result of the query can be cached, in seconds CacheTime int32 } // AnswerCallbackQueryRequestTypeID is TL type id of AnswerCallbackQueryRequest. const AnswerCallbackQueryRequestTypeID = 0xbb462e76 // Ensuring interfaces in compile-time for AnswerCallbackQueryRequest. var ( _ bin.Encoder = &AnswerCallbackQueryRequest{} _ bin.Decoder = &AnswerCallbackQueryRequest{} _ bin.BareEncoder = &AnswerCallbackQueryRequest{} _ bin.BareDecoder = &AnswerCallbackQueryRequest{} ) func (a *AnswerCallbackQueryRequest) Zero() bool { if a == nil { return true } if !(a.CallbackQueryID == 0) { return false } if !(a.Text == "") { return false } if !(a.ShowAlert == false) { return false } if !(a.URL == "") { return false } if !(a.CacheTime == 0) { return false } return true } // String implements fmt.Stringer. func (a *AnswerCallbackQueryRequest) String() string { if a == nil { return "AnswerCallbackQueryRequest(nil)" } type Alias AnswerCallbackQueryRequest return fmt.Sprintf("AnswerCallbackQueryRequest%+v", Alias(*a)) } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*AnswerCallbackQueryRequest) TypeID() uint32 { return AnswerCallbackQueryRequestTypeID } // TypeName returns name of type in TL schema. func (*AnswerCallbackQueryRequest) TypeName() string { return "answerCallbackQuery" } // TypeInfo returns info about TL type. func (a *AnswerCallbackQueryRequest) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "answerCallbackQuery", ID: AnswerCallbackQueryRequestTypeID, } if a == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{ { Name: "CallbackQueryID", SchemaName: "callback_query_id", }, { Name: "Text", SchemaName: "text", }, { Name: "ShowAlert", SchemaName: "show_alert", }, { Name: "URL", SchemaName: "url", }, { Name: "CacheTime", SchemaName: "cache_time", }, } return typ } // Encode implements bin.Encoder. func (a *AnswerCallbackQueryRequest) Encode(b *bin.Buffer) error { if a == nil { return fmt.Errorf("can't encode answerCallbackQuery#bb462e76 as nil") } b.PutID(AnswerCallbackQueryRequestTypeID) return a.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (a *AnswerCallbackQueryRequest) EncodeBare(b *bin.Buffer) error { if a == nil { return fmt.Errorf("can't encode answerCallbackQuery#bb462e76 as nil") } b.PutLong(a.CallbackQueryID) b.PutString(a.Text) b.PutBool(a.ShowAlert) b.PutString(a.URL) b.PutInt32(a.CacheTime) return nil } // Decode implements bin.Decoder. func (a *AnswerCallbackQueryRequest) Decode(b *bin.Buffer) error { if a == nil { return fmt.Errorf("can't decode answerCallbackQuery#bb462e76 to nil") } if err := b.ConsumeID(AnswerCallbackQueryRequestTypeID); err != nil { return fmt.Errorf("unable to decode answerCallbackQuery#bb462e76: %w", err) } return a.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (a *AnswerCallbackQueryRequest) DecodeBare(b *bin.Buffer) error { if a == nil { return fmt.Errorf("can't decode answerCallbackQuery#bb462e76 to nil") } { value, err := b.Long() if err != nil { return fmt.Errorf("unable to decode answerCallbackQuery#bb462e76: field callback_query_id: %w", err) } a.CallbackQueryID = value } { value, err := b.String() if err != nil { return fmt.Errorf("unable to decode answerCallbackQuery#bb462e76: field text: %w", err) } a.Text = value } { value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode answerCallbackQuery#bb462e76: field show_alert: %w", err) } a.ShowAlert = value } { value, err := b.String() if err != nil { return fmt.Errorf("unable to decode answerCallbackQuery#bb462e76: field url: %w", err) } a.URL = value } { value, err := b.Int32() if err != nil { return fmt.Errorf("unable to decode answerCallbackQuery#bb462e76: field cache_time: %w", err) } a.CacheTime = value } return nil } // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (a *AnswerCallbackQueryRequest) EncodeTDLibJSON(b tdjson.Encoder) error { if a == nil { return fmt.Errorf("can't encode answerCallbackQuery#bb462e76 as nil") } b.ObjStart() b.PutID("answerCallbackQuery") b.Comma() b.FieldStart("callback_query_id") b.PutLong(a.CallbackQueryID) b.Comma() b.FieldStart("text") b.PutString(a.Text) b.Comma() b.FieldStart("show_alert") b.PutBool(a.ShowAlert) b.Comma() b.FieldStart("url") b.PutString(a.URL) b.Comma() b.FieldStart("cache_time") b.PutInt32(a.CacheTime) b.Comma() b.StripComma() b.ObjEnd() return nil } // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (a *AnswerCallbackQueryRequest) DecodeTDLibJSON(b tdjson.Decoder) error { if a == nil { return fmt.Errorf("can't decode answerCallbackQuery#bb462e76 to nil") } return b.Obj(func(b tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := b.ConsumeID("answerCallbackQuery"); err != nil { return fmt.Errorf("unable to decode answerCallbackQuery#bb462e76: %w", err) } case "callback_query_id": value, err := b.Long() if err != nil { return fmt.Errorf("unable to decode answerCallbackQuery#bb462e76: field callback_query_id: %w", err) } a.CallbackQueryID = value case "text": value, err := b.String() if err != nil { return fmt.Errorf("unable to decode answerCallbackQuery#bb462e76: field text: %w", err) } a.Text = value case "show_alert": value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode answerCallbackQuery#bb462e76: field show_alert: %w", err) } a.ShowAlert = value case "url": value, err := b.String() if err != nil { return fmt.Errorf("unable to decode answerCallbackQuery#bb462e76: field url: %w", err) } a.URL = value case "cache_time": value, err := b.Int32() if err != nil { return fmt.Errorf("unable to decode answerCallbackQuery#bb462e76: field cache_time: %w", err) } a.CacheTime = value default: return b.Skip() } return nil }) } // GetCallbackQueryID returns value of CallbackQueryID field. func (a *AnswerCallbackQueryRequest) GetCallbackQueryID() (value int64) { if a == nil { return } return a.CallbackQueryID } // GetText returns value of Text field. func (a *AnswerCallbackQueryRequest) GetText() (value string) { if a == nil { return } return a.Text } // GetShowAlert returns value of ShowAlert field. func (a *AnswerCallbackQueryRequest) GetShowAlert() (value bool) { if a == nil { return } return a.ShowAlert } // GetURL returns value of URL field. func (a *AnswerCallbackQueryRequest) GetURL() (value string) { if a == nil { return } return a.URL } // GetCacheTime returns value of CacheTime field. func (a *AnswerCallbackQueryRequest) GetCacheTime() (value int32) { if a == nil { return } return a.CacheTime } // AnswerCallbackQuery invokes method answerCallbackQuery#bb462e76 returning error if any. func (c *Client) AnswerCallbackQuery(ctx context.Context, request *AnswerCallbackQueryRequest) error { var ok Ok if err := c.rpc.Invoke(ctx, request, &ok); err != nil { return err } return nil }