Skip to content

Commit

Permalink
通知类消息不自动撤回
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyl18 committed Sep 5, 2021
1 parent 7a3844b commit b5d69ef
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
12 changes: 9 additions & 3 deletions Connectors/MiraiHTTPConnector/Connector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,17 @@ public override void Init()

public override void SendGroupMessage(GroupID groupID, string message)
{
const string NotificationHead = "[WFBot通知] ";
var isNotification = message.StartsWith(NotificationHead);
if (isNotification)
{
message = message.Substring(NotificationHead.Length);
}
var msgID = session.SendGroupMessageAsync(groupID, new PlainMessage(message)).Result;

if (MiraiConfigInMain.Instance.AutoRevoke)
if (MiraiConfig.Instance.AutoRevoke && !isNotification)
{
var time = MiraiConfigInMain.Instance.RevokeTimeInSeconds;
var time = MiraiConfig.Instance.RevokeTimeInSeconds;
var tr = time < 1000 ? time * 1000 : time;
Task.Delay(tr)
.ContinueWith((t) => { session.RevokeMessageAsync(msgID); });
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
[**🐳Docker 部署**](docs/docker.md)

[**🟦普通部署指南**](docs/install.md)
[**🐧来自社区的 Linux 部署指南**](https://github.com/Wapriaily/WFBot/blob/patch-1/docs/Liunx-install.md)
[**🐧来自社区的 Linux 部署指南**](https://github.com/Wapriaily/WFBot/blob/wapriaily/docs/Liunx-install.md)

---

Expand Down
13 changes: 9 additions & 4 deletions WFBot/Connector/ConnectorManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,18 @@ public override void Init()
};
session.ConnectAsync(options, qq).Wait();
}

public override void SendGroupMessage(GroupID groupID, string message)
{
const string NotificationHead = "[WFBot通知] ";
var isNotification = message.StartsWith(NotificationHead);
if (isNotification)
{
message = message.Substring(NotificationHead.Length);
}
var msgID = session.SendGroupMessageAsync(groupID, new PlainMessage(message)).Result;
if (MiraiConfigInMain.Instance.AutoRevoke)

if (MiraiConfigInMain.Instance.AutoRevoke && !isNotification)
{
var time = MiraiConfigInMain.Instance.RevokeTimeInSeconds;
var tr = time < 1000 ? time * 1000 : time;
Expand All @@ -116,8 +123,6 @@ public override void SendGroupMessage(GroupID groupID, string message)
}
}



public override void SendPrivateMessage(UserID userID, string message)
{
session.SendFriendMessageAsync(userID, new PlainMessage(message)).Wait();
Expand Down
1 change: 1 addition & 0 deletions WFBot/Features/Utils/Messenger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public static void Broadcast(string content)
if (count > 20 && content.StartsWith("机器人开始了自动更新")) return;

var sb = new StringBuilder();
sb.Append("[WFBot通知] ");
sb.AppendLine(content);
if (count > 10) sb.AppendLine($"发送次序: {count}(与真实延迟了{7 * count}秒)");
sb.AppendLine($"如果想要获取更好的体验,请自行部署.");
Expand Down

0 comments on commit b5d69ef

Please sign in to comment.