// 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{} ) // ChatPermissions represents TL type `chatPermissions#f8f25a79`. type ChatPermissions struct { // True, if the user can send text messages, contacts, giveaways, giveaway winners, // invoices, locations, and venues CanSendBasicMessages bool // True, if the user can send music files CanSendAudios bool // True, if the user can send documents CanSendDocuments bool // True, if the user can send photos CanSendPhotos bool // True, if the user can send videos CanSendVideos bool // True, if the user can send video notes CanSendVideoNotes bool // True, if the user can send voice notes CanSendVoiceNotes bool // True, if the user can send polls CanSendPolls bool // True, if the user can send animations, games, stickers, and dice and use inline bots CanSendOtherMessages bool // True, if the user may add a link preview to their messages CanAddLinkPreviews bool // True, if the user can change the chat title, photo, and other settings CanChangeInfo bool // True, if the user can invite new users to the chat CanInviteUsers bool // True, if the user can pin messages CanPinMessages bool // True, if the user can create topics CanCreateTopics bool } // ChatPermissionsTypeID is TL type id of ChatPermissions. const ChatPermissionsTypeID = 0xf8f25a79 // Ensuring interfaces in compile-time for ChatPermissions. var ( _ bin.Encoder = &ChatPermissions{} _ bin.Decoder = &ChatPermissions{} _ bin.BareEncoder = &ChatPermissions{} _ bin.BareDecoder = &ChatPermissions{} ) func (c *ChatPermissions) Zero() bool { if c == nil { return true } if !(c.CanSendBasicMessages == false) { return false } if !(c.CanSendAudios == false) { return false } if !(c.CanSendDocuments == false) { return false } if !(c.CanSendPhotos == false) { return false } if !(c.CanSendVideos == false) { return false } if !(c.CanSendVideoNotes == false) { return false } if !(c.CanSendVoiceNotes == false) { return false } if !(c.CanSendPolls == false) { return false } if !(c.CanSendOtherMessages == false) { return false } if !(c.CanAddLinkPreviews == false) { return false } if !(c.CanChangeInfo == false) { return false } if !(c.CanInviteUsers == false) { return false } if !(c.CanPinMessages == false) { return false } if !(c.CanCreateTopics == false) { return false } return true } // String implements fmt.Stringer. func (c *ChatPermissions) String() string { if c == nil { return "ChatPermissions(nil)" } type Alias ChatPermissions return fmt.Sprintf("ChatPermissions%+v", Alias(*c)) } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*ChatPermissions) TypeID() uint32 { return ChatPermissionsTypeID } // TypeName returns name of type in TL schema. func (*ChatPermissions) TypeName() string { return "chatPermissions" } // TypeInfo returns info about TL type. func (c *ChatPermissions) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "chatPermissions", ID: ChatPermissionsTypeID, } if c == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{ { Name: "CanSendBasicMessages", SchemaName: "can_send_basic_messages", }, { Name: "CanSendAudios", SchemaName: "can_send_audios", }, { Name: "CanSendDocuments", SchemaName: "can_send_documents", }, { Name: "CanSendPhotos", SchemaName: "can_send_photos", }, { Name: "CanSendVideos", SchemaName: "can_send_videos", }, { Name: "CanSendVideoNotes", SchemaName: "can_send_video_notes", }, { Name: "CanSendVoiceNotes", SchemaName: "can_send_voice_notes", }, { Name: "CanSendPolls", SchemaName: "can_send_polls", }, { Name: "CanSendOtherMessages", SchemaName: "can_send_other_messages", }, { Name: "CanAddLinkPreviews", SchemaName: "can_add_link_previews", }, { Name: "CanChangeInfo", SchemaName: "can_change_info", }, { Name: "CanInviteUsers", SchemaName: "can_invite_users", }, { Name: "CanPinMessages", SchemaName: "can_pin_messages", }, { Name: "CanCreateTopics", SchemaName: "can_create_topics", }, } return typ } // Encode implements bin.Encoder. func (c *ChatPermissions) Encode(b *bin.Buffer) error { if c == nil { return fmt.Errorf("can't encode chatPermissions#f8f25a79 as nil") } b.PutID(ChatPermissionsTypeID) return c.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (c *ChatPermissions) EncodeBare(b *bin.Buffer) error { if c == nil { return fmt.Errorf("can't encode chatPermissions#f8f25a79 as nil") } b.PutBool(c.CanSendBasicMessages) b.PutBool(c.CanSendAudios) b.PutBool(c.CanSendDocuments) b.PutBool(c.CanSendPhotos) b.PutBool(c.CanSendVideos) b.PutBool(c.CanSendVideoNotes) b.PutBool(c.CanSendVoiceNotes) b.PutBool(c.CanSendPolls) b.PutBool(c.CanSendOtherMessages) b.PutBool(c.CanAddLinkPreviews) b.PutBool(c.CanChangeInfo) b.PutBool(c.CanInviteUsers) b.PutBool(c.CanPinMessages) b.PutBool(c.CanCreateTopics) return nil } // Decode implements bin.Decoder. func (c *ChatPermissions) Decode(b *bin.Buffer) error { if c == nil { return fmt.Errorf("can't decode chatPermissions#f8f25a79 to nil") } if err := b.ConsumeID(ChatPermissionsTypeID); err != nil { return fmt.Errorf("unable to decode chatPermissions#f8f25a79: %w", err) } return c.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (c *ChatPermissions) DecodeBare(b *bin.Buffer) error { if c == nil { return fmt.Errorf("can't decode chatPermissions#f8f25a79 to nil") } { value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode chatPermissions#f8f25a79: field can_send_basic_messages: %w", err) } c.CanSendBasicMessages = value } { value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode chatPermissions#f8f25a79: field can_send_audios: %w", err) } c.CanSendAudios = value } { value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode chatPermissions#f8f25a79: field can_send_documents: %w", err) } c.CanSendDocuments = value } { value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode chatPermissions#f8f25a79: field can_send_photos: %w", err) } c.CanSendPhotos = value } { value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode chatPermissions#f8f25a79: field can_send_videos: %w", err) } c.CanSendVideos = value } { value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode chatPermissions#f8f25a79: field can_send_video_notes: %w", err) } c.CanSendVideoNotes = value } { value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode chatPermissions#f8f25a79: field can_send_voice_notes: %w", err) } c.CanSendVoiceNotes = value } { value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode chatPermissions#f8f25a79: field can_send_polls: %w", err) } c.CanSendPolls = value } { value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode chatPermissions#f8f25a79: field can_send_other_messages: %w", err) } c.CanSendOtherMessages = value } { value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode chatPermissions#f8f25a79: field can_add_link_previews: %w", err) } c.CanAddLinkPreviews = value } { value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode chatPermissions#f8f25a79: field can_change_info: %w", err) } c.CanChangeInfo = value } { value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode chatPermissions#f8f25a79: field can_invite_users: %w", err) } c.CanInviteUsers = value } { value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode chatPermissions#f8f25a79: field can_pin_messages: %w", err) } c.CanPinMessages = value } { value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode chatPermissions#f8f25a79: field can_create_topics: %w", err) } c.CanCreateTopics = value } return nil } // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (c *ChatPermissions) EncodeTDLibJSON(b tdjson.Encoder) error { if c == nil { return fmt.Errorf("can't encode chatPermissions#f8f25a79 as nil") } b.ObjStart() b.PutID("chatPermissions") b.Comma() b.FieldStart("can_send_basic_messages") b.PutBool(c.CanSendBasicMessages) b.Comma() b.FieldStart("can_send_audios") b.PutBool(c.CanSendAudios) b.Comma() b.FieldStart("can_send_documents") b.PutBool(c.CanSendDocuments) b.Comma() b.FieldStart("can_send_photos") b.PutBool(c.CanSendPhotos) b.Comma() b.FieldStart("can_send_videos") b.PutBool(c.CanSendVideos) b.Comma() b.FieldStart("can_send_video_notes") b.PutBool(c.CanSendVideoNotes) b.Comma() b.FieldStart("can_send_voice_notes") b.PutBool(c.CanSendVoiceNotes) b.Comma() b.FieldStart("can_send_polls") b.PutBool(c.CanSendPolls) b.Comma() b.FieldStart("can_send_other_messages") b.PutBool(c.CanSendOtherMessages) b.Comma() b.FieldStart("can_add_link_previews") b.PutBool(c.CanAddLinkPreviews) b.Comma() b.FieldStart("can_change_info") b.PutBool(c.CanChangeInfo) b.Comma() b.FieldStart("can_invite_users") b.PutBool(c.CanInviteUsers) b.Comma() b.FieldStart("can_pin_messages") b.PutBool(c.CanPinMessages) b.Comma() b.FieldStart("can_create_topics") b.PutBool(c.CanCreateTopics) b.Comma() b.StripComma() b.ObjEnd() return nil } // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (c *ChatPermissions) DecodeTDLibJSON(b tdjson.Decoder) error { if c == nil { return fmt.Errorf("can't decode chatPermissions#f8f25a79 to nil") } return b.Obj(func(b tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := b.ConsumeID("chatPermissions"); err != nil { return fmt.Errorf("unable to decode chatPermissions#f8f25a79: %w", err) } case "can_send_basic_messages": value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode chatPermissions#f8f25a79: field can_send_basic_messages: %w", err) } c.CanSendBasicMessages = value case "can_send_audios": value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode chatPermissions#f8f25a79: field can_send_audios: %w", err) } c.CanSendAudios = value case "can_send_documents": value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode chatPermissions#f8f25a79: field can_send_documents: %w", err) } c.CanSendDocuments = value case "can_send_photos": value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode chatPermissions#f8f25a79: field can_send_photos: %w", err) } c.CanSendPhotos = value case "can_send_videos": value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode chatPermissions#f8f25a79: field can_send_videos: %w", err) } c.CanSendVideos = value case "can_send_video_notes": value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode chatPermissions#f8f25a79: field can_send_video_notes: %w", err) } c.CanSendVideoNotes = value case "can_send_voice_notes": value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode chatPermissions#f8f25a79: field can_send_voice_notes: %w", err) } c.CanSendVoiceNotes = value case "can_send_polls": value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode chatPermissions#f8f25a79: field can_send_polls: %w", err) } c.CanSendPolls = value case "can_send_other_messages": value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode chatPermissions#f8f25a79: field can_send_other_messages: %w", err) } c.CanSendOtherMessages = value case "can_add_link_previews": value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode chatPermissions#f8f25a79: field can_add_link_previews: %w", err) } c.CanAddLinkPreviews = value case "can_change_info": value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode chatPermissions#f8f25a79: field can_change_info: %w", err) } c.CanChangeInfo = value case "can_invite_users": value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode chatPermissions#f8f25a79: field can_invite_users: %w", err) } c.CanInviteUsers = value case "can_pin_messages": value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode chatPermissions#f8f25a79: field can_pin_messages: %w", err) } c.CanPinMessages = value case "can_create_topics": value, err := b.Bool() if err != nil { return fmt.Errorf("unable to decode chatPermissions#f8f25a79: field can_create_topics: %w", err) } c.CanCreateTopics = value default: return b.Skip() } return nil }) } // GetCanSendBasicMessages returns value of CanSendBasicMessages field. func (c *ChatPermissions) GetCanSendBasicMessages() (value bool) { if c == nil { return } return c.CanSendBasicMessages } // GetCanSendAudios returns value of CanSendAudios field. func (c *ChatPermissions) GetCanSendAudios() (value bool) { if c == nil { return } return c.CanSendAudios } // GetCanSendDocuments returns value of CanSendDocuments field. func (c *ChatPermissions) GetCanSendDocuments() (value bool) { if c == nil { return } return c.CanSendDocuments } // GetCanSendPhotos returns value of CanSendPhotos field. func (c *ChatPermissions) GetCanSendPhotos() (value bool) { if c == nil { return } return c.CanSendPhotos } // GetCanSendVideos returns value of CanSendVideos field. func (c *ChatPermissions) GetCanSendVideos() (value bool) { if c == nil { return } return c.CanSendVideos } // GetCanSendVideoNotes returns value of CanSendVideoNotes field. func (c *ChatPermissions) GetCanSendVideoNotes() (value bool) { if c == nil { return } return c.CanSendVideoNotes } // GetCanSendVoiceNotes returns value of CanSendVoiceNotes field. func (c *ChatPermissions) GetCanSendVoiceNotes() (value bool) { if c == nil { return } return c.CanSendVoiceNotes } // GetCanSendPolls returns value of CanSendPolls field. func (c *ChatPermissions) GetCanSendPolls() (value bool) { if c == nil { return } return c.CanSendPolls } // GetCanSendOtherMessages returns value of CanSendOtherMessages field. func (c *ChatPermissions) GetCanSendOtherMessages() (value bool) { if c == nil { return } return c.CanSendOtherMessages } // GetCanAddLinkPreviews returns value of CanAddLinkPreviews field. func (c *ChatPermissions) GetCanAddLinkPreviews() (value bool) { if c == nil { return } return c.CanAddLinkPreviews } // GetCanChangeInfo returns value of CanChangeInfo field. func (c *ChatPermissions) GetCanChangeInfo() (value bool) { if c == nil { return } return c.CanChangeInfo } // GetCanInviteUsers returns value of CanInviteUsers field. func (c *ChatPermissions) GetCanInviteUsers() (value bool) { if c == nil { return } return c.CanInviteUsers } // GetCanPinMessages returns value of CanPinMessages field. func (c *ChatPermissions) GetCanPinMessages() (value bool) { if c == nil { return } return c.CanPinMessages } // GetCanCreateTopics returns value of CanCreateTopics field. func (c *ChatPermissions) GetCanCreateTopics() (value bool) { if c == nil { return } return c.CanCreateTopics }