diff --git a/QUERY_BOT.php b/QUERY_BOT.php index c925899..a792489 100644 --- a/QUERY_BOT.php +++ b/QUERY_BOT.php @@ -2,38 +2,40 @@ //init $Pre_Type = $_SERVER['QUERY_STRING']; require_once('config.php'); -require_once('functions.php'); $plugins = array(); require(PATH.'classes'.DIRECTORY_SEPARATOR.TYPE.DIRECTORY_SEPARATOR.'Base.php'); require_once(PATH.'classes'.DIRECTORY_SEPARATOR.TYPE.DIRECTORY_SEPARATOR.'init.php'); //load plugins - - $load_plugins = glob(PATH.'plugins'.DIRECTORY_SEPARATOR.'*.php'); - foreach ($load_plugins as $key => $value) { - if ($value == PATH.'plugins'.DIRECTORY_SEPARATOR.'help.php') { - unset($load_plugins[$key]); +$load_plugins = glob(PATH.'plugins'.DIRECTORY_SEPARATOR.'*.php'); +foreach ($load_plugins as $key => $value) { + if ($value == PATH.'plugins'.DIRECTORY_SEPARATOR.'help.php') { + unset($load_plugins[$key]); + } +} +foreach ($TAGs as $TAG) { + foreach ($load_plugins as $value) { + $plugin_name = substr($value, strlen(PATH.'plugins'.DIRECTORY_SEPARATOR), -4); + if (preg_match("/^(".preg_quote($TAG, '/').$plugin_name."|".preg_quote($TAG, '/').$plugin_name.preg_quote('@').BOT_NAME.") (.*)$/", $text, $matches)) { + $plugin_text = $matches[2]; + $plugin_sendto = $from; + require_once $value; + break; + }elseif (preg_match("/^(".preg_quote($TAG, '/').$plugin_name.")|(".preg_quote($TAG, '/').$plugin_name.preg_quote('@').BOT_NAME.")$/", $text)) { + $plugin_text = $matches[2]; + $plugin_sendto = $from; + require_once $value; + break; } } - foreach ($TAGs as $TAG) { - foreach ($load_plugins as $value) { - $plugin_name = substr($value, strlen(PATH.'plugins'.DIRECTORY_SEPARATOR), -4); - if (preg_match("/^(".preg_quote($TAG, '/').$plugin_name."|".preg_quote($TAG, '/').$plugin_name.preg_quote('@').BOT_NAME.") (.*)$/", $text, $matches)) { - $plugin_text = $matches[2]; - $plugin_sendto = $from; - require_once $value; - break; - }elseif (preg_match("/^(".preg_quote($TAG, '/').$plugin_name.")|(".preg_quote($TAG, '/').$plugin_name.preg_quote('@').BOT_NAME.")$/", $text)) { - $plugin_text = $matches[2]; - $plugin_sendto = $from; - require_once $value; - break; - } - } - } - require_once PATH.'plugins'.DIRECTORY_SEPARATOR.'help.php'; - +} +require_once PATH.'plugins'.DIRECTORY_SEPARATOR.'help.php'; +//function +function PluginSet($desc){ + global $plugins,$plugin_name,$TAG; + $plugins[] .= $TAG.$plugin_name." ".$desc; +} ?> \ No newline at end of file diff --git a/VAR_BOT.php b/VAR_BOT.php index 735a8ec..4d8dd7d 100644 --- a/VAR_BOT.php +++ b/VAR_BOT.php @@ -2,38 +2,40 @@ //init $Pre_Type = substr(substr($_SERVER['PHP_SELF'], strrpos($_SERVER['PHP_SELF'], '/')+1), 0, -4); require_once('config.php'); -require_once('functions.php'); $plugins = array(); require(PATH.'classes'.DIRECTORY_SEPARATOR.TYPE.DIRECTORY_SEPARATOR.'Base.php'); require_once(PATH.'classes'.DIRECTORY_SEPARATOR.TYPE.DIRECTORY_SEPARATOR.'init.php'); //load plugins - - $load_plugins = glob(PATH.'plugins'.DIRECTORY_SEPARATOR.'*.php'); - foreach ($load_plugins as $key => $value) { - if ($value == PATH.'plugins'.DIRECTORY_SEPARATOR.'help.php') { - unset($load_plugins[$key]); +$load_plugins = glob(PATH.'plugins'.DIRECTORY_SEPARATOR.'*.php'); +foreach ($load_plugins as $key => $value) { + if ($value == PATH.'plugins'.DIRECTORY_SEPARATOR.'help.php') { + unset($load_plugins[$key]); + } +} +foreach ($TAGs as $TAG) { + foreach ($load_plugins as $value) { + $plugin_name = substr($value, strlen(PATH.'plugins'.DIRECTORY_SEPARATOR), -4); + if (preg_match("/^(".preg_quote($TAG, '/').$plugin_name."|".preg_quote($TAG, '/').$plugin_name.preg_quote('@').BOT_NAME.") (.*)$/", $text, $matches)) { + $plugin_text = $matches[2]; + $plugin_sendto = $from; + require_once $value; + break; + }elseif (preg_match("/^(".preg_quote($TAG, '/').$plugin_name.")|(".preg_quote($TAG, '/').$plugin_name.preg_quote('@').BOT_NAME.")$/", $text)) { + $plugin_text = $matches[2]; + $plugin_sendto = $from; + require_once $value; + break; } } - foreach ($TAGs as $TAG) { - foreach ($load_plugins as $value) { - $plugin_name = substr($value, strlen(PATH.'plugins'.DIRECTORY_SEPARATOR), -4); - if (preg_match("/^(".preg_quote($TAG, '/').$plugin_name."|".preg_quote($TAG, '/').$plugin_name.preg_quote('@').BOT_NAME.") (.*)$/", $text, $matches)) { - $plugin_text = $matches[2]; - $plugin_sendto = $from; - require_once $value; - break; - }elseif (preg_match("/^(".preg_quote($TAG, '/').$plugin_name.")|(".preg_quote($TAG, '/').$plugin_name.preg_quote('@').BOT_NAME.")$/", $text)) { - $plugin_text = $matches[2]; - $plugin_sendto = $from; - require_once $value; - break; - } - } - } - require_once PATH.'plugins'.DIRECTORY_SEPARATOR.'help.php'; - +} +require_once PATH.'plugins'.DIRECTORY_SEPARATOR.'help.php'; +//function +function PluginSet($desc){ + global $plugins,$plugin_name,$TAG; + $plugins[] .= $TAG.$plugin_name." ".$desc; +} ?> \ No newline at end of file diff --git a/classes/Telegram/Base.php b/classes/Telegram/Base.php deleted file mode 100644 index b4cedde..0000000 --- a/classes/Telegram/Base.php +++ /dev/null @@ -1,55 +0,0 @@ -_fp = stream_socket_client($Socket); - if ($this->_fp === false) { - throw new ClientException('Could not connect to socket "' . $Socket . '"'); - } - stream_set_timeout($this->_fp, 1); - } - public function __destruct() - { - fclose($this->_fp); - } - public function exec($command) - { - fwrite($this->_fp, str_replace("\n", '\n', $command) . PHP_EOL); - $answer = fgets($this->_fp); - if (is_string($answer)) { - if (substr($answer, 0, 7) === 'ANSWER ') { - $bytes = (int) substr($answer, 7); - if ($bytes > 0) { - $Response = trim(fread($this->_fp, $bytes + 1)); - return $Response; - } - }elseif ($answer === PHP_EOL) { - return true; - } - } - return false; - } - public function escapeStringArgument($argument) - { - return '"' . addslashes($argument) . '"'; - } - public function escapePeer($peer) - { - return str_replace(' ', '_', $peer); - } - - - public function msg($peer, $msg) - { - $peer = $this->escapePeer($peer); - $msg = $this->escapeStringArgument($msg); - return $this->exec('msg ' . $peer . ' ' . $msg); - } - public function send_audio($peer, $file) - { - $peer = $this->escapePeer($peer); - return $this->exec('send_audio ' . $peer . ' ' . $file); - } -} \ No newline at end of file diff --git a/classes/Telegram/init.php b/classes/Telegram/init.php deleted file mode 100644 index 1e67fee..0000000 --- a/classes/Telegram/init.php +++ /dev/null @@ -1,20 +0,0 @@ -exec("msg ".escapePeer(OWNER_NAME)." ".json_encode($_GET)); - } - - $text = $_GET['text']; -} \ No newline at end of file diff --git a/functions.php b/functions.php deleted file mode 100644 index 1b8c230..0000000 --- a/functions.php +++ /dev/null @@ -1,13 +0,0 @@ -