Explorar o código

Merge pull request #944 from visuddhinanda/laravel

增加 最新更新消息
visuddhinanda %!s(int64=3) %!d(string=hai) anos
pai
achega
f48b0b0821

+ 16 - 5
app/Console/Commands/UpgradeChapterDynamic.php

@@ -42,15 +42,18 @@ class UpgradeChapterDynamic extends Command
      */
     public function handle()
     {
-        $start = time();
+		$this->info('upgrade:chapterdynamic start.');
+
+        $startAt = time();
         $img_width = 600;
         $img_height = 120;
         $days = 300; //统计多少天
         $min = 30;
         $linewidth = 2;
 
-        $this->info('更新总动态');
+        
 //更新总动态
+		$this->info("更新总动态");
         $chapters = ProgressChapter::select('book','para')
                                     ->groupBy('book','para')
                                     ->orderBy('book')
@@ -91,8 +94,10 @@ class UpgradeChapterDynamic extends Command
         }
         $bar->finish();
 
-        $this->info('用时'.(time()-$start));
-        $start = time();
+		$time = time()- $startAt;
+        $this->info("用时 {$time}");
+
+        $startAt = time();
 
         $this->info('更新缺的章节空白图');
         // 更新缺的章节空白图
@@ -113,8 +118,10 @@ class UpgradeChapterDynamic extends Command
             }
         }
         $bar->finish();
+		$time = time()- $startAt;
+        $this->info("用时 {$time}");
 
-
+		$startAt = time();
         //更新chennel动态
         $this->info('更新chennel动态');
         $bar = $this->output->createProgressBar(ProgressChapter::count());
@@ -153,6 +160,10 @@ class UpgradeChapterDynamic extends Command
             }
         }
         $bar->finish();
+		$time = time()- $startAt;
+        $this->info("用时 {$time}");
+
+        $this->info("upgrade:chapterdynamic done");
 
         return 0;
     }

+ 12 - 2
app/Console/Commands/UpgradeDaily.php

@@ -50,7 +50,7 @@ class UpgradeDaily extends Command
 		}
 
         # 刷巴利语句子uuid 仅调用一次
-        $this->call('upgrade:palitextid');
+        //$this->call('upgrade:palitextid');
         //巴利原文段落库目录结构改变时运行
         $this->call('upgrade:palitext'); 
         #巴利段落标签
@@ -71,7 +71,17 @@ class UpgradeDaily extends Command
 				'url' => 'dingtalk1',
 				'title' => "后台任务",
 				'message' => "wikipali: 每日统计后台任务执行完毕。用时{$time}",
-			]);			
+			]);
+			//发送dingding消息
+			$this->call('message:webhookarticlenew',[
+				'host' => 'https://oapi.dingtalk.com/robot/send?access_token=34143dbec80a8fc09c1cb5897a5639ee3a9a32ecfe31835ad29bf7013bdb9fdf',
+				'type' => 'dingtalk',
+			]);
+			//发送微信消息
+			$this->call('message:webhookarticlenew',[
+				'host' => 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=25dbd74f-c89c-40e5-8cbc-48b1ef7710b8',
+				'type' => 'wechat',
+			]);
 		}
 
 

+ 5 - 1
app/Console/Commands/UpgradeProgress.php

@@ -42,7 +42,8 @@ class UpgradeProgress extends Command
      */
     public function handle()
     {
-
+		$this->info('upgrade:progress start');
+		$startTime = time();
 
         $channels = Sentence::where('strlen','>',0)
                           ->where('book_id','<',1000)
@@ -102,6 +103,9 @@ class UpgradeProgress extends Command
         }
         $bar->finish();
 
+		$time = time() - $startTime;
+		$this->info("upgrade progress finished in {$time}s");
+
         return 0;
     }
 }

+ 5 - 1
app/Console/Commands/UpgradeProgressChapter.php

@@ -46,6 +46,9 @@ class UpgradeProgressChapter extends Command
      */
     public function handle()
     {
+		$this->info("upgrade:progresschapter start.");
+		$startTime = time();
+
         $tagCount=0;
         #第一步 查询有多少书有译文
 		$books = Sentence::where('strlen','>',0)
@@ -199,7 +202,8 @@ class UpgradeProgressChapter extends Command
             $bar->advance();
         }
         $bar->finish();
-        $this->info("tag count:".$tagCount);
+		$time = time() - $startTime;
+		$this->info("upgrade:progresschapter finished in {$time}s tag count:{$tagCount}");
         return 0;
     }
 }

+ 5 - 1
app/Console/Commands/UpgradeWbwAnalyses.php

@@ -40,6 +40,9 @@ class UpgradeWbwAnalyses extends Command
      */
     public function handle()
     {
+		$startAt = time();
+		$this->info("upgrade:wbwanalyses start");
+
         $bar = $this->output->createProgressBar(Wbw::count());
         $counter =0;
         if(empty($this->argument('id'))){
@@ -140,7 +143,8 @@ class UpgradeWbwAnalyses extends Command
             $bar->advance();
         }
         $bar->finish();
-        $this->info("wbw analyses finished");
+		$time = time() - $startAt;
+        $this->info("wbw analyses done in {$time}");
         return 0;
     }
 }

+ 87 - 0
app/Console/Commands/WebHookArticleNew.php

@@ -0,0 +1,87 @@
+<?php
+
+namespace App\Console\Commands;
+
+use Illuminate\Console\Command;
+use Illuminate\Support\Facades\Http;
+
+class WebHookArticleNew extends Command
+{
+    /**
+     * The name and signature of the console command.
+     *
+     * @var string
+     */
+    protected $signature = 'message:webhookarticlenew {host} {type}';
+
+    /**
+     * The console command description.
+     *
+     * @var string
+     */
+    protected $description = '发送消息到一个服务器机器人';
+
+    /**
+     * Create a new command instance.
+     *
+     * @return void
+     */
+    public function __construct()
+    {
+        parent::__construct();
+    }
+
+    /**
+     * Execute the console command.
+     *
+     * @return int
+     */
+    public function handle()
+    {
+		# 获取最新文章数据
+		$url = env('APP_URL',"http://127.0.0.1:8000")."/api/v2/progress?view=chapter&channel_type=translation";
+
+		$response = Http::get($url);
+		if($response->successful()){
+			$this->info("get data ok");
+			$data = $response['data']['rows'];
+			$title = "2022-7-3更新";
+			$message = "# wikipali:最新更新\n\n";
+			for ($i=0; $i < 4; $i++) { 
+				# code...
+				$row = $data[$i];
+				$book = $row['book'];
+                $para = $row['para'];
+				$channel_id = $row['channel_id'];
+                $title = $row['toc'];
+				$link = env('APP_URL',"http://127.0.0.1:8000")."/app/article/index.php?view=chapter&book={$book}&par={$para}&channel={$channel_id}";
+				$message .= "1. [{$title}]({$link})\n";				
+			}
+			$this->info($message);
+			$url = $this->argument('host');
+			switch ($this->argument('type')) {
+				case "dingtalk":
+					$param = [
+						"markdown"=> [
+							"title"=> $title, 
+							"text"=> $message, 
+						], 
+						"msgtype"=>"markdown"
+						];
+					break;
+				case "wechat":
+					$param = [
+						"msgtype"=>"markdown",
+						"markdown"=> [
+							"content"=> $message, 
+						], 
+						];
+					break;
+			}
+			$response = Http::post($url, $param);
+		}else{
+			$this->error("章节数据获取错误");
+		}
+        return 0;
+    }
+}

+ 2 - 3
public/app/public/charcode/coverter_my.js

@@ -111,7 +111,7 @@ var char_roman_to_myn = [
 	{ id: "o", value: "ဩ" },
 	{ id: "်္အ", value: "" },
 	{ id: "္အ", value: "" },
-	{ id: "1", value: "၁" },
+	{ id: "1", value: "၁" },//新增数字
 	{ id: "2", value: "၂" },
 	{ id: "3", value: "၃" },
 	{ id: "4", value: "၄" },
@@ -121,7 +121,7 @@ var char_roman_to_myn = [
 	{ id: "8", value: "၈" },
 	{ id: "9", value: "၉" },
 	{ id: "0", value: "၀" },
-	{ id: "ခော", value: "ခေါ" },
+	{ id: "ခော", value: "ခေါ" },//矫正缅文转码错误
 	{ id: "ခာ", value: "ခါ" }, //kh
 	{ id: "က္ခေါ", value: "က္ခော" }, //kkho
 	{ id: "က္ခါ", value: "က္ခာ" }, //kkhā
@@ -142,7 +142,6 @@ var char_roman_to_myn = [
 
 var char_myn_to_roman_1 = [
 	{ id: "ႁႏၵ", value: "ndra" }, //後加
-
 	{ id: "ခ္", value: "kh" },
 	{ id: "ဃ္", value: "gh" },
 	{ id: "ဆ္", value: "ch" },