Skip to content

Commit

Permalink
Merge pull request #1142 from gotd/feat/update-tl
Browse files Browse the repository at this point in the history
feat: update to layer 160
  • Loading branch information
ernado authored Jul 21, 2023
2 parents 8f9c148 + d8990c1 commit 67360ed
Show file tree
Hide file tree
Showing 132 changed files with 19,368 additions and 2,943 deletions.
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ generate:

download_schema:
go run ./cmd/dltl -base https://raw.githubusercontent.com/tdlib/td -branch master -dir td/generate/scheme -f telegram_api.tl -o _schema/tdlib.tl
go run ./cmd/dltl -base https://raw.githubusercontent.com/telegramdesktop/tdesktop -branch dev -dir Telegram/Resources/tl -f api.tl -o _schema/tdesktop.tl
go run ./cmd/dltl -base https://raw.githubusercontent.com/telegramdesktop/tdesktop -branch dev -dir Telegram/Resources/tl -f api.tl -merge _schema/legacy.tl -o _schema/telegram.tl
go run ./cmd/dltl -base https://raw.githubusercontent.com/telegramdesktop/tdesktop -branch dev -dir Telegram/SourceFiles/mtproto/scheme -f api.tl -o _schema/tdesktop.tl
go run ./cmd/dltl -base https://raw.githubusercontent.com/telegramdesktop/tdesktop -branch dev -dir Telegram/SourceFiles/mtproto/scheme -f layer.tl -o _schema/layer.tl
go run ./cmd/dltl -base https://raw.githubusercontent.com/telegramdesktop/tdesktop -branch dev -dir Telegram/SourceFiles/mtproto/scheme -f api.tl -merge _schema/legacy.tl,_schema/layer.tl -o _schema/telegram.tl
.PHONY: download_schema

download_public_keys:
Expand Down
7 changes: 7 additions & 0 deletions _schema/layer.tl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Code generated by ./cmd/dltl, DO NOT EDIT.
//
// Source: https://raw.githubusercontent.com/telegramdesktop/tdesktop/dev/Telegram/SourceFiles/mtproto/scheme/layer.tl
// Layer: 160
// SHA256: 99aaa4767ac10a5103b97840075a525d3eb11cc6a940988d3ee9fe099b61ee20

// LAYER 160
160 changes: 127 additions & 33 deletions _schema/tdesktop.tl

Large diffs are not rendered by default.

160 changes: 128 additions & 32 deletions _schema/tdlib.tl

Large diffs are not rendered by default.

164 changes: 130 additions & 34 deletions _schema/telegram.tl

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions cmd/dltl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ Classes:

target.Classes = append(target.Classes, c)
}
if target.Layer == 0 {
target.Layer = s.Layer
}
}

func main() {
Expand Down
96 changes: 0 additions & 96 deletions cmd/gotdchats/main.go

This file was deleted.

2 changes: 1 addition & 1 deletion telegram/internal/upconv/upconv.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func convertOptional(msg *tg.Message, i tg.UpdatesClass) {
GetReplyTo() (tg.MessageReplyHeader, bool)
}); ok {
if v, ok := u.GetReplyTo(); ok {
msg.SetReplyTo(v)
msg.SetReplyTo(&v)
}
}
if u, ok := i.(interface {
Expand Down
2 changes: 1 addition & 1 deletion telegram/message/inline.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func (b *Builder) InlineResult(ctx context.Context, id string, queryID int64, hi
ClearDraft: b.clearDraft,
HideVia: hideVia,
Peer: p,
ReplyToMsgID: b.replyToMsgID,
ReplyTo: &tg.InputReplyToMessage{ReplyToMsgID: b.replyToMsgID},
QueryID: queryID,
ID: id,
ScheduleDate: b.scheduleDate,
Expand Down
4 changes: 2 additions & 2 deletions telegram/message/media.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (b *Builder) Album(ctx context.Context, media MultiMediaOption, album ...Mu
Background: b.background,
ClearDraft: b.clearDraft,
Peer: p,
ReplyToMsgID: b.replyToMsgID,
ReplyTo: &tg.InputReplyToMessage{ReplyToMsgID: b.replyToMsgID},
MultiMedia: mb,
ScheduleDate: b.scheduleDate,
})
Expand Down Expand Up @@ -112,7 +112,7 @@ func (b *Builder) Media(ctx context.Context, media MediaOption) (tg.UpdatesClass
Background: b.background,
ClearDraft: b.clearDraft,
Peer: p,
ReplyToMsgID: b.replyToMsgID,
ReplyTo: &tg.InputReplyToMessage{ReplyToMsgID: b.replyToMsgID},
Media: attachment.Media,
Message: attachment.Message,
ReplyMarkup: b.replyMarkup,
Expand Down
4 changes: 2 additions & 2 deletions telegram/message/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ func (b *RequestBuilder) ScreenshotNotify(ctx context.Context, msgID int) (tg.Up
}

upd, err := b.sender.sendScreenshotNotification(ctx, &tg.MessagesSendScreenshotNotificationRequest{
Peer: p,
ReplyToMsgID: msgID,
Peer: p,
ReplyTo: &tg.InputReplyToMessage{ReplyToMsgID: msgID},
})
if err != nil {
return nil, errors.Wrap(err, "send screenshot notify")
Expand Down
4 changes: 2 additions & 2 deletions telegram/message/request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestRequestBuilder_ScreenshotNotify(t *testing.T) {
req, ok := b.(*tg.MessagesSendScreenshotNotificationRequest)
require.True(t, ok)
require.Equal(t, &tg.InputPeerSelf{}, req.Peer)
require.Equal(t, 10, req.ReplyToMsgID)
require.Equal(t, 10, req.ReplyTo.(*tg.InputReplyToMessage).ReplyToMsgID)
}).ThenResult(&tg.Updates{})
_, err := sender.Self().ScreenshotNotify(ctx, 10)
require.NoError(t, err)
Expand All @@ -51,7 +51,7 @@ func TestRequestBuilder_ScreenshotNotify(t *testing.T) {
req, ok := b.(*tg.MessagesSendScreenshotNotificationRequest)
require.True(t, ok)
require.Equal(t, &tg.InputPeerSelf{}, req.Peer)
require.Equal(t, 10, req.ReplyToMsgID)
require.Equal(t, 10, req.ReplyTo.(*tg.InputReplyToMessage).ReplyToMsgID)
}).ThenRPCErr(testRPCError())
_, err = sender.Self().ScreenshotNotify(ctx, 10)
require.Error(t, err)
Expand Down
2 changes: 1 addition & 1 deletion telegram/message/text.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func (b *Builder) sendRequest(
ClearDraft: b.clearDraft,
Noforwards: b.noForwards,
Peer: p,
ReplyToMsgID: b.replyToMsgID,
ReplyTo: &tg.InputReplyToMessage{ReplyToMsgID: b.replyToMsgID},
Message: msg,
RandomID: 0,
ReplyMarkup: b.replyMarkup,
Expand Down
7 changes: 5 additions & 2 deletions telegram/message/video.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,15 @@ func (u *VideoDocumentBuilder) Resolution(w, h int) *VideoDocumentBuilder {

// Duration sets duration of video file.
func (u *VideoDocumentBuilder) Duration(duration time.Duration) *VideoDocumentBuilder {
return u.DurationSeconds(int(duration.Seconds()))
u.attr.Duration = duration.Seconds()
return u
}

// DurationSeconds sets duration in seconds.
//
// Deprecated: Use Duration instead. Telegram now supports fractional seconds.
func (u *VideoDocumentBuilder) DurationSeconds(duration int) *VideoDocumentBuilder {
u.attr.Duration = duration
u.attr.Duration = float64(duration)
return u
}

Expand Down
21 changes: 0 additions & 21 deletions telegram/peers/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,27 +149,6 @@ func (m *Manager) applyFullChannel(ctx context.Context, ch *tg.ChannelFull) erro
return m.cache.SaveChannelFulls(ctx, ch)
}

func (m *Manager) applyMessagesChats(
ctx context.Context,
all tg.MessagesChatsClass,
) (chats []Chat, channels []Channel, _ error) {
raw := all.GetChats()
if err := m.applyChats(ctx, raw...); err != nil {
return nil, nil, errors.Wrap(err, "apply chats")
}

for _, ch := range raw {
switch ch := ch.(type) {
case *tg.Chat:
chats = append(chats, m.Chat(ch))
case *tg.Channel:
channels = append(channels, m.Channel(ch))
}
}

return chats, channels, nil
}

func (m *Manager) updateContacts(ctx context.Context) ([]tg.UserClass, error) {
ch := m.sg.DoChan("_contacts", func() (interface{}, error) {
hash, err := m.storage.GetContactsHash(ctx)
Expand Down
31 changes: 0 additions & 31 deletions telegram/peers/get_chats.go

This file was deleted.

34 changes: 0 additions & 34 deletions telegram/peers/get_chats_test.go

This file was deleted.

2 changes: 1 addition & 1 deletion telegram/updates/conv_shorts.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func convertOptional(msg *tg.Message, i tg.UpdatesClass) {
GetReplyTo() (tg.MessageReplyHeader, bool)
}); ok {
if v, ok := u.GetReplyTo(); ok {
msg.SetReplyTo(v)
msg.SetReplyTo(&v)
}
}
if u, ok := i.(interface {
Expand Down
Loading

0 comments on commit 67360ed

Please sign in to comment.