easy to set config

This commit is contained in:
Denny Dai 2015-06-26 13:37:54 +08:00
parent 88c6a081dd
commit fce895bb21
4 changed files with 24 additions and 19 deletions

25
BOT.php
View File

@ -1,6 +1,25 @@
<?php
//init
require('classes/Telegram/Base.php');
$BOT = new DBot\Telegram\Base('unix:///tmp/tg.sck');
require_once('classes/Telegram/init.php');
require_once('config.php');
require_once('functions.php');
$plugins = [];
require(PATH.'classes'.DIRECTORY_SEPARATOR.TYPE.DIRECTORY_SEPARATOR.'Base.php');
$BOT = new DBot\Base('unix:///tmp/tg.sck');
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]);
}
}
foreach ($load_plugins as $value) {
require_once $value;
}
require_once PATH.'plugins'.DIRECTORY_SEPARATOR.'help.php';
?>

View File

@ -1,5 +1,5 @@
<?php
namespace DBot\Telegram;
namespace DBot;
class Base
{
protected $_fp;

View File

@ -1,9 +1,5 @@
<?php
require_once('config.inc.php');
require_once('functions.php');
$plugins = [];
if($_GET['from'] != escapePeer(BOT_NAME)){
//is group?
if ($_GET['to'] == escapePeer(BOT_NAME)) {
@ -20,15 +16,4 @@ if($_GET['from'] != escapePeer(BOT_NAME)){
$BOT->exec("msg ".escapePeer(OWNER_NAME)." ".json_encode($_GET));
}
//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]);
}
}
foreach ($load_plugins as $value) {
require_once $value;
}
require_once PATH.'plugins'.DIRECTORY_SEPARATOR.'help.php';
}

View File

@ -1,4 +1,5 @@
<?php
define('TYPE', 'Telegram');
define('PATH', dirname(__FILE__).DIRECTORY_SEPARATOR);
define('TAG', '#');
define('OWNER_NAME', 'Denny Dai');