正在显示
1 个修改的文件
包含
10 行增加
和
51 行删除
| @@ -63,36 +63,10 @@ class fob_hot_ai_mail_auto_reply { | @@ -63,36 +63,10 @@ class fob_hot_ai_mail_auto_reply { | ||
| 63 | 63 | ||
| 64 | protected $bodys = []; | 64 | protected $bodys = []; |
| 65 | 65 | ||
| 66 | - public function getDelayTime(){ | ||
| 67 | - /** | ||
| 68 | - * 随机一个延时时间秒 极小的概率30-60分钟,小概率60-120分钟,中概率120-180分钟 大概率180-240分钟 | ||
| 69 | - */ | ||
| 70 | - | ||
| 71 | -// 生成一个 0 到 100 之间的随机数 | ||
| 72 | - $randomValue = rand(0, 100); | ||
| 73 | - | ||
| 74 | - // 根据随机值的范围来决定延迟时间 | ||
| 75 | - if ($randomValue < 5) { // 5% 的概率 | ||
| 76 | - // 随机 30-60分钟 | ||
| 77 | - $rand = rand(45, 60) * 60; // 转换为秒 | ||
| 78 | - } elseif ($randomValue < 15) { // 10% 的概率 (5% + 10%) | ||
| 79 | - // 随机 60-120分钟 | ||
| 80 | - $rand = rand(65, 120) * 60; // 转换为秒 | ||
| 81 | - } elseif ($randomValue < 45) { // 30% 的概率 (15% + 30%) | ||
| 82 | - // 随机 120-180分钟 | ||
| 83 | - $rand = rand(125, 180) * 60; // 转换为秒 | ||
| 84 | - } else { // 55% 的概率 (45% + 55%) | ||
| 85 | - // 随机 180-240分钟 | ||
| 86 | - $rand = rand(180, 240) * 60; // 转换为秒 | ||
| 87 | - } | ||
| 88 | - | ||
| 89 | - return time()+$rand; | ||
| 90 | - } | ||
| 91 | - | ||
| 92 | public function handler(){ | 66 | public function handler(){ |
| 93 | 67 | ||
| 94 | - $this->bodys = file_get_contents(__DIR__."/body.reply"); | ||
| 95 | - $this->bodys = explode("--------------",$this->bodys); | 68 | +// $this->bodys = file_get_contents(__DIR__."/body.reply"); |
| 69 | +// $this->bodys = explode("--------------",$this->bodys); | ||
| 96 | 70 | ||
| 97 | while (!$this->isStop()){ | 71 | while (!$this->isStop()){ |
| 98 | 72 | ||
| @@ -100,10 +74,6 @@ class fob_hot_ai_mail_auto_reply { | @@ -100,10 +74,6 @@ class fob_hot_ai_mail_auto_reply { | ||
| 100 | if($id){ | 74 | if($id){ |
| 101 | // 检查是否到时间了 | 75 | // 检查是否到时间了 |
| 102 | list($did,$time) = explode('.',((string) $id).'.0'); | 76 | list($did,$time) = explode('.',((string) $id).'.0'); |
| 103 | - if($time == '0'){ | ||
| 104 | - redis()->rPush('new_hot_mail_auto_reply_ids',$id.'.'.$this->getDelayTime()); | ||
| 105 | - continue; | ||
| 106 | - } | ||
| 107 | 77 | ||
| 108 | $h = (int) date('H'); | 78 | $h = (int) date('H'); |
| 109 | if($h >= 23 || $h < 6 ){ | 79 | if($h >= 23 || $h < 6 ){ |
| @@ -111,13 +81,6 @@ class fob_hot_ai_mail_auto_reply { | @@ -111,13 +81,6 @@ class fob_hot_ai_mail_auto_reply { | ||
| 111 | continue; | 81 | continue; |
| 112 | } | 82 | } |
| 113 | 83 | ||
| 114 | - | ||
| 115 | - if($time > time()){ | ||
| 116 | - redis()->rPush('new_hot_mail_auto_reply_ids',$id); | ||
| 117 | - usleep(10000); | ||
| 118 | - // echo $did." ".date("Y-m-d H:i:s",$time)." 时间未到 \n"; | ||
| 119 | - continue; | ||
| 120 | - } | ||
| 121 | // 查询数据 | 84 | // 查询数据 |
| 122 | $data = $this->db->first(\Model\listsSql::first('`id` = '.$did,'`id`,`to`,`folder_id`,`email_id`,`subject`,`is_hots`,`from`,`udate`,`uid`')); | 85 | $data = $this->db->first(\Model\listsSql::first('`id` = '.$did,'`id`,`to`,`folder_id`,`email_id`,`subject`,`is_hots`,`from`,`udate`,`uid`')); |
| 123 | if($data && $data['is_hots']){ | 86 | if($data && $data['is_hots']){ |
| @@ -130,7 +93,7 @@ class fob_hot_ai_mail_auto_reply { | @@ -130,7 +93,7 @@ class fob_hot_ai_mail_auto_reply { | ||
| 130 | if($this->db->count(sprintf("select count(*) from `hot_mail` where `email` = '%s'",$email['email']))){ | 93 | if($this->db->count(sprintf("select count(*) from `hot_mail` where `email` = '%s'",$email['email']))){ |
| 131 | 94 | ||
| 132 | // 验证邮箱状态 | 95 | // 验证邮箱状态 |
| 133 | - $fobemail = fob_mysql()->cache(300)->first("select `status`,`is_send_mail` from `e_mail_binds` where `email_id` = ".$data['email_id']); | 96 | + $fobemail = fob_mysql()->cache(300)->first("select `status`,`is_send_mail`,`is_web_send` from `e_mail_binds` where `email_id` = ".$data['email_id']); |
| 134 | // 状态异常的跳过 | 97 | // 状态异常的跳过 |
| 135 | if(!$fobemail || $fobemail['status']!=1||!$fobemail['is_send_mail']){ | 98 | if(!$fobemail || $fobemail['status']!=1||!$fobemail['is_send_mail']){ |
| 136 | continue; | 99 | continue; |
| @@ -146,7 +109,7 @@ class fob_hot_ai_mail_auto_reply { | @@ -146,7 +109,7 @@ class fob_hot_ai_mail_auto_reply { | ||
| 146 | } | 109 | } |
| 147 | 110 | ||
| 148 | // 来回超过5次就不回了 | 111 | // 来回超过5次就不回了 |
| 149 | - if(substr_count($data['subject'],"Re:") < 2){ | 112 | + if(substr_count($data['subject'],"Re:") < 1 ){ |
| 150 | // 有配置才回复 | 113 | // 有配置才回复 |
| 151 | $email['hot_email'] = 1; | 114 | $email['hot_email'] = 1; |
| 152 | $email['password'] = base64_encode($email['password']); | 115 | $email['password'] = base64_encode($email['password']); |
| @@ -176,18 +139,14 @@ class fob_hot_ai_mail_auto_reply { | @@ -176,18 +139,14 @@ class fob_hot_ai_mail_auto_reply { | ||
| 176 | } | 139 | } |
| 177 | 140 | ||
| 178 | public function trimBody($data,$inbox){ | 141 | public function trimBody($data,$inbox){ |
| 179 | - // 随机body内容 | ||
| 180 | - $reply = $this->bodys[array_rand($this->bodys)]; | ||
| 181 | - | ||
| 182 | - if(rand(1,2)==1){ | ||
| 183 | - $reply = "<pre>".$reply."</pre>"; | ||
| 184 | - }else{ | ||
| 185 | - $reply = array_map(function ($v){ | ||
| 186 | - return "<p>".$v."</p>"; | ||
| 187 | - },explode("\n",$reply)); | ||
| 188 | - $reply = implode("\n",$reply); | 142 | + if(count($this->bodys) < 1000){ |
| 143 | + $temp = @json_decode(file_get_contents("http://oa.shopk.com/api/email_template?tag=预热邮件"),true); | ||
| 144 | + if(!empty($temp['data']['body'])){ | ||
| 145 | + $this->bodys[] = $temp['data']['body']??''; | ||
| 146 | + } | ||
| 189 | } | 147 | } |
| 190 | 148 | ||
| 149 | + $reply = $this->bodys[array_rand($this->bodys)]; | ||
| 191 | 150 | ||
| 192 | return $reply."<pre style='background-color: #e8d6d6;'>------------------ original message ------------------ | 151 | return $reply."<pre style='background-color: #e8d6d6;'>------------------ original message ------------------ |
| 193 | from: {$data['from']}; | 152 | from: {$data['from']}; |
-
请 注册 或 登录 后发表评论