(l *zap.Logger, botToken string, index int)
| 146 | } |
| 147 | |
| 148 | func startWorker(l *zap.Logger, botToken string, index int) (*gotgproto.Client, error) { |
| 149 | log := l.Named("Worker").Sugar() |
| 150 | log.Infof("Starting worker with index - %d", index) |
| 151 | var sessionType sessionMaker.SessionConstructor |
| 152 | if config.ValueOf.UseSessionFile { |
| 153 | sessionType = sessionMaker.SqlSession(sqlite.Open(fmt.Sprintf("sessions/worker-%d.session", index))) |
| 154 | } else { |
| 155 | sessionType = sessionMaker.SimpleSession() |
| 156 | } |
| 157 | client, err := gotgproto.NewClient( |
| 158 | int(config.ValueOf.ApiID), |
| 159 | config.ValueOf.ApiHash, |
| 160 | gotgproto.ClientTypeBot(botToken), |
| 161 | &gotgproto.ClientOpts{ |
| 162 | Session: sessionType, |
| 163 | DisableCopyright: true, |
| 164 | Middlewares: GetFloodMiddleware(log.Desugar()), |
| 165 | }, |
| 166 | ) |
| 167 | if err != nil { |
| 168 | return nil, err |
| 169 | } |
| 170 | return client, nil |
| 171 | } |
no test coverage detected