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

Function StartUserBot

internal/bot/userbot.go:20–47  ·  view source on GitHub ↗
(l *zap.Logger)

Source from the content-addressed store, hash-verified

18var UserBot *UserBotStruct = &UserBotStruct{}
19
20func StartUserBot(l *zap.Logger) {
21 log := l.Named("USERBOT")
22 if config.ValueOf.UserSession == "" {
23 log.Warn("User session is empty")
24 return
25 }
26 log.Sugar().Infoln("Starting userbot")
27 client, err := gotgproto.NewClient(
28 int(config.ValueOf.ApiID),
29 config.ValueOf.ApiHash,
30 gotgproto.ClientTypePhone(""),
31 &gotgproto.ClientOpts{
32 Session: sessionMaker.PyrogramSession(config.ValueOf.UserSession),
33 DisableCopyright: true,
34 },
35 )
36 if err != nil {
37 log.Error("Failed to start userbot", zap.Error(err))
38 return
39 }
40 UserBot.log = log
41 UserBot.client = client
42 log.Info("Userbot started", zap.String("username", client.Self.Username), zap.String("FirstName", client.Self.FirstName), zap.String("LastName", client.Self.LastName))
43 if err := UserBot.AddBotsAsAdmins(); err != nil {
44 log.Error("Failed to add bots as admins", zap.Error(err))
45 return
46 }
47}
48
49func (u *UserBotStruct) AddBotsAsAdmins() error {
50 u.log.Info("Preparing to add bots as admins")

Callers 1

runAppFunction · 0.92

Calls 2

StringMethod · 0.80
AddBotsAsAdminsMethod · 0.80

Tested by

no test coverage detected