Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
G
go-cqhttp
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
go-cqhttp
Commits
470efa07
Commit
470efa07
authored
Aug 20, 2020
by
Mrs4s
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
url cache supported.
parent
b7572f8d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
5 deletions
+22
-5
coolq/cqcode.go
coolq/cqcode.go
+14
-0
go.mod
go.mod
+1
-1
go.sum
go.sum
+2
-4
main.go
main.go
+5
-0
No files found.
coolq/cqcode.go
View file @
470efa07
package
coolq
import
(
"crypto/md5"
"encoding/base64"
"encoding/hex"
"errors"
...
...
@@ -261,10 +262,23 @@ func (bot *CQBot) ToElement(t string, d map[string]string, group bool) (message.
case
"image"
:
f
:=
d
[
"file"
]
if
strings
.
HasPrefix
(
f
,
"http"
)
||
strings
.
HasPrefix
(
f
,
"https"
)
{
cache
:=
d
[
"cache"
]
if
cache
==
""
{
cache
=
"1"
}
hash
:=
md5
.
Sum
([]
byte
(
f
))
cacheFile
:=
path
.
Join
(
global
.
CACHE_PATH
,
hex
.
EncodeToString
(
hash
[
:
])
+
".cache"
)
if
global
.
PathExists
(
cacheFile
)
&&
cache
==
"1"
{
b
,
err
:=
ioutil
.
ReadFile
(
cacheFile
)
if
err
==
nil
{
return
message
.
NewImage
(
b
),
nil
}
}
b
,
err
:=
global
.
GetBytes
(
f
)
if
err
!=
nil
{
return
nil
,
err
}
_
=
ioutil
.
WriteFile
(
cacheFile
,
b
,
0644
)
return
message
.
NewImage
(
b
),
nil
}
if
strings
.
HasPrefix
(
f
,
"base64"
)
{
...
...
go.mod
View file @
470efa07
...
...
@@ -3,7 +3,7 @@ module github.com/Mrs4s/go-cqhttp
go 1.14
require (
github.com/Mrs4s/MiraiGo v0.0.0-20200819
041545-3561e5f156ce
github.com/Mrs4s/MiraiGo v0.0.0-20200819
185537-8d1e5fb04c17
github.com/gin-gonic/gin v1.6.3
github.com/gorilla/websocket v1.4.2
github.com/guonaihong/gout v0.1.1
...
...
go.sum
View file @
470efa07
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Mrs4s/MiraiGo v0.0.0-20200817175311-ac7fc7ad2847 h1:ZnCHrRSLvN+a7ndOFPJF/FIg80JM6WxiOGC1TPTarEk=
github.com/Mrs4s/MiraiGo v0.0.0-20200817175311-ac7fc7ad2847/go.mod h1:0je03wji/tSw4bUH4QCF2Z4/EjyNWjSJTyy5tliX6EM=
github.com/Mrs4s/MiraiGo v0.0.0-20200819041545-3561e5f156ce h1:rqefWaA8Xrk6qxFBbEQaySOUXH614DIR7cFmU5jVAQY=
github.com/Mrs4s/MiraiGo v0.0.0-20200819041545-3561e5f156ce/go.mod h1:0je03wji/tSw4bUH4QCF2Z4/EjyNWjSJTyy5tliX6EM=
github.com/Mrs4s/MiraiGo v0.0.0-20200819185537-8d1e5fb04c17 h1:sY4lwW34serGKnD26hP7ZLpnJ4NfVYKdS2SJIW1Mezs=
github.com/Mrs4s/MiraiGo v0.0.0-20200819185537-8d1e5fb04c17/go.mod h1:0je03wji/tSw4bUH4QCF2Z4/EjyNWjSJTyy5tliX6EM=
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=
...
...
main.go
View file @
470efa07
...
...
@@ -51,6 +51,11 @@ func init() {
log
.
Fatalf
(
"创建视频缓存文件夹失败: %v"
,
err
)
}
}
if
!
global
.
PathExists
(
global
.
CACHE_PATH
)
{
if
err
:=
os
.
MkdirAll
(
global
.
CACHE_PATH
,
0755
);
err
!=
nil
{
log
.
Fatalf
(
"创建发送图片缓存文件夹失败: %v"
,
err
)
}
}
if
global
.
PathExists
(
"cqhttp.json"
)
{
log
.
Info
(
"发现 cqhttp.json 将在五秒后尝试导入配置,按 Ctrl+C 取消."
)
log
.
Warn
(
"警告: 该操作会删除 cqhttp.json 并覆盖 config.json 文件."
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment