-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4ca9810
Showing
65 changed files
with
11,812 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Yui |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
httpproxy: http://127.0.0.1:7890 # 插件 HTTP 服务时会使用的 Proxy | ||
opqurl: http://127.0.0.1:8086 # OPQ 的地址 | ||
admin: | ||
- 2435932516 # 管理员 | ||
plugin: | ||
env: | ||
test: opqbot # 环境变量 将会传递到插件内 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package config | ||
|
||
import ( | ||
"github.com/charmbracelet/log" | ||
"github.com/spf13/viper" | ||
) | ||
|
||
func init() { | ||
viper.SetConfigFile("config.yaml") | ||
err := viper.ReadInConfig() // 搜索并读取配置文件 | ||
if err != nil { // 处理错误 | ||
log.Fatalf("没有配置文件呢?: %s \n", err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package cron | ||
|
||
import "github.com/robfig/cron/v3" | ||
|
||
var ( | ||
C = cron.New() | ||
) | ||
|
||
func init() { | ||
C.Start() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package main | ||
|
||
//go:generate protoc --go-plugin_out=. --go-plugin_opt=paths=source_relative proto/opq.proto | ||
//go:generate go run proto/generate/generate.go | ||
//go:generate protoc --go-plugin_out=. --go-plugin_opt=paths=source_relative proto/library/systemInfo/export/systemInfo.proto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
module Yui | ||
|
||
go 1.19 | ||
|
||
require ( | ||
github.com/charmbracelet/log v0.2.1 | ||
github.com/ethereum/go-ethereum v1.11.6 | ||
github.com/fogleman/gg v1.3.0 | ||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 | ||
github.com/google/uuid v1.3.0 | ||
github.com/imroc/req/v3 v3.33.2 | ||
github.com/knqyf263/go-plugin v0.7.1-0.20230420183704-82cf9090ca1e | ||
github.com/mailru/easyjson v0.7.7 | ||
github.com/mcoo/OPQBot v0.2.2-0.20230415115049-02b00e2cf9e1 | ||
github.com/opq-osc/OPQBot/v2 v2.0.0-20230427091225-f73faded2e3b | ||
github.com/robfig/cron/v3 v3.0.1 | ||
github.com/shirou/gopsutil/v3 v3.23.3 | ||
github.com/spf13/cast v1.5.0 | ||
github.com/spf13/cobra v1.7.0 | ||
github.com/spf13/viper v1.15.0 | ||
github.com/tetratelabs/wazero v1.0.3 | ||
github.com/tidwall/gjson v1.14.4 | ||
golang.org/x/image v0.0.0-20190802002840-cff245a6509b | ||
golang.org/x/tools v0.8.0 | ||
google.golang.org/protobuf v1.30.0 | ||
) | ||
|
||
require ( | ||
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect | ||
github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect | ||
github.com/charmbracelet/lipgloss v0.7.1 // indirect | ||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect | ||
github.com/fsnotify/fsnotify v1.6.0 // indirect | ||
github.com/go-logfmt/logfmt v0.6.0 // indirect | ||
github.com/go-ole/go-ole v1.2.6 // indirect | ||
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect | ||
github.com/golang/mock v1.6.0 // indirect | ||
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 // indirect | ||
github.com/gorilla/websocket v1.5.0 // indirect | ||
github.com/hashicorp/errwrap v1.1.0 // indirect | ||
github.com/hashicorp/go-multierror v1.1.1 // indirect | ||
github.com/hashicorp/hcl v1.0.0 // indirect | ||
github.com/holiman/uint256 v1.2.2-0.20230321075855-87b91420868c // indirect | ||
github.com/inconshreveable/mousetrap v1.1.0 // indirect | ||
github.com/josharian/intern v1.0.0 // indirect | ||
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect | ||
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect | ||
github.com/magiconair/properties v1.8.7 // indirect | ||
github.com/makiuchi-d/gozxing v0.1.1 // indirect | ||
github.com/mattn/go-isatty v0.0.18 // indirect | ||
github.com/mattn/go-runewidth v0.0.14 // indirect | ||
github.com/mdp/qrterminal/v3 v3.0.0 // indirect | ||
github.com/mitchellh/mapstructure v1.5.0 // indirect | ||
github.com/muesli/reflow v0.3.0 // indirect | ||
github.com/muesli/termenv v0.15.1 // indirect | ||
github.com/onsi/ginkgo/v2 v2.2.0 // indirect | ||
github.com/pelletier/go-toml/v2 v2.0.6 // indirect | ||
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect | ||
github.com/quic-go/qpack v0.4.0 // indirect | ||
github.com/quic-go/qtls-go1-18 v0.2.0 // indirect | ||
github.com/quic-go/qtls-go1-19 v0.2.0 // indirect | ||
github.com/quic-go/qtls-go1-20 v0.1.0 // indirect | ||
github.com/quic-go/quic-go v0.32.0 // indirect | ||
github.com/rivo/uniseg v0.2.0 // indirect | ||
github.com/rotisserie/eris v0.5.4 // indirect | ||
github.com/spf13/afero v1.9.3 // indirect | ||
github.com/spf13/jwalterweatherman v1.1.0 // indirect | ||
github.com/spf13/pflag v1.0.5 // indirect | ||
github.com/subosito/gotenv v1.4.2 // indirect | ||
github.com/tidwall/match v1.1.1 // indirect | ||
github.com/tidwall/pretty v1.2.1 // indirect | ||
github.com/tklauser/go-sysconf v0.3.11 // indirect | ||
github.com/tklauser/numcpus v0.6.0 // indirect | ||
github.com/yusufpapurcu/wmi v1.2.2 // indirect | ||
golang.org/x/crypto v0.4.0 // indirect | ||
golang.org/x/exp v0.0.0-20230206171751-46f607a40771 // indirect | ||
golang.org/x/mod v0.10.0 // indirect | ||
golang.org/x/net v0.9.0 // indirect | ||
golang.org/x/sys v0.7.0 // indirect | ||
golang.org/x/text v0.9.0 // indirect | ||
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect | ||
gopkg.in/ini.v1 v1.67.0 // indirect | ||
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
rsc.io/qr v0.2.0 // indirect | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package main | ||
|
||
import ( | ||
_ "Yui/config" | ||
"Yui/cron" | ||
"Yui/opq" | ||
"Yui/plugin" | ||
"context" | ||
"github.com/charmbracelet/log" | ||
"github.com/spf13/viper" | ||
) | ||
|
||
var ( | ||
version = "v0.0.1" | ||
commit = "xxxxxxxxxxxxxxx" | ||
) | ||
|
||
func main() { | ||
log.Infof("Yui 欢迎使用 Version:%s (commit:%s)", version, commit) | ||
if v := viper.Get("logLevel"); v != nil { | ||
log.SetLevel(log.Level(v.(int))) | ||
} | ||
err := opq.C.ListenAndWait(context.Background()) | ||
if err != nil { | ||
log.Error(err) | ||
} | ||
plugin.M.CloseAllPlugin(context.Background()) | ||
cron.C.Stop() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package opq | ||
|
||
import ( | ||
"github.com/charmbracelet/log" | ||
"github.com/opq-osc/OPQBot/v2" | ||
"github.com/spf13/viper" | ||
) | ||
|
||
var C *OPQBot.Core | ||
|
||
var Url = viper.GetString("opqUrl") | ||
|
||
func init() { | ||
var err error | ||
C, err = OPQBot.NewCore(Url) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
//go:build tinygo.wasm | ||
|
||
package S | ||
|
||
import ( | ||
"Yui/proto" | ||
"context" | ||
"github.com/opq-osc/OPQBot/v2/events" | ||
) | ||
|
||
func LogInfo(ctx context.Context, msg string) { | ||
proto.NewApi().Log(ctx, &proto.LogReq{ | ||
LogType: proto.LogType_Info, | ||
Msg: msg, | ||
}) | ||
} | ||
func LogError(ctx context.Context, msg string) { | ||
proto.NewApi().Log(ctx, &proto.LogReq{ | ||
LogType: proto.LogType_Error, | ||
Msg: msg, | ||
}) | ||
} | ||
func LogWarn(ctx context.Context, msg string) { | ||
proto.NewApi().Log(ctx, &proto.LogReq{ | ||
LogType: proto.LogType_Warn, | ||
Msg: msg, | ||
}) | ||
} | ||
func LogDebug(ctx context.Context, msg string) { | ||
proto.NewApi().Log(ctx, &proto.LogReq{ | ||
LogType: proto.LogType_Debug, | ||
Msg: msg, | ||
}) | ||
} | ||
func HttpGet(ctx context.Context, url string, header map[string]string) (*proto.HttpRes, error) { | ||
return proto.NewApi().Http(ctx, &proto.HttpReq{ | ||
Url: url, | ||
Method: proto.HttpMethod_GET, | ||
Header: header, | ||
Content: nil, | ||
}) | ||
} | ||
func HttpPost(ctx context.Context, url string, header map[string]string, body []byte) (*proto.HttpRes, error) { | ||
return proto.NewApi().Http(ctx, &proto.HttpReq{ | ||
Url: url, | ||
Method: proto.HttpMethod_POST, | ||
Header: header, | ||
Content: body, | ||
}) | ||
} | ||
func SendGroupTextMsg(ctx context.Context, toUin, botUin int64, text string) (*proto.SendReply, error) { | ||
return proto.NewApi().SendGroupMsg(ctx, &proto.MsgReq{ | ||
ToUin: toUin, | ||
Msg: &proto.MsgReq_TextMsg{TextMsg: &proto.TextMsg{Text: text}}, | ||
BotUin: botUin, | ||
}) | ||
} | ||
func ParserEvent(rawMessage []byte) (events.IEvent, error) { | ||
var event = &events.EventStruct{} | ||
err := event.UnmarshalJSON(rawMessage) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return event, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
//go:build !tinygo.wasm | ||
|
||
package S | ||
|
||
import ( | ||
"Yui/opq" | ||
"github.com/opq-osc/OPQBot/v2/apiBuilder" | ||
"github.com/opq-osc/OPQBot/v2/events" | ||
) | ||
|
||
func GetApi(event events.IEvent) apiBuilder.IMainFunc { | ||
return apiBuilder.New(opq.Url, event.GetCurrentQQ()) | ||
} |
Oops, something went wrong.