Skip to content

Commit

Permalink
/solve command parse check is at robot
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric committed Mar 1, 2022
1 parent 07cfb65 commit b2d33cb
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import cn.zzq0324.alarm.bot.core.config.AlarmBotProperties;
import cn.zzq0324.alarm.bot.core.constant.CommandConstants;
import cn.zzq0324.alarm.bot.core.constant.Status;
import cn.zzq0324.alarm.bot.core.constant.TaskType;
import cn.zzq0324.alarm.bot.core.entity.Event;
import cn.zzq0324.alarm.bot.core.entity.Message;
Expand Down Expand Up @@ -44,9 +45,13 @@ public class SolveEvent implements Command<SolveEventContext> {
@Override
public CommandContext matchCommand(IMMessage imMessage) {
Message message = imMessage.getMessageList().get(0);
// 解决事件
if (message.getContent().contains(CommandConstants.SOLVE_EVENT)) {
// 解决事件,必须@机器人
if (message.getContent().contains(CommandConstants.SOLVE_EVENT) && imMessage.isAtRobot()) {
Event event = eventService.getByChatGroupId(message.getChatGroupId());
// 找不到事件或者已经标记解决,不重复处理
if (event == null || event.getEventStatus() == Status.FINISH) {
return null;
}

return SolveEventContext.builder().command(CommandConstants.SOLVE_EVENT).message(message).build();
}
Expand Down Expand Up @@ -106,7 +111,7 @@ public boolean execute(SolveEventContext context) {
private void replyAlarmGroupSolved(Event event, String summary) {
String replyMessage = String.format(alarmBotProperties.getReplySolvedToChatGroup(),
DateUtils.getDiffText(event.getCreateTime(), event.getFinishTime()), summary);

ExtensionLoader.getDefaultExtension(PlatformExt.class).replyText(event.getThirdMessageId(), replyMessage);
}

Expand Down

0 comments on commit b2d33cb

Please sign in to comment.