MCPcopy
hub / github.com/EverythingSuckz/TG-FileStreamBot / startWorker

Function startWorker

internal/bot/workers.go:148–171  ·  view source on GitHub ↗
(l *zap.Logger, botToken string, index int)

Source from the content-addressed store, hash-verified

146}
147
148func 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}

Callers 1

AddMethod · 0.85

Calls 1

GetFloodMiddlewareFunction · 0.85

Tested by

no test coverage detected