diff --git a/commands.go b/commands.go index 7645f17..fac97ce 100644 --- a/commands.go +++ b/commands.go @@ -83,6 +83,8 @@ func fnLogin(ce *WrappedCommandEvent) { return } + ce.User.hackyLoginCommand = ce + ce.User.hackyLoginCommandPrevEvent = "" _, err := ce.User.Login(context.Background()) if err != nil { ce.User.log.Errorf("Failed to log in:", err) diff --git a/user.go b/user.go index 9daf8dc..0a2fea2 100644 --- a/user.go +++ b/user.go @@ -69,6 +69,9 @@ type User struct { spaceMembershipChecked bool DoublePuppetIntent *appservice.IntentAPI + + hackyLoginCommand *WrappedCommandEvent + hackyLoginCommandPrevEvent id.EventID } func (br *GMBridge) getUserByMXID(userID id.UserID, onlyIfExists bool) *User { @@ -524,9 +527,13 @@ func (user *User) sendMarkdownBridgeAlert(formatString string, args ...interface func (user *User) HandleEvent(event interface{}) { switch v := event.(type) { case *events.QR: - // These should be here - user.zlog.Info().Msg(v.URL) + // This shouldn't be here + if user.hackyLoginCommand != nil { + user.hackyLoginCommandPrevEvent = user.sendQR(user.hackyLoginCommand, v.URL, user.hackyLoginCommandPrevEvent) + } case *events.PairSuccessful: + user.hackyLoginCommand = nil + user.hackyLoginCommandPrevEvent = "" user.tryAutomaticDoublePuppeting() user.Phone = v.PairDeviceData.Mobile.RegistrationID user.Session.PhoneInfo = v.PairDeviceData.Mobile