no message
This commit is contained in:
parent
135bc89550
commit
6667c25116
@ -109,7 +109,7 @@ final class HookController
|
||||
$oTGHttp->sendToTG($r, $aUpdate);
|
||||
}
|
||||
|
||||
Http::response(200, 'ok');
|
||||
Http::response(200);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
16
src/Models/MailArticle.php
Executable file
16
src/Models/MailArticle.php
Executable file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Query\Builder;
|
||||
use function time;
|
||||
|
||||
final class MailArticle extends Model
|
||||
{
|
||||
protected $connection = 'default';
|
||||
protected $table = 'mail_article';
|
||||
|
||||
|
||||
}
|
||||
@ -25,25 +25,258 @@ use Exception;
|
||||
use Psr\Http\Client\ClientExceptionInterface;
|
||||
use Smarty\Smarty;
|
||||
|
||||
final class Mail
|
||||
use App\Models\MailArticle as ModelMailArticle;
|
||||
|
||||
//use App\Services\TomTool\ToolTg;
|
||||
use App\Services\TomTool\TgFormat;
|
||||
|
||||
final class Mail extends Base
|
||||
{
|
||||
|
||||
public function mod1($aParam)
|
||||
public function list()
|
||||
{
|
||||
// $sValue = $aParam["aArg"][1] ?? false;
|
||||
//
|
||||
// if ($sValue == "?") {
|
||||
// return "/mail#mod1 <liuliang>";
|
||||
// }
|
||||
$oMailArticle = ModelMailArticle::all();
|
||||
|
||||
return $this->toJson($oMailArticle);
|
||||
}
|
||||
|
||||
public function add($aParam)
|
||||
{
|
||||
$sValue = $aParam["aArg"][1] ?? false;
|
||||
|
||||
if ($sValue == "?") {
|
||||
return "/node#add 无参数";
|
||||
}
|
||||
|
||||
$oMailArticle = new ModelMailArticle();
|
||||
$oMailArticle->save();
|
||||
|
||||
$aParam["aArg"][1] = $oMailArticle->id;
|
||||
return $this->find($aParam);
|
||||
}
|
||||
|
||||
public function set($aParam)
|
||||
{
|
||||
$iId = $aParam["aOption"][1] ?? false;
|
||||
$sField = $aParam["aOption"][2] ?? false;
|
||||
$sValue = $aParam["aArg"][1] ?? false;
|
||||
|
||||
if ($sValue == "?") {
|
||||
return "/mail#set__{id}__{field} {value}";
|
||||
}
|
||||
|
||||
if (!$iId) {
|
||||
return "需要id";
|
||||
}
|
||||
|
||||
if (!$sField) {
|
||||
return "需要field";
|
||||
}
|
||||
|
||||
if (!$sValue) {
|
||||
return "需要value";
|
||||
}
|
||||
|
||||
$oMailArticle = ModelMailArticle::where("id", $iId)->first();
|
||||
|
||||
if (!$oMailArticle->exists()) {
|
||||
return "没找到这个id";
|
||||
}
|
||||
|
||||
$oMailArticle->$sField = $sValue;
|
||||
|
||||
$oMailArticle->save();
|
||||
|
||||
$aParam["aArg"][1] = $oMailArticle->id;
|
||||
return $this->find($aParam);
|
||||
}
|
||||
|
||||
public function like($aParam)
|
||||
{
|
||||
$sValue = $aParam["aArg"][1] ?? false;
|
||||
$sField = $aParam["aOption"][1] ?? false;
|
||||
|
||||
if ($sValue == "?") {
|
||||
return "/mail#like__{likeField} {likeValue}";
|
||||
}
|
||||
|
||||
if (!$sValue) {
|
||||
return "需要field";
|
||||
}
|
||||
|
||||
if (!$sField) {
|
||||
return "需要value";
|
||||
}
|
||||
|
||||
$oMailArticle = ModelMailArticle::where($sField, "like", "%".$sValue."%")->get();
|
||||
|
||||
return $this->toJson($oMailArticle);
|
||||
}
|
||||
|
||||
public function del($aParam)
|
||||
{
|
||||
$iId = $aParam["aArg"][1] ?? false;
|
||||
|
||||
if (!$iId) {
|
||||
return "需要id";
|
||||
}
|
||||
|
||||
$oMailArticle = ModelMailArticle::find($iId);
|
||||
|
||||
if (!$oMailArticle) {
|
||||
return "没有这个id";
|
||||
}
|
||||
|
||||
$oMailArticle->delete();
|
||||
|
||||
return $this->list();
|
||||
}
|
||||
|
||||
public function find($aParam)
|
||||
{
|
||||
$iId = $aParam["aArg"][1] ?? false;
|
||||
|
||||
if (!$iId) {
|
||||
return "需要id";
|
||||
}
|
||||
|
||||
$oMailArticle = ModelMailArticle::find($iId);
|
||||
|
||||
return $this->toJson($oMailArticle);
|
||||
}
|
||||
|
||||
public function me()
|
||||
{
|
||||
$tmp = [
|
||||
"type:bulk=群发,none=默认原本",
|
||||
"tpl:war=重要通知,tip=运维通知,warn=系统提示",
|
||||
];
|
||||
|
||||
$str = TgFormat::arrToStr($tmp);
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function sendTest($aParam)
|
||||
{
|
||||
$aParam["is_test"] = true;
|
||||
|
||||
return $this->send($aParam);
|
||||
}
|
||||
|
||||
public function send($aParam)
|
||||
{
|
||||
$iId = $aParam["aArg"][1] ?? false;
|
||||
$iClass = $aParam["aOption"][1] ?? false;
|
||||
$sType = $aParam["aOption"][2] ?? "no";
|
||||
$isTest = $aParam["is_test"] ?? false;
|
||||
|
||||
if ($iId == "?") {
|
||||
return "/mail#send__{class大于等于,支持zero}__{type?} {articleId} | type=空:核查提示,type=yes:确认核查";
|
||||
}
|
||||
|
||||
if (!$iId) {
|
||||
return "需要id";
|
||||
}
|
||||
|
||||
if (!$iClass) {
|
||||
return "需要class";
|
||||
}
|
||||
|
||||
if ($iClass == "zero") {
|
||||
$iClass == 0;
|
||||
}
|
||||
|
||||
$oMailArticle = ModelMailArticle::find($iId);
|
||||
|
||||
if (!$oMailArticle) {
|
||||
return "没有这个id";
|
||||
}
|
||||
|
||||
if ($sType == "no") {
|
||||
|
||||
$msg = $this->toJson($oMailArticle);
|
||||
|
||||
$sTip = "仔细核查!!!别弄错了!!!确认在option输入yes。\n\n";
|
||||
|
||||
return $sTip.$msg;
|
||||
|
||||
} else if ($sType == "yes") {
|
||||
|
||||
return $this->_send($oMailArticle, $iClass, $isTest);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function _send($oMailArticle, $iClass, $isTest = false)
|
||||
{
|
||||
$sMailTitle = $oMailArticle["title"];
|
||||
$sMailContent = $oMailArticle["content"];
|
||||
$sTpl = $oMailArticle["tpl"];
|
||||
$sType = $oMailArticle["type"];
|
||||
|
||||
$content = strip_tags(
|
||||
str_replace(
|
||||
['<p>','</p>'],
|
||||
['','<br><br>'],
|
||||
$sMailContent
|
||||
),
|
||||
['br', 'a', 'strong']
|
||||
);
|
||||
|
||||
if ($isTest) {
|
||||
$users = (new User())->where("email", "yuejiqi@tuta.io")->get();
|
||||
// echo "testmail";exit;£
|
||||
} else {
|
||||
$users = (new User())->where('class', '>=', $iClass)->get();
|
||||
//echo 11;exit;
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
foreach ($users as $user) {
|
||||
|
||||
if ($sType == "bulk") {
|
||||
|
||||
(new EmailQueue())->add_bulk( //add_bulk 群发
|
||||
$user->email,
|
||||
$sMailTitle,
|
||||
$sTpl.'.tpl', // 注意切换模版
|
||||
[
|
||||
'user' => $user,
|
||||
'text' => $content,
|
||||
]
|
||||
);
|
||||
|
||||
} else {
|
||||
|
||||
(new EmailQueue())->add(
|
||||
$user->email,
|
||||
$sMailTitle,
|
||||
$sTpl.'.tpl', // 注意切换模版
|
||||
[
|
||||
'user' => $user,
|
||||
'text' => $content,
|
||||
]
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
|
||||
return $sType."邮件添加".$i."条";
|
||||
|
||||
}
|
||||
|
||||
public function tmp()
|
||||
{
|
||||
$subject = "福云 - 运维通知";
|
||||
$subject = "福云 - 暑假礼盒";
|
||||
|
||||
// $text = "<br>原主域名fuuu.cloud被封禁,已更换为fuuuu.cloud(多了一个u)。<br><br>无法继续翻墙的用户需到网站上重新复制订阅。<br><br>很抱歉对您的使用造成影响,补偿有套餐用户30g流量。";
|
||||
$text = "<br>近期管控收紧,造成节点波动和不可用。已陆续恢复正常,补偿有套餐用户10g流量。<br><br>最新域名:fuuuu.cloud";
|
||||
// $text = "<br>近期管控收紧,造成节点波动和不可用。已陆续恢复正常,补偿有套餐用户10g流量。<br><br>最新域名:fuuuu.cloud";
|
||||
$text = "<br>礼盒内容:<br>一批6折优惠码:zzxxss,仅限购买月套餐<br>10g流量,赠送给有套餐用户。<br>富云最新域名fuuuu.cloud";
|
||||
|
||||
$content = strip_tags(
|
||||
str_replace(
|
||||
@ -54,8 +287,8 @@ final class Mail
|
||||
['br', 'a', 'strong']
|
||||
);
|
||||
|
||||
$users = (new User())->where('class', '>=', 0)->get();
|
||||
// $users = (new User())->where("email", "yuejiqi@tuta.io")->get();
|
||||
// $users = (new User())->where('class', '>=', 0)->get();
|
||||
$users = (new User())->where("email", "yuejiqi@tuta.io")->get();
|
||||
|
||||
$i = 0;
|
||||
foreach ($users as $user) {
|
||||
@ -76,89 +309,6 @@ final class Mail
|
||||
|
||||
}
|
||||
|
||||
public function test_yuejiqi()
|
||||
{
|
||||
$subject = "福云 - 重要通知:域名地址变更!";
|
||||
|
||||
$text = "<br>原主域名fuuu.cloud被封禁,已更换为fuuuu.cloud(多了一个u)。<br><br>无法继续翻墙的用户需到网站上重新复制订阅。<br><br>很抱歉对您的使用造成影响,补偿有套餐用户30g流量。";
|
||||
|
||||
$content = strip_tags(
|
||||
str_replace(
|
||||
['<p>','</p>'],
|
||||
['','<br><br>'],
|
||||
$text
|
||||
),
|
||||
['br', 'a', 'strong']
|
||||
);
|
||||
|
||||
// $users = (new User())->where('class', '>=', 0)->get();
|
||||
$users = (new User())->where("email", "yuejiqi@tuta.io")->get();
|
||||
|
||||
$i = 0;
|
||||
foreach ($users as $user) {
|
||||
(new EmailQueue())->add_bulk(
|
||||
$user->email,
|
||||
$subject,
|
||||
'war.tpl',
|
||||
[
|
||||
'user' => $user,
|
||||
'text' => $content,
|
||||
]
|
||||
);
|
||||
$i++;
|
||||
}
|
||||
|
||||
|
||||
return "邮件队列添加".$i."条";
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function tmp2()
|
||||
{
|
||||
$subject = "福云 - 重要通知:域名地址变更!";
|
||||
|
||||
|
||||
|
||||
$text = "<br>主域名fuuu.cloud被封禁,已更换为fuuuu.cloud(多一个u)。";
|
||||
|
||||
$content = strip_tags(
|
||||
str_replace(
|
||||
['<p>','</p>'],
|
||||
['','<br><br>'],
|
||||
$text
|
||||
),
|
||||
['br', 'a', 'strong']
|
||||
);
|
||||
|
||||
// $users = (new User())->where('class', '>=', 0)
|
||||
// ->get();
|
||||
|
||||
$users = (new User())->where("email", "yuejiqi@tuta.io")->get();
|
||||
|
||||
foreach ($users as $user) {
|
||||
(new EmailQueue())->add(
|
||||
$user->email,
|
||||
$subject,
|
||||
'war.tpl',
|
||||
[
|
||||
'user' => $user,
|
||||
'text' => $content,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
return "应该发送成功了";
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -19,7 +19,7 @@ class Http {
|
||||
public function sendToTG($sMsg = "没有msg?", $aUpdate = [])
|
||||
{
|
||||
|
||||
if (isset($aUpdate["cmd"]) && $aUpdate["cmd"] == "shell") {
|
||||
if (isset($aUpdate["shell"]) && $aUpdate["shell"] == "cmd") {
|
||||
|
||||
echo $sMsg;
|
||||
|
||||
|
||||
@ -22,4 +22,14 @@ class TgFormat {
|
||||
return $sValue;
|
||||
}
|
||||
|
||||
public static function arrToStr($arr)
|
||||
{
|
||||
$str = "";
|
||||
foreach ($arr as $v) {
|
||||
$str .= "\n\n".$v;
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user