diff options
| author | Fuwn <[email protected]> | 2021-07-05 18:15:40 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2021-07-05 18:15:40 -0700 |
| commit | a7587a06445a7852e6931d807b885cc5d3227fd3 (patch) | |
| tree | 80ca884c63d796957d75d2c214836cf0f9390b9e | |
| parent | refactor(discord): move prefix to config file (diff) | |
| download | munch-a7587a06445a7852e6931d807b885cc5d3227fd3.tar.xz munch-a7587a06445a7852e6931d807b885cc5d3227fd3.zip | |
refactor(utilities): move utilities to seperate package
| -rw-r--r-- | pkg/server/utils/encode.go | 10 | ||||
| -rw-r--r-- | pkg/utilities/hex.go (renamed from pkg/server/utils/hex.go) | 2 |
2 files changed, 7 insertions, 5 deletions
diff --git a/pkg/server/utils/encode.go b/pkg/server/utils/encode.go index 86e5500..dc37b6b 100644 --- a/pkg/server/utils/encode.go +++ b/pkg/server/utils/encode.go @@ -3,6 +3,8 @@ package utils +import "github.com/Whirlsplash/munch/pkg/utilities" + const ( AutoServer = iota RoomServer @@ -28,10 +30,10 @@ func EncodeSessionInitialization(username string, password string, serverType in data += // Username - "\x02" + string(rune(len(username))) + ISO88591ToString(username) + + "\x02" + string(rune(len(username))) + utilities.ISO88591ToString(username) + // Password - "\x06" + string(rune(len(password))) + ISO88591ToString(password) + "\x06" + string(rune(len(password))) + utilities.ISO88591ToString(password) if serverType == AutoServer { data += "\x0c\x01\x31" @@ -45,7 +47,7 @@ func EncodeBuddyListUpdate(buddy string) []byte { data := "\x01\x1d" // Buddy UTF-8 length and UTF-8 - data += string(rune(len(buddy))) + ISO88591ToString(buddy) + data += string(rune(len(buddy))) + utilities.ISO88591ToString(buddy) // Buddy "add" data += "\x01" @@ -61,7 +63,7 @@ func EncodePropertyUpdate(avatar string) []byte { data := "\x01\x0f\x00\x05\x40\x01" // Avatar UTF-8 length and UTF-8 - data += string(rune(len("avatar:"+avatar))) + ISO88591ToString("avatar:"+avatar) + data += string(rune(len("avatar:"+avatar))) + utilities.ISO88591ToString("avatar:"+avatar) // Data length data = (string(rune(len(data) + 1))) + data diff --git a/pkg/server/utils/hex.go b/pkg/utilities/hex.go index a5393aa..30428b7 100644 --- a/pkg/server/utils/hex.go +++ b/pkg/utilities/hex.go @@ -1,4 +1,4 @@ -package utils +package utilities import "unicode/utf8" |