Muti-TAGs

This commit is contained in:
Denny Dai 2015-07-01 04:35:29 +08:00
parent 1f1fd24782
commit 9a0ffb2fc0
4 changed files with 25 additions and 22 deletions

View File

@ -16,16 +16,17 @@ require_once(PATH.'classes'.DIRECTORY_SEPARATOR.TYPE.DIRECTORY_SEPARATOR.'init.p
} }
} }
foreach ($TAGs as $TAG) {
foreach ($load_plugins as $value) { foreach ($load_plugins as $value) {
$plugin_name = substr($value, strlen(PATH.'plugins'.DIRECTORY_SEPARATOR), -4); $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)) { if (preg_match("/^(".preg_quote($TAG, '/').$plugin_name."|".preg_quote($TAG, '/').$plugin_name.preg_quote('@').BOT_NAME.") (.*)$/", $text, $matches)) {
$plugin_text = $matches[2]; $plugin_text = $matches[2];
$plugin_sendto = $from; $plugin_sendto = $from;
require_once $value; require_once $value;
break; break;
} }
} }
}
require_once PATH.'plugins'.DIRECTORY_SEPARATOR.'help.php'; require_once PATH.'plugins'.DIRECTORY_SEPARATOR.'help.php';

View File

@ -1,11 +1,11 @@
<?php <?php
define('TYPE', 'Telegram-Bot'); define('TYPE', 'Telegram-Bot');
define('PATH', dirname(__FILE__).DIRECTORY_SEPARATOR); define('PATH', dirname(__FILE__).DIRECTORY_SEPARATOR);
define('TAG', '#');
define('OWNER_NAME', 'Denny Dai'); define('OWNER_NAME', 'Denny Dai');
define('BOT_NAME', 'D_bot'); define('BOT_NAME', 'D_bot');
define('HELP_BEGIN', "Welcome to use TG-BOT"); define('HELP_BEGIN', "Welcome to use TG-BOT");
define('HELP_END', "GitHub: https://github.com/dennydai/D-bot\nAuthor: @DennyDai"); define('HELP_END', "GitHub: https://github.com/dennydai/D-bot\nAuthor: @DennyDai");
$TAGs = array('#','/','!');
//For Telegram-Bot //For Telegram-Bot

View File

@ -8,6 +8,6 @@ function escapePeer($peer){
} }
function PluginSet($desc){ function PluginSet($desc){
global $plugins,$plugin_name; global $plugins,$plugin_name,$TAG;
$plugins[] .= TAG.$plugin_name." ".$desc; $plugins[] .= $TAG.$plugin_name." ".$desc;
} }

View File

@ -1,5 +1,6 @@
<?php <?php
if (preg_match("/^(".preg_quote(TAG, '/')."help)|(".preg_quote(TAG, '/').$plugin_name.preg_quote('@').BOT_NAME.")$/", $text)) { foreach ($TAGs as $TAG) {
if (preg_match("/^(".preg_quote($TAG, '/')."help)|(".preg_quote($TAG, '/').$plugin_name.preg_quote('@').BOT_NAME.")$/", $text)) {
foreach ($load_plugins as $value) { foreach ($load_plugins as $value) {
$plugin_name = substr($value, strlen(PATH.'plugins'.DIRECTORY_SEPARATOR), -4); $plugin_name = substr($value, strlen(PATH.'plugins'.DIRECTORY_SEPARATOR), -4);
$lines=file($value); $lines=file($value);
@ -11,4 +12,5 @@ if (preg_match("/^(".preg_quote(TAG, '/')."help)|(".preg_quote(TAG, '/').$plugin
} }
$plugin_list .= "\n\n".HELP_END; $plugin_list .= "\n\n".HELP_END;
$BOT->msg($from, $plugin_list); $BOT->msg($from, $plugin_list);
}
} }