Skip to content

Commit

Permalink
Merge branch 'master' into feat_dnd_multi_rc
Browse files Browse the repository at this point in the history
  • Loading branch information
PaienNate authored Dec 3, 2024
2 parents bb4a97e + 6aaa1f0 commit 3ec265b
Show file tree
Hide file tree
Showing 6 changed files with 213 additions and 78 deletions.
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
5 changes: 4 additions & 1 deletion dice/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2335,7 +2335,10 @@ func (d *Dice) loads() {
} else {
d.Logger.Info("serve.yaml not found")
// 这里是没有加载到配置文件,所以写默认设置项
d.DiceMasters = []string{"UI:1001"}
d.DeckList = config.DeckList
d.CommandPrefix = config.CommandPrefix
d.DiceMasters = config.DiceMasters
d.Config = config
}

_ = model.BanItemList(d.DBData, func(id string, banUpdatedAt int64, data []byte) {
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

0 comments on commit 3ec265b

Please sign in to comment.