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 <?php
//init //init
require('classes/Telegram/Base.php'); require_once('config.php');
$BOT = new DBot\Telegram\Base('unix:///tmp/tg.sck'); require_once('functions.php');
require_once('classes/Telegram/init.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 <?php
namespace DBot\Telegram; namespace DBot;
class Base class Base
{ {
protected $_fp; protected $_fp;

View File

@ -1,9 +1,5 @@
<?php <?php
require_once('config.inc.php');
require_once('functions.php');
$plugins = [];
if($_GET['from'] != escapePeer(BOT_NAME)){ if($_GET['from'] != escapePeer(BOT_NAME)){
//is group? //is group?
if ($_GET['to'] == escapePeer(BOT_NAME)) { 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)); $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 <?php
define('TYPE', 'Telegram');
define('PATH', dirname(__FILE__).DIRECTORY_SEPARATOR); define('PATH', dirname(__FILE__).DIRECTORY_SEPARATOR);
define('TAG', '#'); define('TAG', '#');
define('OWNER_NAME', 'Denny Dai'); define('OWNER_NAME', 'Denny Dai');