Skip to content

Commit

Permalink
增加/help命令
Browse files Browse the repository at this point in the history
  • Loading branch information
nyancatda committed Nov 5, 2021
1 parent 02ea98a commit bce2511
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ Wiki:
```

## 命令
0. 帮助
```
/help
```

1. 查询Wiki
```
Wiki名字:需要查询的内容
Expand All @@ -98,6 +103,7 @@ mw:首页
```
[[首页]]
```

2. 修改语言
*修改只对单个用户生效,默认语言修改请通过配置文件*
```
Expand Down
10 changes: 10 additions & 0 deletions src/Plugin/Command/Command.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,15 @@ func Command(SNSName string, Messagejson Struct.WebHookJson, CommandText string)
}
return LanguageSettings(SNSName, strconv.Itoa(UserID), Language)
}
if find := strings.Contains(CommandText, "help"); find {
var UserID int
switch SNSName {
case "QQ":
UserID = Messagejson.Sender.Id
case "Telegram":
UserID = Messagejson.Message.From.Id
}
return Help(SNSName, strconv.Itoa(UserID))
}
return "", false
}
10 changes: 10 additions & 0 deletions src/Plugin/Command/Help.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package Command

import (
"xyz.nyan/MediaWiki-Bot/src/utils/Language"
)

func Help(SNSName string, UserID string) (string, bool) {
HelpText := Language.Message(SNSName, UserID).HelpText
return HelpText, true
}

0 comments on commit bce2511

Please sign in to comment.