Skip to content

Commit

Permalink
fix(plugins/moliplugin/): error:前缀字符被加入发送给茉莉api
Browse files Browse the repository at this point in the history
  • Loading branch information
yiyungent committed Jan 23, 2023
1 parent ad3ac98 commit 22c765b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
11 changes: 11 additions & 0 deletions plugins/MoLiPlugin/MoLiPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ public void OnGroupMessage((Bot s, GroupMessageEvent e) obj, string message, str
try
{
string text = ConvertToString(obj.e.Chain);
if (!string.IsNullOrEmpty(settingsModel.Prefix) && !message.Trim().StartsWith(settingsModel.Prefix))
{
// 移除前缀
text = text.Substring(settingsModel.Prefix.Length);
}
resModel = Utils.MoLiApiUtil.Reply(new MoLiApiRequestModel
{
content = text,
Expand Down Expand Up @@ -103,6 +108,11 @@ public void OnFriendMessage((Bot s, FriendMessageEvent e) obj, string message, u
try
{
string text = ConvertToString(obj.e.Chain);
if (!string.IsNullOrEmpty(settingsModel.Prefix) && !message.Trim().StartsWith(settingsModel.Prefix))
{
// 移除前缀
text = text.Substring(settingsModel.Prefix.Length);
}
resModel = Utils.MoLiApiUtil.Reply(new MoLiApiRequestModel
{
content = text,
Expand Down Expand Up @@ -140,6 +150,7 @@ private string ConvertToString(MessageChain chains)
switch (item.Type)
{
case BaseChain.ChainType.At:
// 注意: 这里不要 at, 否则发送给茉莉时还需要去除
break;
case BaseChain.ChainType.Reply:
break;
Expand Down
4 changes: 4 additions & 0 deletions plugins/MoLiPlugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@




<!-- Matomo Image Tracker-->
<img referrerpolicy="no-referrer-when-downgrade" src="https://matomo.moeci.com/matomo.php?idsite=2&amp;rec=1&amp;action_name=Plugins.MoLiPlugin.README" style="border:0" alt="" />
<!-- End Matomo -->
2 changes: 1 addition & 1 deletion plugins/MoLiPlugin/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"DisplayName": "茉莉机器人",
"Description": "对接 茉莉 API",
"Author": "yiyun",
"Version": "1.0.0",
"Version": "1.0.1",
"SupportedVersions": [ "0.0.1" ]
}

0 comments on commit 22c765b

Please sign in to comment.