reply in management room when session expired and remove useless print log
This commit is contained in:
parent
bada7a88d6
commit
c12ba3d64e
|
@ -117,7 +117,7 @@ func (handler *CommandHandler) CommandMux(ce *CommandEvent) {
|
||||||
handler.CommandLogout(ce)
|
handler.CommandLogout(ce)
|
||||||
case "login-matrix", "sync", "list", "open", "pm", "invite", "kick", "leave", "join", "create", "share":
|
case "login-matrix", "sync", "list", "open", "pm", "invite", "kick", "leave", "join", "create", "share":
|
||||||
if !ce.User.HasSession() {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -435,7 +435,7 @@ func (handler *CommandHandler) CommandPing(ce *CommandEvent) {
|
||||||
if len(ce.User.Conn.UserProfile.LastName) > 0 {
|
if len(ce.User.Conn.UserProfile.LastName) > 0 {
|
||||||
username = username + ce.User.Conn.UserProfile.LastName
|
username = username + ce.User.Conn.UserProfile.LastName
|
||||||
}
|
}
|
||||||
ce.Reply("You are logged in as @" + username)
|
ce.Reply("You're logged in as @" + username)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
4
main.go
4
main.go
|
@ -29,7 +29,7 @@ var (
|
||||||
URL = "unknown"
|
URL = "unknown"
|
||||||
// This is changed when making a release
|
// This is changed when making a release
|
||||||
Version = "0.1.1"
|
Version = "0.1.1"
|
||||||
WAVersion = ""
|
SkypeVersion = ""
|
||||||
// These are filled at build time with the -X linker flag
|
// These are filled at build time with the -X linker flag
|
||||||
Tag = "unknown"
|
Tag = "unknown"
|
||||||
Commit = "unknown"
|
Commit = "unknown"
|
||||||
|
@ -43,7 +43,7 @@ func init() {
|
||||||
if Tag != Version && !strings.HasSuffix(Version, "+dev") {
|
if Tag != Version && !strings.HasSuffix(Version, "+dev") {
|
||||||
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()
|
var configPath = flag.MakeFull("c", "config", "The path to your config file.", "config.yaml").String()
|
||||||
|
|
21
matrix.go
21
matrix.go
|
@ -379,40 +379,19 @@ func (mx *MatrixHandler) HandleEncrypted(evt *event.Event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mx *MatrixHandler) HandleMessage(evt *event.Event) {
|
func (mx *MatrixHandler) HandleMessage(evt *event.Event) {
|
||||||
fmt.Println()
|
|
||||||
fmt.Printf("HandleMessage : %+v", evt)
|
|
||||||
fmt.Println()
|
|
||||||
if mx.shouldIgnoreEvent(evt) {
|
if mx.shouldIgnoreEvent(evt) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
user := mx.bridge.GetUserByMXID(evt.Sender)
|
user := mx.bridge.GetUserByMXID(evt.Sender)
|
||||||
fmt.Println()
|
|
||||||
fmt.Printf("HandleMessage user: %+v", user)
|
|
||||||
fmt.Println()
|
|
||||||
content := evt.Content.AsMessage()
|
content := evt.Content.AsMessage()
|
||||||
if user.Whitelisted && content.MsgType == event.MsgText {
|
if user.Whitelisted && content.MsgType == event.MsgText {
|
||||||
commandPrefix := mx.bridge.Config.Bridge.CommandPrefix
|
commandPrefix := mx.bridge.Config.Bridge.CommandPrefix
|
||||||
fmt.Println()
|
|
||||||
fmt.Printf("HandleMessage commandPrefix: %+v", commandPrefix)
|
|
||||||
fmt.Println()
|
|
||||||
hasCommandPrefix := strings.HasPrefix(content.Body, commandPrefix)
|
hasCommandPrefix := strings.HasPrefix(content.Body, commandPrefix)
|
||||||
if hasCommandPrefix {
|
if hasCommandPrefix {
|
||||||
content.Body = strings.TrimLeft(content.Body[len(commandPrefix):], " ")
|
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 {
|
if hasCommandPrefix || evt.RoomID == user.ManagementRoom {
|
||||||
fmt.Println()
|
|
||||||
fmt.Printf("HandleMessage commandPrefix: %+v", commandPrefix)
|
|
||||||
fmt.Println()
|
|
||||||
mx.cmd.Handle(evt.RoomID, user, content.Body)
|
mx.cmd.Handle(evt.RoomID, user, content.Body)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
9
user.go
9
user.go
|
@ -237,7 +237,7 @@ func (user *User) SetSession(session *skype.Session) {
|
||||||
// return false
|
// return false
|
||||||
// }
|
// }
|
||||||
// user.Conn = whatsappExt.ExtendConn(conn)
|
// 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.log.Debugln("WhatsApp connection successful")
|
||||||
// user.Conn.AddHandler(user)
|
// user.Conn.AddHandler(user)
|
||||||
// return user.RestoreSession()
|
// return user.RestoreSession()
|
||||||
|
@ -263,7 +263,7 @@ func (user *User) Connect(evenIfNoSession bool) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
user.Conn = skypeExt.ExtendConn(conn)
|
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.log.Debugln("skype connection successful")
|
||||||
user.Conn.AddHandler(user)
|
user.Conn.AddHandler(user)
|
||||||
return user.RestoreSession()
|
return user.RestoreSession()
|
||||||
|
@ -388,7 +388,7 @@ func (user *User) Login(ce *CommandEvent, name string, password string) (err err
|
||||||
userIds = append(userIds, userId)
|
userIds = append(userIds, userId)
|
||||||
}
|
}
|
||||||
ce.User.Conn.SubscribeUsers(userIds)
|
ce.User.Conn.SubscribeUsers(userIds)
|
||||||
go loopPresence(user)
|
go loopPresence(ce, user)
|
||||||
}
|
}
|
||||||
go user.Conn.Poll()
|
go user.Conn.Poll()
|
||||||
|
|
||||||
|
@ -400,9 +400,10 @@ func (user *User) Login(ce *CommandEvent, name string, password string) (err err
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func loopPresence(user *User) {
|
func loopPresence(ce *CommandEvent, user *User) {
|
||||||
for {
|
for {
|
||||||
if user.Conn.LoggedIn == false {
|
if user.Conn.LoggedIn == false {
|
||||||
|
ce.Reply("Session expired")
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
for cid, contact := range user.contactsPresence {
|
for cid, contact := range user.contactsPresence {
|
||||||
|
|
Loading…
Reference in New Issue