Skip to content

Commit

Permalink
chore: make lint happy
Browse files Browse the repository at this point in the history
  • Loading branch information
fumiama committed Oct 13, 2024
1 parent 0055c7d commit 9a40555
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions emozi/api.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Package emozi 颜文字抽象转写
package emozi

const api = "https://emozi.seku.su/api/"

// User 用户
type User struct {
name string
pswd string
Expand Down
9 changes: 9 additions & 0 deletions emozi/coder.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ import (
"github.com/FloatTech/floatbox/binary"
)

// Marshal 编码
//
// - randomSameMeaning 随机使用近音颜文字
// - text 中文文本
// - choices 多音字选择
func (usr *User) Marshal(randomSameMeaning bool, text string, choices ...int) (string, []int, error) {
w := binary.SelectWriter()
defer binary.PutWriter(w)
Expand Down Expand Up @@ -44,6 +49,10 @@ func (usr *User) Marshal(randomSameMeaning bool, text string, choices ...int) (s
return r.Result.Text, r.Result.Choice, nil
}

// Unmarshal 解码
//
// - force 强制解码不是由程序生成的转写
// - text 颜文字文本
func (usr *User) Unmarshal(force bool, text string) (string, error) {
w := binary.SelectWriter()
defer binary.PutWriter(w)
Expand Down
7 changes: 7 additions & 0 deletions emozi/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,23 @@ import (
"github.com/tidwall/gjson"
)

// NewUser 创建已注册用户实例
//
// 注册请前往 API 网址
func NewUser(name, pswd string) (usr User, err error) {
usr.name = name
usr.pswd = pswd
return
}

// Anonymous 创建匿名用户
//
// 有访问请求数限制
func Anonymous() (usr User) {
return
}

// Login 登录
func (usr *User) Login() error {
data, err := web.GetData(api + "getLoginSalt?username=" + url.QueryEscape(usr.name))
if err != nil {
Expand Down

0 comments on commit 9a40555

Please sign in to comment.