All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.biezhi.wechat.api.model.Invoke Maven / Gradle / Ivy

There is a newer version: 1.0.6
Show newest version
package io.github.biezhi.wechat.api.model;

import io.github.biezhi.wechat.WeChatBot;
import io.github.biezhi.wechat.api.enums.AccountType;
import io.github.biezhi.wechat.exception.WeChatException;
import lombok.AllArgsConstructor;
import lombok.Data;

import java.lang.reflect.Method;
import java.util.List;

/**
 * 消息执行器
 *
 * @author biezhi
 * @date 2018/1/20
 */
@Data
@AllArgsConstructor
public class Invoke {

    private Method            method;
    private List accountTypes;

    /**
     * 回调给客户端
     *
     * @param bot
     * @param message
     * @param 
     */
    public  void call(T bot, WeChatMessage message) {
        AccountType accountType = bot.api().getAccountById(message.getFromUserName()).getAccountType();
        if (accountTypes.contains(accountType)) {
            try {
                method.invoke(bot, message);
            } catch (Exception e) {
                throw new WeChatException(e);
            }
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy