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
b545e05a
Commit
b545e05a
authored
Aug 14, 2020
by
Mrs4s
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/Mrs4s/go-cqhttp
parents
b290a0a5
774a1e32
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
11 deletions
+10
-11
coolq/bot.go
coolq/bot.go
+1
-1
coolq/event.go
coolq/event.go
+3
-4
global/fs.go
global/fs.go
+1
-1
main.go
main.go
+5
-5
No files found.
coolq/bot.go
View file @
b545e05a
...
@@ -191,7 +191,7 @@ func (bot *CQBot) dispatchEventMessage(m MSG) {
...
@@ -191,7 +191,7 @@ func (bot *CQBot) dispatchEventMessage(m MSG) {
fn
(
m
)
fn
(
m
)
end
:=
time
.
Now
()
end
:=
time
.
Now
()
if
end
.
Sub
(
start
)
>
time
.
Second
*
5
{
if
end
.
Sub
(
start
)
>
time
.
Second
*
5
{
log
.
Debugf
(
"警告: 事件处理耗时超过 5 秒 (%v
秒), 请检查应用是否有堵塞."
,
end
.
Sub
(
start
)
/
time
.
Second
)
log
.
Debugf
(
"警告: 事件处理耗时超过 5 秒 (%v
), 请检查应用是否有堵塞."
,
end
.
Sub
(
start
)
)
}
}
}()
}()
}
}
...
...
coolq/event.go
View file @
b545e05a
...
@@ -8,7 +8,6 @@ import (
...
@@ -8,7 +8,6 @@ import (
"github.com/Mrs4s/go-cqhttp/global"
"github.com/Mrs4s/go-cqhttp/global"
log
"github.com/sirupsen/logrus"
log
"github.com/sirupsen/logrus"
"io/ioutil"
"io/ioutil"
"os"
"path"
"path"
"strconv"
"strconv"
"strings"
"strings"
...
@@ -374,7 +373,7 @@ func (bot *CQBot) checkMedia(e []message.IMessageElement) {
...
@@ -374,7 +373,7 @@ func (bot *CQBot) checkMedia(e []message.IMessageElement) {
w
.
WriteUInt32
(
uint32
(
i
.
Size
))
w
.
WriteUInt32
(
uint32
(
i
.
Size
))
w
.
WriteString
(
i
.
Filename
)
w
.
WriteString
(
i
.
Filename
)
w
.
WriteString
(
i
.
Url
)
w
.
WriteString
(
i
.
Url
)
}),
os
.
ModePerm
)
}),
0644
)
}
}
i
.
Filename
=
filename
i
.
Filename
=
filename
case
*
message
.
VoiceElement
:
case
*
message
.
VoiceElement
:
...
@@ -386,7 +385,7 @@ func (bot *CQBot) checkMedia(e []message.IMessageElement) {
...
@@ -386,7 +385,7 @@ func (bot *CQBot) checkMedia(e []message.IMessageElement) {
log
.
Warnf
(
"语音文件 %v 下载失败: %v"
,
i
.
Name
,
err
)
log
.
Warnf
(
"语音文件 %v 下载失败: %v"
,
i
.
Name
,
err
)
continue
continue
}
}
_
=
ioutil
.
WriteFile
(
path
.
Join
(
global
.
VOICE_PATH
,
i
.
Name
),
b
,
os
.
ModePerm
)
_
=
ioutil
.
WriteFile
(
path
.
Join
(
global
.
VOICE_PATH
,
i
.
Name
),
b
,
0644
)
}
}
case
*
message
.
ShortVideoElement
:
case
*
message
.
ShortVideoElement
:
filename
:=
hex
.
EncodeToString
(
i
.
Md5
)
+
".video"
filename
:=
hex
.
EncodeToString
(
i
.
Md5
)
+
".video"
...
@@ -396,7 +395,7 @@ func (bot *CQBot) checkMedia(e []message.IMessageElement) {
...
@@ -396,7 +395,7 @@ func (bot *CQBot) checkMedia(e []message.IMessageElement) {
w
.
WriteUInt32
(
uint32
(
i
.
Size
))
w
.
WriteUInt32
(
uint32
(
i
.
Size
))
w
.
WriteString
(
i
.
Name
)
w
.
WriteString
(
i
.
Name
)
w
.
Write
(
i
.
Uuid
)
w
.
Write
(
i
.
Uuid
)
}),
os
.
ModePerm
)
}),
0644
)
}
}
i
.
Name
=
filename
i
.
Name
=
filename
i
.
Url
=
bot
.
Client
.
GetShortVideoUrl
(
i
.
Uuid
,
i
.
Md5
)
i
.
Url
=
bot
.
Client
.
GetShortVideoUrl
(
i
.
Uuid
,
i
.
Md5
)
...
...
global/fs.go
View file @
b545e05a
...
@@ -27,7 +27,7 @@ func ReadAllText(path string) string {
...
@@ -27,7 +27,7 @@ func ReadAllText(path string) string {
}
}
func
WriteAllText
(
path
,
text
string
)
{
func
WriteAllText
(
path
,
text
string
)
{
_
=
ioutil
.
WriteFile
(
path
,
[]
byte
(
text
),
0
777
)
_
=
ioutil
.
WriteFile
(
path
,
[]
byte
(
text
),
0
644
)
}
}
func
Check
(
err
error
)
{
func
Check
(
err
error
)
{
...
...
main.go
View file @
b545e05a
...
@@ -37,17 +37,17 @@ func init() {
...
@@ -37,17 +37,17 @@ func init() {
log
.
SetOutput
(
io
.
MultiWriter
(
os
.
Stderr
,
w
))
log
.
SetOutput
(
io
.
MultiWriter
(
os
.
Stderr
,
w
))
}
}
if
!
global
.
PathExists
(
global
.
IMAGE_PATH
)
{
if
!
global
.
PathExists
(
global
.
IMAGE_PATH
)
{
if
err
:=
os
.
MkdirAll
(
global
.
IMAGE_PATH
,
os
.
ModePerm
);
err
!=
nil
{
if
err
:=
os
.
MkdirAll
(
global
.
IMAGE_PATH
,
0755
);
err
!=
nil
{
log
.
Fatalf
(
"创建图片缓存文件夹失败: %v"
,
err
)
log
.
Fatalf
(
"创建图片缓存文件夹失败: %v"
,
err
)
}
}
}
}
if
!
global
.
PathExists
(
global
.
VOICE_PATH
)
{
if
!
global
.
PathExists
(
global
.
VOICE_PATH
)
{
if
err
:=
os
.
MkdirAll
(
global
.
VOICE_PATH
,
os
.
ModePerm
);
err
!=
nil
{
if
err
:=
os
.
MkdirAll
(
global
.
VOICE_PATH
,
0755
);
err
!=
nil
{
log
.
Fatalf
(
"创建语音缓存文件夹失败: %v"
,
err
)
log
.
Fatalf
(
"创建语音缓存文件夹失败: %v"
,
err
)
}
}
}
}
if
!
global
.
PathExists
(
global
.
VIDEO_PATH
)
{
if
!
global
.
PathExists
(
global
.
VIDEO_PATH
)
{
if
err
:=
os
.
MkdirAll
(
global
.
VIDEO_PATH
,
os
.
ModePerm
);
err
!=
nil
{
if
err
:=
os
.
MkdirAll
(
global
.
VIDEO_PATH
,
0755
);
err
!=
nil
{
log
.
Fatalf
(
"创建视频缓存文件夹失败: %v"
,
err
)
log
.
Fatalf
(
"创建视频缓存文件夹失败: %v"
,
err
)
}
}
}
}
...
@@ -135,7 +135,7 @@ func main() {
...
@@ -135,7 +135,7 @@ func main() {
if
!
global
.
PathExists
(
"device.json"
)
{
if
!
global
.
PathExists
(
"device.json"
)
{
log
.
Warn
(
"虚拟设备信息不存在, 将自动生成随机设备."
)
log
.
Warn
(
"虚拟设备信息不存在, 将自动生成随机设备."
)
client
.
GenRandomDevice
()
client
.
GenRandomDevice
()
_
=
ioutil
.
WriteFile
(
"device.json"
,
client
.
SystemDeviceInfo
.
ToJson
(),
os
.
ModePerm
)
_
=
ioutil
.
WriteFile
(
"device.json"
,
client
.
SystemDeviceInfo
.
ToJson
(),
0644
)
log
.
Info
(
"已生成设备信息并保存到 device.json 文件."
)
log
.
Info
(
"已生成设备信息并保存到 device.json 文件."
)
}
else
{
}
else
{
log
.
Info
(
"将使用 device.json 内的设备信息运行Bot."
)
log
.
Info
(
"将使用 device.json 内的设备信息运行Bot."
)
...
@@ -171,7 +171,7 @@ func main() {
...
@@ -171,7 +171,7 @@ func main() {
if
!
rsp
.
Success
{
if
!
rsp
.
Success
{
switch
rsp
.
Error
{
switch
rsp
.
Error
{
case
client
.
NeedCaptcha
:
case
client
.
NeedCaptcha
:
_
=
ioutil
.
WriteFile
(
"captcha.jpg"
,
rsp
.
CaptchaImage
,
os
.
ModePerm
)
_
=
ioutil
.
WriteFile
(
"captcha.jpg"
,
rsp
.
CaptchaImage
,
0644
)
img
,
_
,
_
:=
image
.
Decode
(
bytes
.
NewReader
(
rsp
.
CaptchaImage
))
img
,
_
,
_
:=
image
.
Decode
(
bytes
.
NewReader
(
rsp
.
CaptchaImage
))
fmt
.
Println
(
asciiart
.
New
(
"image"
,
img
)
.
Art
)
fmt
.
Println
(
asciiart
.
New
(
"image"
,
img
)
.
Art
)
log
.
Warn
(
"请输入验证码 (captcha.jpg): (Enter 提交)"
)
log
.
Warn
(
"请输入验证码 (captcha.jpg): (Enter 提交)"
)
...
...
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