package com.yutou.qqbot.Listeners;

import com.yutou.qqbot.MessageEvent.AdminMessage;
import com.yutou.qqbot.QQNumberManager;
import com.yutou.qqbot.models.Model;
import kotlin.coroutines.CoroutineContext;

import org.jetbrains.annotations.NotNull;

public class QQMessageListener  {


    public void handleException(@NotNull CoroutineContext context, @NotNull Throwable exception) {
        //    super.handleException(context, exception);
        exception.printStackTrace();
    }

    public void onMessage() {
       /* long qqNumber;
        boolean isGroup;
        if (event instanceof GroupMessageEvent) {
            qqNumber = ((GroupMessageEvent) event).getGroup().getId();
            isGroup = true;
        } else {
            isGroup = false;
            qqNumber = event.getSource().getFromId();
        }
        QQNumberManager.getManager().addNumber(qqNumber, isGroup);
        if (event.getSource().getFromId() == 583819556) {
            new AdminMessage(qqNumber, event.getMessage().contentToString());
        }
        for (Class<?> model : Model.classList) {
            if (QQNumberManager.getManager().isUseModel(qqNumber, model)||!isGroup) {
                try {
                    Model useModel = (Model) model.getDeclaredConstructor().newInstance();
                    if (!useModel.isUserPublic()) {
                        if (!QQNumberManager.getManager().isExistsPower(event.getSource().getFromId(), useModel.getUsePowers())) {
                            continue;
                        }
                    }
                    useModel.onMessage(qqNumber, event, isGroup);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }

        return ListeningStatus.LISTENING; // 表示继续监听事件*/

    }


}
