Skip to content

Commit

Permalink
refactor(prj): separate telegram client device config to core module
Browse files Browse the repository at this point in the history
  • Loading branch information
iyear committed Jun 12, 2024
1 parent 187ae7a commit 6bb545a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
12 changes: 12 additions & 0 deletions core/util/tutil/device.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package tutil

import "github.com/gotd/td/telegram"

var Device = telegram.DeviceConfig{
DeviceModel: "Desktop",
SystemVersion: "Windows 10",
AppVersion: "4.2.4 x64",
LangCode: "en",
SystemLangCode: "en-US",
LangPack: "tdesktop",
}
11 changes: 0 additions & 11 deletions pkg/tclient/app.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package tclient

import "github.com/gotd/td/telegram"

const (
AppBuiltin = "builtin"
AppDesktop = "desktop"
Expand All @@ -17,12 +15,3 @@ var Apps = map[string]struct {
// https://opentele.readthedocs.io/en/latest/documentation/authorization/api/#class-telegramdesktop
AppDesktop: {AppID: 2040, AppHash: "b18441a1ff607e10a989891a5462e627"},
}

var Device = telegram.DeviceConfig{
DeviceModel: "Desktop",
SystemVersion: "Windows 10",
AppVersion: "4.2.4 x64",
LangCode: "en",
SystemLangCode: "en-US",
LangPack: "tdesktop",
}
3 changes: 2 additions & 1 deletion pkg/tclient/tclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/iyear/tdl/core/middlewares/recovery"
"github.com/iyear/tdl/core/middlewares/retry"
"github.com/iyear/tdl/core/util/netutil"
"github.com/iyear/tdl/core/util/tutil"
"github.com/iyear/tdl/pkg/clock"
"github.com/iyear/tdl/pkg/key"
"github.com/iyear/tdl/pkg/kv"
Expand Down Expand Up @@ -72,7 +73,7 @@ func New(ctx context.Context, o Options, login bool, middlewares ...telegram.Mid
return newBackoff(o.ReconnectTimeout)
},
UpdateHandler: o.UpdateHandler,
Device: Device,
Device: tutil.Device,
SessionStorage: storage.NewSession(o.KV, login),
RetryInterval: 5 * time.Second,
MaxRetries: -1, // infinite retries
Expand Down

0 comments on commit 6bb545a

Please sign in to comment.