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);
}
public function sendMarkdown($msg, $chatId = 0) { // 发送Markdown格式消息
return tgApi::sendMessage(array(
'text' => $msg,
'parse_mode' => 'Markdown',
), $chatId);
}
public function sendMessage($params, $chatId = 0) { // 发送消息
return tgApi::sendByMethod('sendMessage', $params, $chatId);
}

16
models/icpQuery.php

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

5
models/ipInfo.php

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

6
models/kmsCheck.php

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

6
models/ntpCheck.php

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

5
models/punycode.php

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

Loading…
Cancel
Save