no message
This commit is contained in:
parent
e3a201a71f
commit
55fd8be0a9
@ -4,6 +4,7 @@ namespace App\Http\Controllers;
|
|||||||
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use App\Models\Article;
|
use App\Models\Article;
|
||||||
|
use App\Models\Option;
|
||||||
use App\Services\TG\Http as TGHttp;
|
use App\Services\TG\Http as TGHttp;
|
||||||
|
|
||||||
class CronController
|
class CronController
|
||||||
@ -42,6 +43,13 @@ class CronController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 暂停
|
||||||
|
$option = Option::where("type", "pause")->first();
|
||||||
|
$isPause = $option ? $option->value : null;
|
||||||
|
if ($isPause == 1) {
|
||||||
|
exit("暂停");
|
||||||
|
}
|
||||||
|
|
||||||
// i_in10规则
|
// i_in10规则
|
||||||
$iIin10 = $i[1];
|
$iIin10 = $i[1];
|
||||||
$aArticle = Article::where("i_in10", $iIin10)->where("status", 1)->get()->toArray();
|
$aArticle = Article::where("i_in10", $iIin10)->where("status", 1)->get()->toArray();
|
||||||
|
|||||||
@ -13,38 +13,38 @@ class TestsController
|
|||||||
public function hook($sHostName = 'ssssss')
|
public function hook($sHostName = 'ssssss')
|
||||||
{
|
{
|
||||||
|
|
||||||
// 定义要添加的配置
|
// // 定义要添加的配置
|
||||||
$host = $sHostName;
|
// $host = $sHostName;
|
||||||
$hostname = "github.com";
|
// $hostname = "github.com";
|
||||||
$user = "git";
|
// $user = "git";
|
||||||
$identityFile = env("path_ssh")."/id_rsa_".$sHostName;
|
// $identityFile = env("path_ssh")."/id_rsa_".$sHostName;
|
||||||
|
//
|
||||||
// 构建配置字符串
|
// // 构建配置字符串
|
||||||
$config = "\nHost ".$host.".com\n";
|
// $config = "\nHost ".$host.".com\n";
|
||||||
$config .= "\tHostName $hostname\n";
|
// $config .= "\tHostName $hostname\n";
|
||||||
$config .= "\tUser $user\n";
|
// $config .= "\tUser $user\n";
|
||||||
$config .= "\tIdentityFile $identityFile\n";
|
// $config .= "\tIdentityFile $identityFile\n";
|
||||||
|
//
|
||||||
// 指定 SSH 配置文件路径
|
// // 指定 SSH 配置文件路径
|
||||||
$sshConfigFile = env("path_ssh")."/config";
|
// $sshConfigFile = env("path_ssh")."/config";
|
||||||
|
//
|
||||||
// 检查文件是否存在,如果不存在则创建
|
// // 检查文件是否存在,如果不存在则创建
|
||||||
if (!file_exists($sshConfigFile)) {
|
// if (!file_exists($sshConfigFile)) {
|
||||||
touch($sshConfigFile);
|
// touch($sshConfigFile);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// 追加配置到文件
|
// // 追加配置到文件
|
||||||
file_put_contents($sshConfigFile, $config, FILE_APPEND | LOCK_EX);
|
// file_put_contents($sshConfigFile, $config, FILE_APPEND | LOCK_EX);
|
||||||
|
//
|
||||||
// 设置文件权限
|
// // 设置文件权限
|
||||||
chmod($sshConfigFile, 0600);
|
// chmod($sshConfigFile, 0600);
|
||||||
|
//
|
||||||
echo "SSH config updated successfully.";
|
// echo "SSH config updated successfully.";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
exit;
|
// exit;
|
||||||
// $t = [];
|
// $t = [];
|
||||||
// $a = $t['zz']["cc"] += 10;
|
// $a = $t['zz']["cc"] += 10;
|
||||||
// $a = $t['zz']["cc"] += 10;
|
// $a = $t['zz']["cc"] += 10;
|
||||||
@ -62,7 +62,7 @@ class TestsController
|
|||||||
//test
|
//test
|
||||||
// $s = "\/AticleSet__1115zz__sale_rate 1118.118";
|
// $s = "\/AticleSet__1115zz__sale_rate 1118.118";
|
||||||
// $s = "\/git#LastTime 1";
|
// $s = "\/git#LastTime 1";
|
||||||
$s= "/test#cron__i 07";
|
$s= "/cron#pause 4";
|
||||||
|
|
||||||
$oHttp = new Http();
|
$oHttp = new Http();
|
||||||
$oHttp->sMethod = "post";
|
$oHttp->sMethod = "post";
|
||||||
|
|||||||
11
app/Models/Option.php
Executable file
11
app/Models/Option.php
Executable file
@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Option extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'option';
|
||||||
|
public $timestamps = false;
|
||||||
|
}
|
||||||
27
app/Services/TG/Hook/Mod/Cron.php
Normal file
27
app/Services/TG/Hook/Mod/Cron.php
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\TG\Hook\Mod;
|
||||||
|
use App\Models\Option as ModelOption;
|
||||||
|
|
||||||
|
class Cron extends Base {
|
||||||
|
|
||||||
|
public function Pause($aParam)
|
||||||
|
{
|
||||||
|
$v = $aParam['aArg'][1];
|
||||||
|
|
||||||
|
// 获取第一个匹配的选项
|
||||||
|
$oOption = ModelOption::where("type", "pause")->first();
|
||||||
|
|
||||||
|
// 检查是否找到了选项
|
||||||
|
if ($oOption) {
|
||||||
|
$oOption->value = $v;
|
||||||
|
|
||||||
|
// 保存并返回结果
|
||||||
|
return json_encode($oOption->save());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果没有找到选项,返回一个错误信息
|
||||||
|
return json_encode(['error' => 'Option not found']);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user