Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 添加内置gocq #1123

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions api/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func ImConnectionsRWSignServerUrl(c echo.Context) error {
}
if i.ProtocolType == "onebot" {
pa := i.Adapter.(*dice.PlatformAdapterGocq)
if pa.BuiltinMode == "lagrange" {
if pa.BuiltinMode == "lagrange" || pa.BuiltinMode == "lagrange-gocq" {
signServerUrl, signServerVersion := dice.RWLagrangeSignServerUrl(myDice, i, v.SignServerUrl, v.W, v.SignServerVersion)
if signServerUrl != "" {
return Success(&c, Response{
Expand Down Expand Up @@ -207,7 +207,7 @@ func ImConnectionsDel(c echo.Context) error {
myDice.ImSession.EndPoints = append(myDice.ImSession.EndPoints[:index], myDice.ImSession.EndPoints[index+1:]...)
if i.ProtocolType == "onebot" {
pa := i.Adapter.(*dice.PlatformAdapterGocq)
if pa.BuiltinMode == "lagrange" {
if pa.BuiltinMode == "lagrange" || pa.BuiltinMode == "lagrange-gocq" {
dice.BuiltinQQServeProcessKillBase(myDice, i, true)
// 经测试,若不延时,可能导致清理对应目录失败(原因:文件被占用)
time.Sleep(1 * time.Second)
Expand Down Expand Up @@ -969,6 +969,7 @@ func ImConnectionsAddBuiltinLagrange(c echo.Context) error {
Account string `yaml:"account" json:"account"`
SignServerUrl string `yaml:"signServerUrl" json:"signServerUrl"`
SignServerVersion string `yaml:"signServerVersion" json:"signServerVersion"`
IsGocq bool `yaml:"isGocq" json:"isGocq"`
}{}
err := c.Bind(&v)
if err == nil {
Expand All @@ -977,7 +978,7 @@ func ImConnectionsAddBuiltinLagrange(c echo.Context) error {
return nil
}

conn := dice.NewLagrangeConnectInfoItem(v.Account)
conn := dice.NewLagrangeConnectInfoItem(v.Account, v.IsGocq)
conn.UserID = dice.FormatDiceIDQQ(uid)
conn.Session = myDice.ImSession
pa := conn.Adapter.(*dice.PlatformAdapterGocq)
Expand Down
2 changes: 2 additions & 0 deletions api/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ func checkUidExists(c echo.Context, uid string) bool {
var relWorkDir string
if pa.BuiltinMode == "lagrange" {
relWorkDir = "extra/lagrange-qq" + uid
} else if pa.BuiltinMode == "lagrange-gocq" {
relWorkDir = "extra/lagrange-gocq-qq" + uid
} else {
// 默认为gocq
relWorkDir = "extra/go-cqhttp-qq" + uid
Expand Down
6 changes: 3 additions & 3 deletions dice/platform_adapter_gocq.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ func (pa *PlatformAdapterGocq) SendSegmentToPerson(ctx *MsgContext, userID strin
}

func (pa *PlatformAdapterGocq) Serve() int {
if pa.BuiltinMode == "lagrange" {
if pa.BuiltinMode == "lagrange" || pa.BuiltinMode == "lagrange-gocq" {
pa.Implementation = "lagrange"
} else {
pa.Implementation = "gocq"
Expand Down Expand Up @@ -1221,7 +1221,7 @@ func (pa *PlatformAdapterGocq) DoRelogin() bool {
if pa.InPackGoCqhttpDisconnectedCH != nil {
pa.InPackGoCqhttpDisconnectedCH <- -1
}
if pa.BuiltinMode == "lagrange" {
if pa.BuiltinMode == "lagrange" || pa.BuiltinMode == "lagrange-gocq" {
myDice.Logger.Infof("重新启动 lagrange 进程,对应账号: <%s>(%s)", ep.Nickname, ep.UserID)
pa.CurLoginIndex++
pa.GoCqhttpState = StateCodeInit
Expand Down Expand Up @@ -1268,7 +1268,7 @@ func (pa *PlatformAdapterGocq) SetEnable(enable bool) {
c.Enable = true

if pa.UseInPackClient {
if pa.BuiltinMode == "lagrange" {
if pa.BuiltinMode == "lagrange" || pa.BuiltinMode == "lagrange-gocq" {
BuiltinQQServeProcessKill(d, c)
time.Sleep(1 * time.Second)
LagrangeServe(d, c, LagrangeLoginInfo{
Expand Down
Loading