mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-06-30 11:53:25 +00:00
Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
e754bd36ed | |||
fb47a66931 |
@ -10,8 +10,10 @@ import (
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/tidwall/gjson"
|
||||
"io/ioutil"
|
||||
"net/url"
|
||||
"path"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
@ -176,6 +178,20 @@ func (bot *CQBot) ToElement(t string, d map[string]string, group bool) (message.
|
||||
}
|
||||
return message.NewImage(b), nil
|
||||
}
|
||||
if strings.HasPrefix(f, "file") {
|
||||
fu, err := url.Parse(f)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if strings.HasPrefix(fu.Path, "/") && runtime.GOOS == `windows` {
|
||||
fu.Path = fu.Path[1:]
|
||||
}
|
||||
b, err := ioutil.ReadFile(fu.Path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return message.NewImage(b), nil
|
||||
}
|
||||
if global.PathExists(path.Join(global.IMAGE_PATH, f)) {
|
||||
b, err := ioutil.ReadFile(path.Join(global.IMAGE_PATH, f))
|
||||
if err != nil {
|
||||
|
@ -53,6 +53,7 @@ func (bot *CQBot) groupMessageEvent(c *client.QQClient, m *message.GroupMessage)
|
||||
"name": file.Name,
|
||||
"size": file.Size,
|
||||
"busid": file.Busid,
|
||||
"url": c.GetGroupFileUrl(m.GroupCode, file.Path, file.Busid),
|
||||
},
|
||||
"self_id": c.Uin,
|
||||
"time": time.Now().Unix(),
|
||||
|
2
go.mod
2
go.mod
@ -3,7 +3,7 @@ module github.com/Mrs4s/go-cqhttp
|
||||
go 1.14
|
||||
|
||||
require (
|
||||
github.com/Mrs4s/MiraiGo v0.0.0-20200802150153-a7761bfb7571
|
||||
github.com/Mrs4s/MiraiGo v0.0.0-20200803034534-d8ed1a49ff8b
|
||||
github.com/gin-gonic/gin v1.6.3
|
||||
github.com/gorilla/websocket v1.4.2
|
||||
github.com/guonaihong/gout v0.1.1
|
||||
|
4
go.sum
4
go.sum
@ -2,6 +2,10 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/Mrs4s/MiraiGo v0.0.0-20200802150153-a7761bfb7571 h1:OQQhH7IVRX5BqjUwrlg6mKVUlxKoBzOPUNwZEToGQ00=
|
||||
github.com/Mrs4s/MiraiGo v0.0.0-20200802150153-a7761bfb7571/go.mod h1:M9wh1hjd0rie3+wm27tjPZkYMbD+MBV76CGqp2G7WSU=
|
||||
github.com/Mrs4s/MiraiGo v0.0.0-20200802165028-683ad4b6cbb5 h1:NF3YM6Bv2/sA6yc1wxuBuHRfVBhQws02INRpqrkqmh4=
|
||||
github.com/Mrs4s/MiraiGo v0.0.0-20200802165028-683ad4b6cbb5/go.mod h1:M9wh1hjd0rie3+wm27tjPZkYMbD+MBV76CGqp2G7WSU=
|
||||
github.com/Mrs4s/MiraiGo v0.0.0-20200803034534-d8ed1a49ff8b h1:XQEeWyot+xvUDV9btSbI+fAJdWXxRLBWE8wRyzpgmfA=
|
||||
github.com/Mrs4s/MiraiGo v0.0.0-20200803034534-d8ed1a49ff8b/go.mod h1:M9wh1hjd0rie3+wm27tjPZkYMbD+MBV76CGqp2G7WSU=
|
||||
github.com/bwmarrin/snowflake v0.3.0 h1:xm67bEhkKh6ij1790JB83OujPR5CzNe8QuQqAgISZN0=
|
||||
github.com/bwmarrin/snowflake v0.3.0/go.mod h1:NdZxfVWX+oR6y2K0o6qAYv6gIOP9rjG0/E9WsDpxqwE=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
|
Reference in New Issue
Block a user