This commit is contained in:
divyam234 2023-09-15 02:40:32 +05:30
parent b3b4354e0a
commit fd29819b0d
2 changed files with 3 additions and 1 deletions

View file

@ -20,6 +20,8 @@ type Config struct {
AllowedUsers []string `envconfig:"ALLOWED_USERS"` AllowedUsers []string `envconfig:"ALLOWED_USERS"`
DatabaseUrl string `envconfig:"DATABASE_URL" required:"true"` DatabaseUrl string `envconfig:"DATABASE_URL" required:"true"`
RateLimit bool `envconfig:"RATE_LIMIT" default:"true"` RateLimit bool `envconfig:"RATE_LIMIT" default:"true"`
RateBurst int `envconfig:"RATE_BURST" default:"5"`
Rate int `envconfig:"RATE" default:"100"`
TgClientDeviceModel string `envconfig:"TG_CLIENT_DEVICE_MODEL" required:"true"` TgClientDeviceModel string `envconfig:"TG_CLIENT_DEVICE_MODEL" required:"true"`
TgClientSystemVersion string `envconfig:"TG_CLIENT_SYSTEM_VERSION" default:"Win32"` TgClientSystemVersion string `envconfig:"TG_CLIENT_SYSTEM_VERSION" default:"Win32"`
TgClientAppVersion string `envconfig:"TG_CLIENT_APP_VERSION" default:"2.1.9 K"` TgClientAppVersion string `envconfig:"TG_CLIENT_APP_VERSION" default:"2.1.9 K"`

View file

@ -108,7 +108,7 @@ func GetBotClient(clientName string) *telegram.Client {
middlewares := []telegram.Middleware{floodwait.NewSimpleWaiter()} middlewares := []telegram.Middleware{floodwait.NewSimpleWaiter()}
if config.RateLimit { if config.RateLimit {
middlewares = append(middlewares, ratelimit.New(rate.Every(time.Millisecond*100), 5)) middlewares = append(middlewares, ratelimit.New(rate.Every(time.Millisecond*time.Duration(config.Rate)), config.RateBurst))
} }
options := telegram.Options{ options := telegram.Options{