mirror of
https://github.com/tgdrive/teldrive.git
synced 2025-01-08 08:10:05 +08:00
use official web client config
This commit is contained in:
parent
fd9a8903e1
commit
3008e71275
3 changed files with 42 additions and 20 deletions
21
README.md
21
README.md
|
@ -86,18 +86,33 @@ HTTPS=false
|
|||
COOKIE_SAME_SITE=true
|
||||
JWT_SECRET=abc
|
||||
DATABASE_URL=abc
|
||||
MULTI_CLIENT=true # true or false here
|
||||
TG_CLIENT_DEVICE_MODEL="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36 Edg/115.0.1901.203" # Any valid browser user agent here
|
||||
TG_CLIENT_SYSTEM_VERSION=Win32
|
||||
TG_CLIENT_APP_VERSION=2.1.9 K
|
||||
TG_CLIENT_LANG_CODE=en
|
||||
TG_CLIENT_SYSTEM_LANG_CODE=en
|
||||
TG_CLIENT_LANG_PACK=webk
|
||||
MULTI_CLIENT=false
|
||||
MULTI_TOKEN1=55838383:yourfirstmulticlientbottokenhere
|
||||
MULTI_TOKEN2=55838383:yoursecondmulticlientbottokenhere
|
||||
MULTI_TOKEN3=55838383:yourthirdmulticlientbottokenhere
|
||||
```
|
||||
According to [Telegram TOS](https://core.telegram.org/api/obtaining_api_id#using-the-api-id): *all accounts that sign up or log in using unofficial Telegram API clients are automatically put under observation to avoid violations of the Terms of Service.So you can use APP_ID and APP_HASH from official K Telegram webclient from [here](https://github.com/morethanwords/tweb/blob/464bc4e76ff6417c7d996cca50c430d89d5d8175/src/config/app.ts#L36)*
|
||||
|
||||
**Use strong JWT secret instead of pure guessable string.You can use openssl to generate it.**
|
||||
|
||||
```bash
|
||||
$ openssl rand -base64 32
|
||||
```
|
||||
|
||||
|
||||
**Multi Client Mode is recommended way to avoid flood errors and to enable max download speed if you are using downloaders like IDM and aria2c which use multiple connections to download files.**
|
||||
### Mandatory Vars
|
||||
Before running the bot, you will need to set up the following mandatory variables:
|
||||
|
||||
- `APP_ID` : This is the APP ID for your Telegram account, which can be obtained from my.telegram.org.
|
||||
- `APP_ID` : Use official ones as mentioned above.
|
||||
|
||||
- `APP_HASH` : This is the APP hash for your Telegram account, which can also be obtained from my.telegram.org.
|
||||
- `APP_HASH` : Use official ones as mentioned above.
|
||||
|
||||
- `JWT_SECRET` : Used for signing jwt tokens
|
||||
|
||||
|
|
|
@ -7,14 +7,20 @@ import (
|
|||
type MultiToken string
|
||||
|
||||
type Config struct {
|
||||
AppId int `envconfig:"APP_ID" required:"true"`
|
||||
AppHash string `envconfig:"APP_HASH" required:"true"`
|
||||
ChannelID int64 `envconfig:"CHANNEL_ID" required:"true"`
|
||||
JwtSecret string `envconfig:"JWT_SECRET" required:"true"`
|
||||
MultiClient bool `envconfig:"MULTI_CLIENT" default:"false"`
|
||||
Https bool `envconfig:"HTTPS" default:"false"`
|
||||
CookieSameSite bool `envconfig:"COOKIE_SAME_SITE" default:"true"`
|
||||
DatabaseUrl string `envconfig:"DATABASE_URL" required:"true"`
|
||||
AppId int `envconfig:"APP_ID" required:"true"`
|
||||
AppHash string `envconfig:"APP_HASH" required:"true"`
|
||||
ChannelID int64 `envconfig:"CHANNEL_ID" required:"true"`
|
||||
JwtSecret string `envconfig:"JWT_SECRET" required:"true"`
|
||||
MultiClient bool `envconfig:"MULTI_CLIENT" default:"false"`
|
||||
Https bool `envconfig:"HTTPS" default:"false"`
|
||||
CookieSameSite bool `envconfig:"COOKIE_SAME_SITE" default:"true"`
|
||||
DatabaseUrl string `envconfig:"DATABASE_URL" required:"true"`
|
||||
TgClientDeviceModel string `envconfig:"TG_CLIENT_DEVICE_MODEL" required:"true"`
|
||||
TgClientSystemVersion string `envconfig:"TG_CLIENT_SYSTEM_VERSION" default:"Win32"`
|
||||
TgClientAppVersion string `envconfig:"TG_CLIENT_APP_VERSION" default:"2.1.9 K"`
|
||||
TgClientLangCode string `envconfig:"TG_CLIENT_LANG_CODE" default:"en"`
|
||||
TgClientSystemLangCode string `envconfig:"TG_CLIENT_SYSTEM_LANG_CODE" default:"en"`
|
||||
TgClientLangPack string `envconfig:"TG_CLIENT_LANG_PACK" default:"webk"`
|
||||
}
|
||||
|
||||
var config Config
|
||||
|
|
|
@ -27,13 +27,14 @@ type Client struct {
|
|||
var clients map[int]*Client
|
||||
|
||||
func getDeviceConfig() telegram.DeviceConfig {
|
||||
appConfig := GetConfig()
|
||||
config := telegram.DeviceConfig{
|
||||
DeviceModel: "Desktop",
|
||||
SystemVersion: "Windows 11",
|
||||
AppVersion: "4.9.1 x64",
|
||||
SystemLangCode: "en-US",
|
||||
LangPack: "tdesktop",
|
||||
LangCode: "en",
|
||||
DeviceModel: appConfig.TgClientDeviceModel,
|
||||
SystemVersion: appConfig.TgClientSystemVersion,
|
||||
AppVersion: appConfig.TgClientAppVersion,
|
||||
SystemLangCode: appConfig.TgClientSystemLangCode,
|
||||
LangPack: appConfig.TgClientLangPack,
|
||||
LangCode: appConfig.TgClientLangCode,
|
||||
}
|
||||
return config
|
||||
}
|
||||
|
@ -44,9 +45,9 @@ func getBotClient(appID int, appHash, clientName, sessionDir string) *telegram.C
|
|||
}
|
||||
options := telegram.Options{
|
||||
SessionStorage: sessionStorage,
|
||||
// Middlewares: []telegram.Middleware{
|
||||
// ratelimit.New(rate.Every(time.Millisecond*100), 5),
|
||||
// },
|
||||
Middlewares: []telegram.Middleware{
|
||||
ratelimit.New(rate.Every(time.Millisecond*100), 5),
|
||||
},
|
||||
Device: getDeviceConfig(),
|
||||
NoUpdates: true,
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue