package com.mtz.qqbot.Listener;

import net.itbaima.robot.event.RobotListener;
import net.itbaima.robot.event.RobotListenerHandler;
import net.mamoe.mirai.event.events.FriendMessageEvent;
import net.mamoe.mirai.event.events.GroupMessageEvent;
import net.mamoe.mirai.event.events.GroupTempMessageEvent;

@RobotListener
public class HandleMessageListener {
    public static int friendMessageCount = 0;
    public static int group1MessageCount = 0;
    public static int group2MessageCount = 0;
    public static int groupTempMessageCount = 0;


    @RobotListenerHandler//接收来自好友的消息，打印到控制台
    public void handleFriendMessage(FriendMessageEvent event) {
        String message = event.getMessage().contentToString();
        System.out.println("来自" + event.getSenderName() + "的消息：" + message);
        friendMessageCount++;
    }

    public void handleGroupMessage(GroupMessageEvent event) {//接收来自群聊的消息，打印到控制台
        String message = event.getMessage().contentToString();
        System.out.println(event.getGroup() + "“" + event.getSenderName() + "”的群聊消息：" + message);
    }

    @RobotListenerHandler(contactId = 518909220)
    public void handleGroup1Message(GroupMessageEvent event) {
        handleGroupMessage(event);
        group1MessageCount++;
    }

    @RobotListenerHandler(contactId = 1033597003)
    public void handleGroup2Message(GroupMessageEvent event) {
        handleGroupMessage(event);
        group2MessageCount++;
    }

    @RobotListenerHandler
    public void handleGroupTempMessage(GroupTempMessageEvent event) {
        String message = event.getMessage().contentToString();
        System.out.println("来自群聊：" + event.getGroup() + "“" + event.getSenderName() + "”的临时对话：" + message);
        groupTempMessageCount++;
    }
}
