Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Telegram schema to the latest layer #1372

Merged
merged 2 commits into from Apr 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 11 additions & 5 deletions _schema/tdesktop.tl
@@ -1,8 +1,8 @@
// Code generated by ./cmd/dltl, DO NOT EDIT.
//
// Source: https://raw.githubusercontent.com/telegramdesktop/tdesktop/dev/Telegram/SourceFiles/mtproto/scheme/api.tl
// Layer: 178
// SHA256: 7a4c0f192ad4dd77a24614884fd716bcf680b683c45bd2b921af13369ebcf68a
// Layer: 179
// SHA256: 68c4230a10c3ec143824dc09bd82601bd78975d208c4743e7ce54c58bc73cab4

boolFalse#bc799737 = Bool;

Expand Down Expand Up @@ -1268,6 +1268,10 @@ auth.sentCodeTypeFragmentSms#d9565c39 url:string length:int = auth.SentCodeType;

auth.sentCodeTypeFirebaseSms#e57b1432 flags:# nonce:flags.0?bytes receipt:flags.1?string push_timeout:flags.1?int length:int = auth.SentCodeType;

auth.sentCodeTypeSmsWord#a416ac81 flags:# beginning:flags.0?string = auth.SentCodeType;

auth.sentCodeTypeSmsPhrase#b37794af flags:# beginning:flags.0?string = auth.SentCodeType;

messages.botCallbackAnswer#36585ea4 flags:# alert:flags.1?true has_url:flags.3?true native_ui:flags.4?true message:flags.0?string url:flags.2?string cache_time:int = messages.BotCallbackAnswer;

messages.messageEditData#26b5dde6 flags:# caption:flags.0?true = messages.MessageEditData;
Expand Down Expand Up @@ -1836,9 +1840,9 @@ help.userInfoEmpty#f3ae2eed = help.UserInfo;

help.userInfo#1eb3758 message:string entities:Vector<MessageEntity> author:string date:int = help.UserInfo;

pollAnswer#6ca9c2e9 text:string option:bytes = PollAnswer;
pollAnswer#ff16e2ca text:TextWithEntities option:bytes = PollAnswer;

poll#86e18161 id:long flags:# closed:flags.0?true public_voters:flags.1?true multiple_choice:flags.2?true quiz:flags.3?true question:string answers:Vector<PollAnswer> close_period:flags.4?int close_date:flags.5?int = Poll;
poll#58747131 id:long flags:# closed:flags.0?true public_voters:flags.1?true multiple_choice:flags.2?true quiz:flags.3?true question:TextWithEntities answers:Vector<PollAnswer> close_period:flags.4?int close_date:flags.5?int = Poll;

pollAnswerVoters#3b6ddad2 flags:# chosen:flags.0?true correct:flags.1?true option:bytes voters:int = PollAnswerVoters;

Expand Down Expand Up @@ -2645,6 +2649,8 @@ auth.requestFirebaseSms#89464b50 flags:# phone_number:string phone_code_hash:str

auth.resetLoginEmail#7e960193 phone_number:string phone_code_hash:string = auth.SentCode;

auth.reportMissingCode#cb9deff6 phone_number:string phone_code_hash:string mnc:string = Bool;

account.registerDevice#ec86017a flags:# no_muted:flags.0?true token_type:int token:string app_sandbox:Bool secret:bytes other_uids:Vector<long> = Bool;

account.unregisterDevice#6a0d3206 token_type:int token:string other_uids:Vector<long> = Bool;
Expand Down Expand Up @@ -3833,4 +3839,4 @@ smsjobs.finishJob#4f1ebf24 flags:# job_id:string error:flags.0?string = Bool;

fragment.getCollectibleInfo#be1e85ba collectible:InputCollectible = fragment.CollectibleInfo;

// LAYER 178
// LAYER 179
16 changes: 11 additions & 5 deletions _schema/telegram.tl
Expand Up @@ -2,8 +2,8 @@
//
// Source: https://raw.githubusercontent.com/telegramdesktop/tdesktop/dev/Telegram/SourceFiles/mtproto/scheme/api.tl
// Merge: _schema/legacy.tl
// Layer: 178
// SHA256: 7a4c0f192ad4dd77a24614884fd716bcf680b683c45bd2b921af13369ebcf68a
// Layer: 179
// SHA256: 68c4230a10c3ec143824dc09bd82601bd78975d208c4743e7ce54c58bc73cab4

boolFalse#bc799737 = Bool;

Expand Down Expand Up @@ -1269,6 +1269,10 @@ auth.sentCodeTypeFragmentSms#d9565c39 url:string length:int = auth.SentCodeType;

auth.sentCodeTypeFirebaseSms#e57b1432 flags:# nonce:flags.0?bytes receipt:flags.1?string push_timeout:flags.1?int length:int = auth.SentCodeType;

auth.sentCodeTypeSmsWord#a416ac81 flags:# beginning:flags.0?string = auth.SentCodeType;

auth.sentCodeTypeSmsPhrase#b37794af flags:# beginning:flags.0?string = auth.SentCodeType;

messages.botCallbackAnswer#36585ea4 flags:# alert:flags.1?true has_url:flags.3?true native_ui:flags.4?true message:flags.0?string url:flags.2?string cache_time:int = messages.BotCallbackAnswer;

messages.messageEditData#26b5dde6 flags:# caption:flags.0?true = messages.MessageEditData;
Expand Down Expand Up @@ -1837,9 +1841,9 @@ help.userInfoEmpty#f3ae2eed = help.UserInfo;

help.userInfo#1eb3758 message:string entities:Vector<MessageEntity> author:string date:int = help.UserInfo;

pollAnswer#6ca9c2e9 text:string option:bytes = PollAnswer;
pollAnswer#ff16e2ca text:TextWithEntities option:bytes = PollAnswer;

poll#86e18161 id:long flags:# closed:flags.0?true public_voters:flags.1?true multiple_choice:flags.2?true quiz:flags.3?true question:string answers:Vector<PollAnswer> close_period:flags.4?int close_date:flags.5?int = Poll;
poll#58747131 id:long flags:# closed:flags.0?true public_voters:flags.1?true multiple_choice:flags.2?true quiz:flags.3?true question:TextWithEntities answers:Vector<PollAnswer> close_period:flags.4?int close_date:flags.5?int = Poll;

pollAnswerVoters#3b6ddad2 flags:# chosen:flags.0?true correct:flags.1?true option:bytes voters:int = PollAnswerVoters;

Expand Down Expand Up @@ -2646,6 +2650,8 @@ auth.requestFirebaseSms#89464b50 flags:# phone_number:string phone_code_hash:str

auth.resetLoginEmail#7e960193 phone_number:string phone_code_hash:string = auth.SentCode;

auth.reportMissingCode#cb9deff6 phone_number:string phone_code_hash:string mnc:string = Bool;

account.registerDevice#ec86017a flags:# no_muted:flags.0?true token_type:int token:string app_sandbox:Bool secret:bytes other_uids:Vector<long> = Bool;

account.unregisterDevice#6a0d3206 token_type:int token:string other_uids:Vector<long> = Bool;
Expand Down Expand Up @@ -3866,4 +3872,4 @@ test.useError#ee75af01 = Error;

test.useConfigSimple#f9b7b23d = help.ConfigSimple;

// LAYER 178
// LAYER 179
17 changes: 12 additions & 5 deletions telegram/message/poll.go
Expand Up @@ -28,24 +28,24 @@ func RawPollAnswer(poll tg.PollAnswer) PollAnswerOption {
}

// PollAnswer creates new plain poll answer option.
func PollAnswer(text string) PollAnswerOption {
func PollAnswer(text string, entities ...tg.MessageEntityClass) PollAnswerOption {
return func(p *pollAnswerBuilder) {
i := len(p.input.Poll.Answers)
p.input.Poll.Answers = append(p.input.Poll.Answers, tg.PollAnswer{
Text: text,
Text: tg.TextWithEntities{Text: text, Entities: entities},
Option: []byte(strconv.Itoa(i)),
})
}
}

// CorrectPollAnswer creates new correct poll answer option.
func CorrectPollAnswer(text string) PollAnswerOption {
func CorrectPollAnswer(text string, entities ...tg.MessageEntityClass) PollAnswerOption {
return func(p *pollAnswerBuilder) {
p.input.Poll.Quiz = true
i := len(p.input.Poll.Answers)
option := []byte(strconv.Itoa(i))
p.input.Poll.Answers = append(p.input.Poll.Answers, tg.PollAnswer{
Text: text,
Text: tg.TextWithEntities{Text: text, Entities: entities},
Option: option,
})
p.input.CorrectAnswers = append(p.input.CorrectAnswers, option)
Expand Down Expand Up @@ -148,12 +148,19 @@ func (p *PollBuilder) apply(ctx context.Context, b *multiMediaBuilder) error {
return Media(&p.input).apply(ctx, b)
}

func (p *PollBuilder) QuestionEntities(entities []tg.MessageEntityClass) *PollBuilder {
p.input.Poll.Question.Entities = entities
return p
}

// Poll adds poll attachment.
//
// To set poll question entities, use [QuestionEntities](#PollBuilder.QuestionEntities).
func Poll(question string, a, b PollAnswerOption, answers ...PollAnswerOption) *PollBuilder {
return &PollBuilder{
input: tg.InputMediaPoll{
Poll: tg.Poll{
Question: question,
Question: tg.TextWithEntities{Text: question},
},
},
answers: append([]PollAnswerOption{a, b}, answers...),
Expand Down
8 changes: 6 additions & 2 deletions telegram/message/poll_test.go
Expand Up @@ -43,11 +43,15 @@ func TestPoll(t *testing.T) {
CorrectPollAnswer("A?"),
PollAnswer("Che?"),
PollAnswer("Kuda?"),
).PublicVoters(true).
).
PublicVoters(true).
StyledExplanation(
styling.Plain("See"),
styling.TextURL("https://youtu.be/PYzX7SDKhd0.", "https://youtu.be/PYzX7SDKhd0"),
)
).
QuestionEntities([]tg.MessageEntityClass{
&tg.MessageEntityEmail{Offset: 0, Length: 128},
})

_, err := sender.Self().Media(ctx, poll)
require.NoError(t, err)
Expand Down
228 changes: 228 additions & 0 deletions tg/tl_auth_report_missing_code_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.