mirror of
https://github.com/c0re100/gotdlib.git
synced 2026-02-21 20:20:17 +01:00
修正单词拼写,更新新的UUID包。(Fix word spelling, update new UUID package)
This commit is contained in:
parent
af2b93f686
commit
9e42c4a4ee
3 changed files with 49 additions and 20 deletions
|
|
@ -1,26 +1,20 @@
|
|||
package client
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"strings"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type ExtraGenerator func() string
|
||||
|
||||
func UuidV4Generator() ExtraGenerator {
|
||||
return func() string {
|
||||
var uuid [16]byte
|
||||
rand.Read(uuid[:])
|
||||
|
||||
uuid[6] = (uuid[6] & 0x0f) | 0x40
|
||||
uuid[8] = (uuid[8] & 0x3f) | 0x80
|
||||
|
||||
return fmt.Sprintf("%08x-%04x-%04x-%04x-%012x", uuid[:4], uuid[4:6], uuid[6:8], uuid[8:10], uuid[10:])
|
||||
return uuid.NewString()
|
||||
}
|
||||
}
|
||||
|
||||
func IsCommmand(text string) bool {
|
||||
func IsCommand(text string) bool {
|
||||
if text != "" {
|
||||
if text[0] == '/' {
|
||||
return true
|
||||
|
|
@ -30,7 +24,7 @@ func IsCommmand(text string) bool {
|
|||
}
|
||||
|
||||
func CheckCommand(text string, entities []*TextEntity) string {
|
||||
if IsCommmand(text) {
|
||||
if IsCommand(text) {
|
||||
// Check text entities and make bot happy!
|
||||
if len(entities) >= 1 {
|
||||
// Get first command
|
||||
|
|
@ -61,7 +55,7 @@ func CheckCommand(text string, entities []*TextEntity) string {
|
|||
}
|
||||
|
||||
func CommandArgument(text string) string {
|
||||
if IsCommmand(text) {
|
||||
if IsCommand(text) {
|
||||
// e.g. ["/hello 123", "/hell o 123"]
|
||||
// Result: "123", "o 123"
|
||||
if i := strings.Index(text, " "); i != -1 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue