-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fa27487
commit 9c48430
Showing
4 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package bot | ||
|
||
import ( | ||
"EverythingSuckz/fsb/config" | ||
|
||
"github.com/celestix/gotgproto" | ||
"github.com/celestix/gotgproto/sessionMaker" | ||
"go.uber.org/zap" | ||
) | ||
|
||
type UserBotStruct struct { | ||
log *zap.Logger | ||
client *gotgproto.Client | ||
} | ||
|
||
var UserBot *UserBotStruct = &UserBotStruct{} | ||
|
||
func StartUserBot(l *zap.Logger) { | ||
log := l.Named("USERBOT") | ||
if config.ValueOf.UserSession == "" { | ||
log.Warn("User session is empty") | ||
return | ||
} | ||
log.Sugar().Infoln("Starting userbot") | ||
client, err := gotgproto.NewClient( | ||
int(config.ValueOf.ApiID), | ||
config.ValueOf.ApiHash, | ||
gotgproto.ClientType{ | ||
Phone: "", | ||
}, | ||
&gotgproto.ClientOpts{ | ||
Session: sessionMaker.PyrogramSession(config.ValueOf.UserSession), | ||
DisableCopyright: true, | ||
}, | ||
) | ||
if err != nil { | ||
log.Error("Failed to start userbot", zap.Error(err)) | ||
return | ||
} | ||
UserBot.log = log | ||
UserBot.client = client | ||
log.Info("Userbot started", zap.String("username", client.Self.Username), zap.String("FirstName", client.Self.FirstName), zap.String("LastName", client.Self.LastName)) | ||
|
||
} |