Browse Source

机器人修改,10秒发完五句话

lizhen_gitee 3 years ago
parent
commit
4ce643b603
1 changed files with 37 additions and 0 deletions
  1. 37 0
      application/index/controller/Plantask.php

+ 37 - 0
application/index/controller/Plantask.php

@@ -11,6 +11,43 @@ use think\Cache;
 class Plantask extends Controller
 {
 
+    //代替公会的人10秒内发出五句话
+    public function firstuser_send()
+    {
+        //找出24小时内注册的男人
+        $map = [
+            'jointime' => ['gt',time()-86400],
+            'gender' => 1,
+            'gh_id'  => 0,
+        ];
+        $oneuser = Db::name('user')->where($map)->orderRaw('rand()')->value('id');
+        //dump($oneuser);
+
+        //找出公会的人
+        $map = [
+            'gh_id'  => ['gt',0],
+        ];
+        $ghuser = Db::name('user')->where($map)->orderRaw('rand()')->value('id');
+        //dump($ghuser);
+
+        //随机取出一句话
+        $oneword = Db::name('plantask_accost')->orderRaw('rand()')->value('title');
+        //dump($oneword);
+
+        //发送出去
+        $cache = Cache::connect(['type'=>'Redis']);
+        $times = $cache->get('plantask_first_word_'.$oneuser);
+        //dump($times);
+
+        if($times === false){
+            $times = 0;
+        }
+        if($times < 5){
+            $this->sendMessageToUser($ghuser,$oneuser,$oneword);
+            $cache->set('plantask_first_word_'.$oneuser, $times + 1);
+        }
+
+    }
     //代替公会的人发出第一句话
     public function firstword_send()
     {