mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-05-05 03:23:49 +08:00
parent
a57a44f3d6
commit
144220a1da
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,7 +1,7 @@
|
|||||||
vendor/
|
vendor/
|
||||||
.idea
|
.idea
|
||||||
|
.vscode
|
||||||
config.hjson
|
config.hjson
|
||||||
device.json
|
device.json
|
||||||
codec/
|
|
||||||
data/
|
data/
|
||||||
logs/
|
logs/
|
@ -55,7 +55,7 @@ linters:
|
|||||||
- prealloc
|
- prealloc
|
||||||
- predeclared
|
- predeclared
|
||||||
- asciicheck
|
- asciicheck
|
||||||
- revive
|
- golint
|
||||||
- forbidigo
|
- forbidigo
|
||||||
- makezero
|
- makezero
|
||||||
#- interfacer
|
#- interfacer
|
||||||
@ -82,7 +82,7 @@ run:
|
|||||||
|
|
||||||
# output configuration options
|
# output configuration options
|
||||||
output:
|
output:
|
||||||
format: 'colored-line-number'
|
format: "colored-line-number"
|
||||||
print-issued-lines: true
|
print-issued-lines: true
|
||||||
print-linter-name: true
|
print-linter-name: true
|
||||||
uniq-by-line: true
|
uniq-by-line: true
|
||||||
@ -90,3 +90,6 @@ output:
|
|||||||
issues:
|
issues:
|
||||||
# Fix found issues (if it's supported by the linter)
|
# Fix found issues (if it's supported by the linter)
|
||||||
fix: true
|
fix: true
|
||||||
|
exclude-use-default: false
|
||||||
|
exclude:
|
||||||
|
- "Error return value of .((os.)?std(out|err)..*|.*Close|.*Flush|os.Remove(All)?|.*print(f|ln)?|os.(Un)?Setenv). is not check"
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package global
|
package global
|
||||||
|
|
||||||
|
// AccountToken 存储AccountToken供登录使用
|
||||||
var AccountToken []byte
|
var AccountToken []byte
|
||||||
|
|
||||||
// PasswordHash 存储QQ密码哈希供登录使用
|
// PasswordHash 存储QQ密码哈希供登录使用
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// Package config 包含go-cqhttp操作配置文件的相关函数
|
||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -56,6 +57,7 @@ type Config struct {
|
|||||||
Database map[string]yaml.Node `yaml:"database"`
|
Database map[string]yaml.Node `yaml:"database"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MiddleWares 通信中间件
|
||||||
type MiddleWares struct {
|
type MiddleWares struct {
|
||||||
AccessToken string `yaml:"access-token"`
|
AccessToken string `yaml:"access-token"`
|
||||||
Filter string `yaml:"filter"`
|
Filter string `yaml:"filter"`
|
||||||
|
2
global/terminal/doc.go
Normal file
2
global/terminal/doc.go
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
// Package terminal 包含用于检测在windows下是否通过双击运行go-cqhttp的函数
|
||||||
|
package terminal
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
package terminal
|
package terminal
|
||||||
|
|
||||||
|
// RunningByDoubleClick 检查是否通过双击直接运行,非Windows系统永远返回false
|
||||||
func RunningByDoubleClick() bool {
|
func RunningByDoubleClick() bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// Package update 包含go-cqhttp自我更新相关函数
|
||||||
package update
|
package update
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -34,8 +35,8 @@ func (wc *WriteCounter) PrintProgress() {
|
|||||||
fmt.Printf("\rDownloading... %s complete", humanize.Bytes(wc.Total))
|
fmt.Printf("\rDownloading... %s complete", humanize.Bytes(wc.Total))
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateFromStream copy form getlantern/go-update
|
// FromStream copy form getlantern/go-update
|
||||||
func UpdateFromStream(updateWith io.Reader) (err error, errRecover error) {
|
func FromStream(updateWith io.Reader) (err error, errRecover error) {
|
||||||
updatePath, err := osext.Executable()
|
updatePath, err := osext.Executable()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
@ -13,6 +13,7 @@ import (
|
|||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Update go-cqhttp自我更新
|
||||||
func Update(url string) {
|
func Update(url string) {
|
||||||
resp, err := http.Get(url)
|
resp, err := http.Get(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -38,7 +39,7 @@ func Update(url string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if header.Name == "go-cqhttp" {
|
if header.Name == "go-cqhttp" {
|
||||||
err, _ := UpdateFromStream(tr)
|
err, _ := FromStream(tr)
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("更新失败!", err)
|
log.Error("更新失败!", err)
|
||||||
|
@ -10,6 +10,7 @@ import (
|
|||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Update go-cqhttp自我更新
|
||||||
func Update(url string) {
|
func Update(url string) {
|
||||||
resp, err := http.Get(url)
|
resp, err := http.Get(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -25,7 +26,7 @@ func Update(url string) {
|
|||||||
log.Error("更新失败!", err)
|
log.Error("更新失败!", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err, _ = UpdateFromStream(file)
|
err, _ = FromStream(file)
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("更新失败!", err)
|
log.Error("更新失败!", err)
|
||||||
|
@ -322,6 +322,7 @@ func handleQuickOperation(bot *coolq.CQBot, p resultGetter) coolq.MSG {
|
|||||||
return bot.CQHandleQuickOperation(p.Get("context"), p.Get("operation"))
|
return bot.CQHandleQuickOperation(p.Get("context"), p.Get("operation"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// API 是go-cqhttp当前支持的所有api的映射表
|
||||||
var API = map[string]func(*coolq.CQBot, resultGetter) coolq.MSG{
|
var API = map[string]func(*coolq.CQBot, resultGetter) coolq.MSG{
|
||||||
"get_login_info": getLoginInfo,
|
"get_login_info": getLoginInfo,
|
||||||
"get_friend_list": getFriendList,
|
"get_friend_list": getFriendList,
|
||||||
|
@ -43,6 +43,7 @@ type httpContext struct {
|
|||||||
ctx *gin.Context
|
ctx *gin.Context
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RunHTTPServerAndClients 启动HTTP服务器与HTTP上报客户端
|
||||||
func RunHTTPServerAndClients(bot *coolq.CQBot, conf *config.HTTPServer) {
|
func RunHTTPServerAndClients(bot *coolq.CQBot, conf *config.HTTPServer) {
|
||||||
if conf.Disabled {
|
if conf.Disabled {
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user