作者 邓超

x

@@ -51,6 +51,10 @@ class AutoMail { @@ -51,6 +51,10 @@ class AutoMail {
51 ]; 51 ];
52 },$filter[0]); 52 },$filter[0]);
53 53
  54 + if($this->filter){
  55 + redis()->set('ai_email_filter_lists',$this->filter,86400);
  56 + }
  57 +
54 58
55 if(redis()->add('auto_mail_sync2',1,60)){ 59 if(redis()->add('auto_mail_sync2',1,60)){
56 echo '正在计算数据'; 60 echo '正在计算数据';
@@ -105,7 +105,10 @@ class SyncMail { @@ -105,7 +105,10 @@ class SyncMail {
105 * @time 2024/9/12 15:29 105 * @time 2024/9/12 15:29
106 */ 106 */
107 private function auto_mail($id,$data){ 107 private function auto_mail($id,$data){
108 - $filter = '2 Automatic reply 108 +
  109 + $filter = redis()->get('ai_email_filter_lists',[]);
  110 + if(!$filter || !is_array($filter)){
  111 + $filter = '2 Automatic reply
109 2 Delivery 112 2 Delivery
110 2 Automatische Antwort 113 2 Automatische Antwort
111 2 Undeliverable 114 2 Undeliverable
@@ -133,14 +136,22 @@ class SyncMail { @@ -133,14 +136,22 @@ class SyncMail {
133 2 Automatyczna 136 2 Automatyczna
134 2 代开 137 2 代开
135 2 expired'; 138 2 expired';
136 - $filter = explode("\n",$filter); 139 + $filter = explode("\n",$filter);
  140 + $filter = array_map(function ($v){
  141 + list($t,$str) = [
  142 + intval(mb_substr($v,0,1)),
  143 + trim(mb_substr($v,1,99)),
  144 + ];
  145 + return [$t,$str];
  146 + },$filter);
  147 + }
137 148
138 foreach ($filter as $f){ 149 foreach ($filter as $f){
139 - if(!$f) continue;  
140 - list($t,$str) = [  
141 - intval(mb_substr($f,0,1)),  
142 - trim(mb_substr($f,1,99)),  
143 - ]; 150 +
  151 + $t = $f[0]??''; // 类型
  152 + $str = $f[1]??''; // 值
  153 + if(!$str) continue;
  154 +
144 $haystack = ''; 155 $haystack = '';
145 if($t==2){ 156 if($t==2){
146 $haystack = $data['subject']; 157 $haystack = $data['subject'];
@@ -148,9 +159,9 @@ class SyncMail { @@ -148,9 +159,9 @@ class SyncMail {
148 $haystack = $data['from']; 159 $haystack = $data['from'];
149 } 160 }
150 if(stripos($haystack,$str)!==false){ 161 if(stripos($haystack,$str)!==false){
151 - if(!$this->db->count("select count(*) from `lists_auto` where `list_id` = ".$id)){ 162 + try {
152 $this->db->create('lists_auto',['list_id'=>$id],false); 163 $this->db->create('lists_auto',['list_id'=>$id],false);
153 - } 164 + }catch (\Throwable $e){}
154 break; 165 break;
155 } 166 }
156 } 167 }