Skip to content

Commit

Permalink
update to new template
Browse files Browse the repository at this point in the history
  • Loading branch information
Sora233 committed Mar 31, 2022
1 parent 0c228d4 commit 4a09ed8
Show file tree
Hide file tree
Showing 31 changed files with 471 additions and 1,320 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ DDBOT
/qrcode.png
/qq-logs
/session.token
/dist/
/dist/
/template
24 changes: 23 additions & 1 deletion cmd/play.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
package main

func play() {
import (
"fmt"
"github.com/Sora233/DDBOT/lsp/mmsg"
"github.com/Sora233/DDBOT/lsp/template"
"github.com/Sora233/DDBOT/utils/msgstringer"
"github.com/sirupsen/logrus"
"time"
)

func play() {
logrus.SetLevel(logrus.DebugLevel)
template.InitTemplateLoader()
for {
t := template.LoadTemplate("command.private.help.tmpl")
if t == nil {
panic("t is nil")
}
m := mmsg.NewMSG()
if err := t.ExecuteTemplate(m, "command.private.help.tmpl", nil); err != nil {
panic(err)
}
fmt.Println(msgstringer.MsgToString(m.Elements()))
time.Sleep(time.Second * 3)
}
}
2 changes: 1 addition & 1 deletion lsp/cfg/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

func GetCommandPrefix() string {
if config.GlobalConfig == nil {
return ""
return "/"
}
prefix := strings.TrimSpace(config.GlobalConfig.GetString("bot.commandPrefix"))
if len(prefix) == 0 {
Expand Down
9 changes: 5 additions & 4 deletions lsp/groupCommand.go
Original file line number Diff line number Diff line change
Expand Up @@ -837,12 +837,13 @@ func (lgc *LspGroupCommand) HelpCommand() {
if lgc.exit {
return
}

msgs, err := template.YAMLRenderByKey("template.command.public.help", nil)
m, err := template.LoadAndExec("command.group.help", nil)
if err != nil {
lgc.textReplyF("错误 - %v", err.Error())
logger.Errorf("LoadAndExec error %v", err)
lgc.textReply(fmt.Sprintf("错误 - %v", err))
return
}
lgc.sendChain(msgs)
lgc.sendChain(m)
}

func (lgc *LspGroupCommand) DefaultLogger() *logrus.Entry {
Expand Down
16 changes: 16 additions & 0 deletions lsp/mmsg/cut.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package mmsg

import (
"github.com/Mrs4s/MiraiGo/message"
)

type CutElement struct {
}

func (c *CutElement) Type() message.ElementType {
return Cut
}

func (c *CutElement) PackToElement(Target) message.IMessageElement {
return nil
}

0 comments on commit 4a09ed8

Please sign in to comment.