✏️ drop pb in timer

This commit is contained in:
fumiama
2021-12-16 12:51:41 +08:00
parent b871573dc3
commit a363623df9
11 changed files with 258 additions and 121 deletions

View File

@@ -2,9 +2,9 @@ package main
import (
"crypto/md5"
"encoding/binary"
"fmt"
"os"
"unsafe"
"github.com/RomiChan/protobuf/proto"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
@@ -37,7 +37,7 @@ func main() {
}
for _, d := range compo.Array {
s := md5.Sum(helper.StringToBytes(d))
i := *(*int64)(unsafe.Pointer(&s))
i := int64(binary.LittleEndian.Uint64(s[:8]))
fmt.Printf("[Diana]id: %d\n", i)
err = db.Insert("text", &Text{
Id: i,

View File

@@ -3,8 +3,8 @@ package data
import (
"crypto/md5"
"encoding/binary"
"os"
"unsafe"
log "github.com/sirupsen/logrus"
"github.com/wdvxdr1123/ZeroBot/utils/helper"
@@ -56,8 +56,8 @@ func LoadText() error {
// AddText 添加小作文
func AddText(txt string) error {
s := md5.Sum(helper.StringToBytes(txt))
i := *(*int64)(unsafe.Pointer(&s))
return db.Insert("text", &Text{Id: i, Data: txt})
i := binary.LittleEndian.Uint64(s[:8])
return db.Insert("text", &Text{Id: int64(i), Data: txt})
}
// RandText 随机小作文