From 9a405555486579782fc7a991ce3be270edaa8528 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Sun, 13 Oct 2024 17:34:19 +0900 Subject: [PATCH] chore: make lint happy --- emozi/api.go | 2 ++ emozi/coder.go | 9 +++++++++ emozi/login.go | 7 +++++++ 3 files changed, 18 insertions(+) diff --git a/emozi/api.go b/emozi/api.go index 2c99dfe..2a07bee 100644 --- a/emozi/api.go +++ b/emozi/api.go @@ -1,7 +1,9 @@ +// Package emozi 颜文字抽象转写 package emozi const api = "https://emozi.seku.su/api/" +// User 用户 type User struct { name string pswd string diff --git a/emozi/coder.go b/emozi/coder.go index d6a258b..d9bb51a 100644 --- a/emozi/coder.go +++ b/emozi/coder.go @@ -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) @@ -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) diff --git a/emozi/login.go b/emozi/login.go index 7a6c8f2..3d3ce7a 100644 --- a/emozi/login.go +++ b/emozi/login.go @@ -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 {