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

17
BOT.php
View File

@ -16,16 +16,17 @@ require_once(PATH.'classes'.DIRECTORY_SEPARATOR.TYPE.DIRECTORY_SEPARATOR.'init.p
}
}
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;
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;
}
}
}
require_once PATH.'plugins'.DIRECTORY_SEPARATOR.'help.php';

View File

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

View File

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

View File

@ -1,14 +1,16 @@
<?php
if (preg_match("/^(".preg_quote(TAG, '/')."help)|(".preg_quote(TAG, '/').$plugin_name.preg_quote('@').BOT_NAME.")$/", $text)) {
foreach ($load_plugins as $value) {
$plugin_name = substr($value, strlen(PATH.'plugins'.DIRECTORY_SEPARATOR), -4);
$lines=file($value);
eval($lines[1]);
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) {
$plugin_name = substr($value, strlen(PATH.'plugins'.DIRECTORY_SEPARATOR), -4);
$lines=file($value);
eval($lines[1]);
}
$plugin_list = HELP_BEGIN."\n";
foreach ($plugins as $value) {
$plugin_list .= "\n".$value;
}
$plugin_list .= "\n\n".HELP_END;
$BOT->msg($from, $plugin_list);
}
$plugin_list = HELP_BEGIN."\n";
foreach ($plugins as $value) {
$plugin_list .= "\n".$value;
}
$plugin_list .= "\n\n".HELP_END;
$BOT->msg($from, $plugin_list);
}