// Path: src/main/java/love/sola/netsupport/config/Settings.java
// public class Settings {
// 
//     public static final int MAX_DESC_LENGTH = 255;
// 
//     public static Settings I;
// 
//     static {
//         I = TableConfig.getSettings();
//     }
// 
//     public String Wechat_AppId;
//     public String Wechat_Secret;
//     public String Wechat_Token;
//     public String Wechat_AesKey;
// 
//     public int Check_Spam_Cache_Expire_Time;
//     public int Check_Spam_Interval;
// 
//     public int User_Session_Max_Inactive;
//     public int User_Wechat_Cache_Expire_Time;
// 
//     //No arg constructor for Yaml.loadAs
//     public Settings() {
//         I = this;
//     }
// 
//     @Override
//     public String toString() {
//         return "Settings{" +
//                 "Wechat_AppId='" + Wechat_AppId + '\'' +
//                 ", Wechat_Secret='" + Wechat_Secret + '\'' +
//                 ", Wechat_Token='" + Wechat_Token + '\'' +
//                 ", Wechat_AesKey='" + Wechat_AesKey + '\'' +
//                 ", Check_Spam_Cache_Expire_Time=" + Check_Spam_Cache_Expire_Time +
//                 ", Check_Spam_Interval=" + Check_Spam_Interval +
//                 ", User_Session_Max_Inactive=" + User_Session_Max_Inactive +
//                 ", User_Wechat_Cache_Expire_Time=" + User_Wechat_Cache_Expire_Time +
//                 '}';
//     }
// }


import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import java.util.concurrent.TimeUnit;
import love.sola.netsupport.config.Settings;
import me.chanjar.weixin.mp.api.WxMpMessageMatcher;
import me.chanjar.weixin.mp.bean.WxMpXmlMessage;
/*
 * This file is part of WechatTicketSystem.
 *
 * WechatTicketSystem is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * WechatTicketSystem is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with WechatTicketSystem.  If not, see <http://www.gnu.org/licenses/>.
 */

package love.sola.netsupport.wechat.matcher;




/**
 * @author Sola {@literal <dev@sola.love>}
 */
public class CheckSpamMatcher implements WxMpMessageMatcher {

    private class ValueLoader extends CacheLoader<String, Long> {
        @Override
        public Long load(String key) throws Exception {
// Path: src/main/java/love/sola/netsupport/config/Settings.java
// public class Settings {
// 
//     public static final int MAX_DESC_LENGTH = 255;
// 
//     public static Settings I;
// 
//     static {
//         I = TableConfig.getSettings();
//     }
// 
//     public String Wechat_AppId;
//     public String Wechat_Secret;
//     public String Wechat_Token;
//     public String Wechat_AesKey;
// 
//     public int Check_Spam_Cache_Expire_Time;
//     public int Check_Spam_Interval;
// 
//     public int User_Session_Max_Inactive;
//     public int User_Wechat_Cache_Expire_Time;
// 
//     //No arg constructor for Yaml.loadAs
//     public Settings() {
//         I = this;
//     }
// 
//     @Override
//     public String toString() {
//         return "Settings{" +
//                 "Wechat_AppId='" + Wechat_AppId + '\'' +
//                 ", Wechat_Secret='" + Wechat_Secret + '\'' +
//                 ", Wechat_Token='" + Wechat_Token + '\'' +
//                 ", Wechat_AesKey='" + Wechat_AesKey + '\'' +
//                 ", Check_Spam_Cache_Expire_Time=" + Check_Spam_Cache_Expire_Time +
//                 ", Check_Spam_Interval=" + Check_Spam_Interval +
//                 ", User_Session_Max_Inactive=" + User_Session_Max_Inactive +
//                 ", User_Wechat_Cache_Expire_Time=" + User_Wechat_Cache_Expire_Time +
//                 '}';
//     }
// }


// Path: src/main/java/love/sola/netsupport/wechat/matcher/CheckSpamMatcher.java
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import java.util.concurrent.TimeUnit;
import love.sola.netsupport.config.Settings;
import me.chanjar.weixin.mp.api.WxMpMessageMatcher;
import me.chanjar.weixin.mp.bean.WxMpXmlMessage;

/*
 * This file is part of WechatTicketSystem.
 *
 * WechatTicketSystem is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * WechatTicketSystem is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with WechatTicketSystem.  If not, see <http://www.gnu.org/licenses/>.
 */

package love.sola.netsupport.wechat.matcher;




/**
 * @author Sola {@literal <dev@sola.love>}
 */
public class CheckSpamMatcher implements WxMpMessageMatcher {

    private class ValueLoader extends CacheLoader<String, Long> {
        @Override
        public Long load(String key) throws Exception {
            return System.currentTimeMillis() + Settings.I.Check_Spam_Interval;