diff --git a/class.inc.php b/class.inc.php deleted file mode 100644 index fe53c73..0000000 --- a/class.inc.php +++ /dev/null @@ -1,67 +0,0 @@ -_fp = stream_socket_client($remoteSocket); - if ($this->_fp === false) { - throw new ClientException('Could not connect to socket "' . $remoteSocket . '"'); - } - stream_set_timeout($this->_fp, 1); //This way fgets() returns false if telegram-cli gives us no response. - } - - public function __destruct() - { - fclose($this->_fp); - } - - public function exec($command) - { - fwrite($this->_fp, str_replace("\n", '\n', $command) . PHP_EOL); - - $answer = fgets($this->_fp); //"ANSWER $bytes" if there is a return value or \n if not - if (is_string($answer)) { - if (substr($answer, 0, 7) === 'ANSWER ') { - $bytes = (int) substr($answer, 7); - if ($bytes > 0) { - $string = trim(fread($this->_fp, $bytes + 1)); - - if ($string === 'SUCCESS') { //For "status_online" and "status_offline" - return true; - } - - return $string; - } - } else if ($answer === PHP_EOL) { //For commands like "msg" - return true; - } - } - - return false; - } - - public function encodeUri($var){ - return iconv("gb2312", "UTF-8", $var); - } - - - public function escapeString($var){ - return '"' . addslashes($var) . '"'; - } - - public function escapePeer($peer){ - return str_replace(' ', '_', $peer); - } - - - public function escape($var){ - return escapeString(encodeUri($var)); - } - - public function PluginList($commands, $name){ - global $plugins; - $plugins[] .= TAG.$commands." ".$name; - } -} \ No newline at end of file diff --git a/classes/Telegram/Base.php b/classes/Telegram/Base.php index b160eb8..5a0bc8f 100644 --- a/classes/Telegram/Base.php +++ b/classes/Telegram/Base.php @@ -38,14 +38,4 @@ class Base return false; } - - public function escapeStringArgument($argument) - { - return '"' . addslashes($argument) . '"'; - } - - public function escapePeer($peer) - { - return str_replace(' ', '_', $peer); - } } diff --git a/config.inc.php b/config.inc.php index 71c5ef7..f2589d5 100644 --- a/config.inc.php +++ b/config.inc.php @@ -1,2 +1,4 @@ exec("msg Denny_Dai ".json_encode($_GET)); //私聊监测 + $BOT->exec("msg ".escapePeer(OWNER_NAME)." ".json_encode($_GET)); } //load plugins diff --git a/plugins/echo.php b/plugins/echo.php index 3f2cdcb..b61a865 100644 --- a/plugins/echo.php +++ b/plugins/echo.php @@ -1,5 +1,5 @@ exec("msg ".$from." ".$matches[1]); } \ No newline at end of file diff --git a/plugins/help.php b/plugins/help.php index 48eedc5..e89f1bf 100644 --- a/plugins/help.php +++ b/plugins/help.php @@ -1,7 +1,7 @@ exec("msg ".$from." ".escapeString($msg)); } \ No newline at end of file diff --git a/plugins/trans.php b/plugins/trans.php index e5a57a1..6d814a6 100644 --- a/plugins/trans.php +++ b/plugins/trans.php @@ -1,5 +1,5 @@ exec("msg ".$from." ".escapeString($msg)); } \ No newline at end of file diff --git a/plugins/tts.php b/plugins/tts.php index 8bc5825..85e85e0 100644 --- a/plugins/tts.php +++ b/plugins/tts.php @@ -1,5 +1,5 @@