add return orgid

This commit is contained in:
zhaoYangguang 2021-05-14 18:34:39 +08:00
parent 55f909a47f
commit 459b54955a
2 changed files with 25 additions and 3 deletions

View File

@ -7,6 +7,7 @@ import (
"github.com/kelaresg/matrix-skype/database" "github.com/kelaresg/matrix-skype/database"
skypeExt "github.com/kelaresg/matrix-skype/skype-ext" skypeExt "github.com/kelaresg/matrix-skype/skype-ext"
"math" "math"
"maunium.net/go/mautrix/patch"
"sort" "sort"
"strconv" "strconv"
@ -482,7 +483,14 @@ func (handler *CommandHandler) CommandPing(ce *CommandEvent) {
if username == "" { if username == "" {
username = ce.User.Conn.UserProfile.Username username = ce.User.Conn.UserProfile.Username
} }
ce.Reply("You're logged in as @" + username)
orgId := ""
if patch.ThirdPartyIdEncrypt {
orgId = patch.Enc(strings.TrimSuffix(ce.User.JID, skypeExt.NewUserSuffix))
} else {
orgId = strings.TrimSuffix(ce.User.JID, skypeExt.NewUserSuffix)
}
ce.Reply("You're logged in as @" + username + ", orgid is " + orgId)
} }
} }

18
user.go
View File

@ -6,6 +6,7 @@ import (
"fmt" "fmt"
skype "github.com/kelaresg/go-skypeapi" skype "github.com/kelaresg/go-skypeapi"
skypeExt "github.com/kelaresg/matrix-skype/skype-ext" skypeExt "github.com/kelaresg/matrix-skype/skype-ext"
"maunium.net/go/mautrix/patch"
"sort" "sort"
//"strconv" //"strconv"
"strings" "strings"
@ -333,7 +334,13 @@ func (user *User) Login(ce *CommandEvent, name string, password string) (err err
err = user.Conn.Login(name, password) err = user.Conn.Login(name, password)
if err != nil { if err != nil {
user.log.Errorln("Failed to login:", err) user.log.Errorln("Failed to login:", err)
ce.Reply(err.Error()) orgId := ""
if patch.ThirdPartyIdEncrypt {
orgId = patch.Enc(strings.TrimSuffix(user.JID, skypeExt.NewUserSuffix))
} else {
orgId = strings.TrimSuffix(user.JID, skypeExt.NewUserSuffix)
}
ce.Reply(err.Error() + ", orgid is " + orgId)
return err return err
} }
username := user.Conn.UserProfile.FirstName username := user.Conn.UserProfile.FirstName
@ -343,7 +350,14 @@ func (user *User) Login(ce *CommandEvent, name string, password string) (err err
if username == "" { if username == "" {
username = user.Conn.UserProfile.Username username = user.Conn.UserProfile.Username
} }
ce.Reply("Successfully logged in as @" + username)
orgId := ""
if patch.ThirdPartyIdEncrypt {
orgId = patch.Enc(strings.TrimSuffix(user.JID, skypeExt.NewUserSuffix))
} else {
orgId = strings.TrimSuffix(user.JID, skypeExt.NewUserSuffix)
}
ce.Reply("Successfully logged in as @" + username + ", orgid is " + orgId)
user.Conn.Subscribes() // subscribe basic event user.Conn.Subscribes() // subscribe basic event
err = user.Conn.Conn.ContactList(user.Conn.UserProfile.Username) err = user.Conn.Conn.ContactList(user.Conn.UserProfile.Username)