mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-20 06:20:08 +08:00
✏️ str byte 转换改用 zb 的工具
This commit is contained in:
parent
cccea70db1
commit
98b21d0fdf
@ -10,7 +10,7 @@
|
||||
[](https://github.com/takayama-lily/node-onebot)
|
||||
[](https://github.com/yyuueexxiinngg/onebot-kotlin)
|
||||
|
||||
[](https://goreportcard.com/report/github.com/github.com/Yiwen-Chan/ZeroBot-Plugin)
|
||||
[](https://goreportcard.com/report/github.com/github.com/FloatTech/ZeroBot-Plugin)
|
||||
[](https://github.com/howmanybots/onebot)
|
||||
[](https://github.com/wdvxdr1123/ZeroBot)
|
||||
[](https://raw.githubusercontent.com/FloatTech/ZeroBot-Plugin/master/LICENSE)
|
||||
@ -35,7 +35,7 @@ zerobot -h -t token -u url [-d|w] [-g] qq1 qq2 qq3 ...
|
||||
- **web管理**
|
||||
- 因为开启后可执行文件大约增加 5M ,默认注释不开启。
|
||||
- 需要配合 [webgui](https://github.com/FloatTech/bot-manager) 使用
|
||||
- **动态加载插件**
|
||||
- **动态加载插件** `import _ github.com/FloatTech/ZeroBot-Plugin-Dynamic/dyloader`
|
||||
- [x] /刷新插件
|
||||
- [x] /加载插件 service名
|
||||
- [x] /卸载插件 service名
|
||||
@ -182,7 +182,7 @@ zerobot -h -t token -u url [-d|w] [-g] qq1 qq2 qq3 ...
|
||||
### 本地运行
|
||||
|
||||
1. 下载安装 [Go](https://studygolang.com/dl) 环境
|
||||
2. 下载本项目[压缩包](https://github.com/Yiwen-Chan/ZeroBot-Plugin/archive/master.zip),本地解压
|
||||
2. 下载本项目[压缩包](https://github.com/FloatTech/ZeroBot-Plugin/archive/master.zip),本地解压
|
||||
3. 编辑 main.go 文件,内容按需修改
|
||||
4. 双击 build.bat 文件 或 直接双击 run.bat 文件
|
||||
5. 运行 OneBot 框架,并同时运行本插件
|
||||
@ -234,4 +234,4 @@ GOOS=linux GOARCH=mips GOMIPS=softfloat CGO_ENABLED=0 go build -ldflags "-s -w"
|
||||
|
||||
## License
|
||||
|
||||
[](https://app.fossa.com/projects/git%2Bgithub.com%2FYiwen-Chan%2FZeroBot-Plugin?ref=badge_large)
|
||||
[](https://app.fossa.com/projects/git%2Bgithub.com%2FFloatTech%2FZeroBot-Plugin?ref=badge_large)
|
||||
|
||||
15
data/mem.go
15
data/mem.go
@ -1,15 +0,0 @@
|
||||
package data
|
||||
|
||||
import "unsafe"
|
||||
|
||||
// Str2bytes Fast convert
|
||||
func Str2bytes(s string) []byte {
|
||||
x := (*[2]uintptr)(unsafe.Pointer(&s))
|
||||
h := [3]uintptr{x[0], x[1], x[1]}
|
||||
return *(*[]byte)(unsafe.Pointer(&h))
|
||||
}
|
||||
|
||||
// Bytes2str Fast convert
|
||||
func Bytes2str(b []byte) string {
|
||||
return *(*string)(unsafe.Pointer(&b))
|
||||
}
|
||||
@ -10,8 +10,7 @@ import (
|
||||
"time"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/data"
|
||||
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -43,7 +42,7 @@ func init() {
|
||||
log.Printf("[Diana]读取%d条小作文", arrl)
|
||||
md5s = make([]*[16]byte, arrl)
|
||||
for i, t := range *Array {
|
||||
m := md5.Sum(data.Str2bytes(t))
|
||||
m := md5.Sum(helper.StringToBytes(t))
|
||||
md5s[i] = &m
|
||||
}
|
||||
} else {
|
||||
@ -93,7 +92,7 @@ func LoadText() error {
|
||||
|
||||
// AddText 添加小作文
|
||||
func AddText(txt string) error {
|
||||
sum := md5.Sum(data.Str2bytes(txt))
|
||||
sum := md5.Sum(helper.StringToBytes(txt))
|
||||
if txt != "" && !isin(&sum) {
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
|
||||
@ -17,6 +17,7 @@ import (
|
||||
"github.com/fogleman/gg"
|
||||
zero "github.com/wdvxdr1123/ZeroBot"
|
||||
"github.com/wdvxdr1123/ZeroBot/message"
|
||||
"github.com/wdvxdr1123/ZeroBot/utils/helper"
|
||||
|
||||
"github.com/FloatTech/ZeroBot-Plugin/control"
|
||||
"github.com/FloatTech/ZeroBot-Plugin/data"
|
||||
@ -145,7 +146,7 @@ func init() {
|
||||
return
|
||||
}
|
||||
// 发送图片
|
||||
ctx.SendChain(message.Image("base64://" + data.Bytes2str(d)))
|
||||
ctx.SendChain(message.Image("base64://" + helper.BytesToString(d)))
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user