diff --git a/commands.go b/commands.go index 1d27b18..f61ede7 100644 --- a/commands.go +++ b/commands.go @@ -117,7 +117,7 @@ func (handler *CommandHandler) CommandMux(ce *CommandEvent) { handler.CommandLogout(ce) case "login-matrix", "sync", "list", "open", "pm", "invite", "kick", "leave", "join", "create", "share": if !ce.User.HasSession() { - ce.Reply("You are not logged in. Use the `login` command to log into WhatsApp.") + ce.Reply("You're not logged in. Use the `login` command to log into Skype.") return } @@ -435,7 +435,7 @@ func (handler *CommandHandler) CommandPing(ce *CommandEvent) { if len(ce.User.Conn.UserProfile.LastName) > 0 { username = username + ce.User.Conn.UserProfile.LastName } - ce.Reply("You are logged in as @" + username) + ce.Reply("You're logged in as @" + username) } } diff --git a/main.go b/main.go index 6cd3878..260bce3 100644 --- a/main.go +++ b/main.go @@ -29,7 +29,7 @@ var ( URL = "unknown" // This is changed when making a release Version = "0.1.1" - WAVersion = "" + SkypeVersion = "" // These are filled at build time with the -X linker flag Tag = "unknown" Commit = "unknown" @@ -43,7 +43,7 @@ func init() { if Tag != Version && !strings.HasSuffix(Version, "+dev") { Version += "+dev" } - WAVersion = strings.FieldsFunc(Version, func(r rune) bool { return r == '-' || r == '+' })[0] + SkypeVersion = strings.FieldsFunc(Version, func(r rune) bool { return r == '-' || r == '+' })[0] } var configPath = flag.MakeFull("c", "config", "The path to your config file.", "config.yaml").String() diff --git a/matrix.go b/matrix.go index 347598a..87b5ebf 100644 --- a/matrix.go +++ b/matrix.go @@ -379,40 +379,19 @@ func (mx *MatrixHandler) HandleEncrypted(evt *event.Event) { } func (mx *MatrixHandler) HandleMessage(evt *event.Event) { - fmt.Println() - fmt.Printf("HandleMessage : %+v", evt) - fmt.Println() if mx.shouldIgnoreEvent(evt) { return } user := mx.bridge.GetUserByMXID(evt.Sender) - fmt.Println() - fmt.Printf("HandleMessage user: %+v", user) - fmt.Println() content := evt.Content.AsMessage() if user.Whitelisted && content.MsgType == event.MsgText { commandPrefix := mx.bridge.Config.Bridge.CommandPrefix - fmt.Println() - fmt.Printf("HandleMessage commandPrefix: %+v", commandPrefix) - fmt.Println() hasCommandPrefix := strings.HasPrefix(content.Body, commandPrefix) if hasCommandPrefix { content.Body = strings.TrimLeft(content.Body[len(commandPrefix):], " ") } - fmt.Println() - fmt.Printf("HandleMessage hasCommandPrefix: %+v", hasCommandPrefix) - fmt.Println() - fmt.Println() - fmt.Printf("HandleMessage evt.RoomID0: %+v", evt.RoomID) - fmt.Println() - fmt.Println() - fmt.Printf("HandleMessage user.ManagementRoom: %+v", user.ManagementRoom) - fmt.Println() if hasCommandPrefix || evt.RoomID == user.ManagementRoom { - fmt.Println() - fmt.Printf("HandleMessage commandPrefix: %+v", commandPrefix) - fmt.Println() mx.cmd.Handle(evt.RoomID, user, content.Body) return } diff --git a/user.go b/user.go index 0f74d01..826613a 100644 --- a/user.go +++ b/user.go @@ -237,7 +237,7 @@ func (user *User) SetSession(session *skype.Session) { // return false // } // user.Conn = whatsappExt.ExtendConn(conn) -// _ = user.Conn.SetClientName("matrix-skype bridge", "mx-wa", WAVersion) +// _ = user.Conn.SetClientName("matrix-skype bridge", "mx-wa", SkypeVersion) // user.log.Debugln("WhatsApp connection successful") // user.Conn.AddHandler(user) // return user.RestoreSession() @@ -263,7 +263,7 @@ func (user *User) Connect(evenIfNoSession bool) bool { return false } user.Conn = skypeExt.ExtendConn(conn) - //_ = user.Conn.SetClientName("matrix-skype bridge", "mx-wa", WAVersion) + //_ = user.Conn.SetClientName("matrix-skype bridge", "mx-wa", SkypeVersion) user.log.Debugln("skype connection successful") user.Conn.AddHandler(user) return user.RestoreSession() @@ -388,7 +388,7 @@ func (user *User) Login(ce *CommandEvent, name string, password string) (err err userIds = append(userIds, userId) } ce.User.Conn.SubscribeUsers(userIds) - go loopPresence(user) + go loopPresence(ce, user) } go user.Conn.Poll() @@ -400,9 +400,10 @@ func (user *User) Login(ce *CommandEvent, name string, password string) (err err return } -func loopPresence(user *User) { +func loopPresence(ce *CommandEvent, user *User) { for { if user.Conn.LoggedIn == false { + ce.Reply("Session expired") break } for cid, contact := range user.contactsPresence {