Browse Source

update: interface of send markdown

master
Dnomd343 3 years ago
parent
commit
72b66a3854
  1. 7
      functions/TgInterface.php
  2. 16
      models/icpQuery.php
  3. 5
      models/ipInfo.php
  4. 6
      models/kmsCheck.php
  5. 6
      models/ntpCheck.php
  6. 5
      models/punycode.php

7
functions/TgInterface.php

@ -5,6 +5,13 @@ class tgApi {
return tgApi::sendMessage(['text' => $msg], $chatId); return tgApi::sendMessage(['text' => $msg], $chatId);
} }
public function sendMarkdown($msg, $chatId = 0) { // 发送Markdown格式消息
return tgApi::sendMessage(array(
'text' => $msg,
'parse_mode' => 'Markdown',
), $chatId);
}
public function sendMessage($params, $chatId = 0) { // 发送消息 public function sendMessage($params, $chatId = 0) { // 发送消息
return tgApi::sendByMethod('sendMessage', $params, $chatId); return tgApi::sendByMethod('sendMessage', $params, $chatId);
} }

16
models/icpQuery.php

@ -119,20 +119,15 @@ class icpQueryEntry {
} }
$content = $this->check($rawParam); $content = $this->check($rawParam);
if ($content['status'] !== 'ok') { // 请求参数错误 if ($content['status'] !== 'ok') { // 请求参数错误
tgApi::sendMessage(array( tgApi::sendMarkdown($content['message']);
'parse_mode' => 'Markdown',
'text' => $content['message']
));
return; return;
} }
$isCache = true; $isCache = true;
$domain = $content['domain']; $domain = $content['domain'];
$msg = '`' . (new Punycode)->decode($domain) . '`' . PHP_EOL; $msg = '`' . (new Punycode)->decode($domain) . '`' . PHP_EOL;
if (!(new icpQuery)->isCache($domain)) { // 域名信息未缓存 if (!(new icpQuery)->isCache($domain)) { // 域名信息未缓存
$message = json_decode(tgApi::sendMessage(array( $message = tgApi::sendMarkdown($msg . 'ICP备案信息查询中...');
'parse_mode' => 'Markdown', $message = json_decode($message, true);
'text' => $msg . 'ICP备案信息查询中...'
)), true);
$isCache = false; $isCache = false;
} }
$info = (new icpQuery)->icpInfo($domain); // 发起查询 $info = (new icpQuery)->icpInfo($domain); // 发起查询
@ -178,10 +173,7 @@ class icpQueryEntry {
$msg .= '*审核时间:*' . $info['VerifyTime'] . PHP_EOL; $msg .= '*审核时间:*' . $info['VerifyTime'] . PHP_EOL;
$msg .= '*许可证号:*' . $info['SiteLicense'] . PHP_EOL; $msg .= '*许可证号:*' . $info['SiteLicense'] . PHP_EOL;
if ($isCache) { // 没有缓冲信息 直接发送 if ($isCache) { // 没有缓冲信息 直接发送
tgApi::sendMessage(array( // 返回查询数据 tgApi::sendMarkdown($msg); // 返回查询数据
'parse_mode' => 'Markdown',
'text' => $msg
));
} else { } else {
tgApi::editMessage(array( // 返回查询数据 修改原消息 tgApi::editMessage(array( // 返回查询数据 修改原消息
'parse_mode' => 'Markdown', 'parse_mode' => 'Markdown',

5
models/ipInfo.php

@ -153,10 +153,7 @@ class ipInfoEntry {
} }
$ips = $this->dnsResolve($rawParam); $ips = $this->dnsResolve($rawParam);
if (count($ips) == 0) { // 解析不到IP记录 if (count($ips) == 0) { // 解析不到IP记录
tgApi::sendMessage($chatId, array( tgApi::sendMarkdown('Nothing found of `' . $rawParam . '`');
'parse_mode' => 'Markdown',
'text' => 'Nothing found of `' . $rawParam . '`'
));
return; return;
} }
foreach ($ips as $ip) { foreach ($ips as $ip) {

6
models/kmsCheck.php

@ -205,10 +205,8 @@ class kmsCheckEntry {
tgApi::sendText($check['message']); tgApi::sendText($check['message']);
return; return;
} }
$message = json_decode(tgApi::sendMessage(array( $message = tgApi::sendMarkdown('`' . $rawParam . '`' . PHP_EOL . 'KMS服务检测中...');
'parse_mode' => 'Markdown', $message = json_decode($message, true);
'text' => '`' . $rawParam . '`' . PHP_EOL . 'KMS服务检测中...'
)), true);
fastcgi_finish_request(); // 断开连接 fastcgi_finish_request(); // 断开连接
tgApi::editMessage(array( tgApi::editMessage(array(
'message_id' => $message['result']['message_id'], 'message_id' => $message['result']['message_id'],

6
models/ntpCheck.php

@ -201,10 +201,8 @@ class ntpCheckEntry {
tgApi::sendText('Illegal host'); // 输入错误 tgApi::sendText('Illegal host'); // 输入错误
return; return;
} }
$message = json_decode(tgApi::sendMessage(array( $message = tgApi::sendMarkdown('`' . $rawParam . '`' . PHP_EOL . 'NTP Server Checking...');
'parse_mode' => 'Markdown', $message = json_decode($message, true);
'text' => '`' . $rawParam . '`' . PHP_EOL . 'NTP Server Checking...'
)), true);
fastcgi_finish_request(); // 断开连接 fastcgi_finish_request(); // 断开连接
tgApi::editMessage(array( tgApi::editMessage(array(
'message_id' => $message['result']['message_id'], 'message_id' => $message['result']['message_id'],

5
models/punycode.php

@ -45,10 +45,7 @@ class punycodeEntry {
$msg .= '*Warning:* ' . $errMsg; $msg .= '*Warning:* ' . $errMsg;
} }
} }
tgApi::sendMessage(array( tgApi::sendMarkdown($msg);
'parse_mode' => 'Markdown',
'text' => $msg
));
} }
} }

Loading…
Cancel
Save