Big Change about Plugins
This commit is contained in:
parent
3cc20a8a89
commit
f94b5403f4
13
BOT.php
13
BOT.php
@ -8,15 +8,26 @@ 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]);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($load_plugins as $value) {
|
||||
require_once $value;
|
||||
$plugin_name = substr($value, strlen(PATH.'plugins'.DIRECTORY_SEPARATOR), -4);
|
||||
if (preg_match("/^".preg_quote(TAG, '/').$plugin_name." (.*)$/", $text, $matches)) {
|
||||
$plugin_text = $matches[1];
|
||||
$plugin_sendto = $from;
|
||||
require_once $value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
require_once PATH.'plugins'.DIRECTORY_SEPARATOR.'help.php';
|
||||
|
||||
|
||||
|
||||
?>
|
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
define('TYPE', 'Telegram');
|
||||
define('TYPE', 'Telegram-Bot');
|
||||
define('PATH', dirname(__FILE__).DIRECTORY_SEPARATOR);
|
||||
define('TAG', '#');
|
||||
define('OWNER_NAME', 'Denny Dai');
|
||||
|
@ -7,7 +7,7 @@ function escapePeer($peer){
|
||||
return str_replace(' ', '_', $peer);
|
||||
}
|
||||
|
||||
function PluginList($commands, $name){
|
||||
global $plugins;
|
||||
$plugins[] .= TAG.$commands." ".$name;
|
||||
function PluginSet($desc){
|
||||
global $plugins,$plugin_name;
|
||||
$plugins[] .= TAG.$plugin_name." ".$desc;
|
||||
}
|
@ -1,5 +1,3 @@
|
||||
<?php
|
||||
PluginList("echo", "Echo what you typed.");
|
||||
if (preg_match("/^".preg_quote(TAG, '/')."echo (.*)$/", $text, $matches)) {
|
||||
$BOT->msg($from, $matches[1]);
|
||||
}
|
||||
PluginSet("Echo what you typed.");
|
||||
$BOT->msg($plugin_sendto, $plugin_text);
|
@ -1,6 +1,10 @@
|
||||
<?php
|
||||
PluginList("help", "Ask for help");
|
||||
if (preg_match("/^".preg_quote(TAG, '/')."help$/", $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;
|
||||
|
@ -1,12 +1,10 @@
|
||||
<?php
|
||||
PluginList("ipto", "Change the form of IP address");
|
||||
if (preg_match("/^".preg_quote(TAG, '/')."ipto (.*)$/", $text, $matches)) {
|
||||
$arr = explode('.',$matches[1]);
|
||||
$msg = 'IP: '.$arr[0].'.'.$arr[1].'.'.$arr[2].'.'.$arr[3];
|
||||
$msg .= "\nint: ".($arr[0] * pow(256,3) + $arr[1] * pow(256,2) + $arr[2] * 256 + $arr[3]);
|
||||
$msg .= "\noct: 0".decoct($arr[0]).".0".decoct($arr[1]).".0".decoct($arr[2]).'.0'.decoct($arr[3]);
|
||||
$msg .= "\nhex: 0x".dechex($arr[0]).".0x".dechex($arr[1]).".0x".dechex($arr[2]).'.0x'.dechex($arr[3]);
|
||||
$msg .= "\nfucking hex: 0x0000000000".dechex($arr[0]).".0x0000000000".dechex($arr[1]).".0x0000000000".dechex($arr[2]).'.0x0000000000'.dechex($arr[3]);
|
||||
$msg .= "\nYou can combine them with any combination. Such as: 0".decoct($arr[0]).'.0x0000000000'.dechex($arr[1]).'.'.$arr[2].'.0x'.dechex($arr[3]);
|
||||
$BOT->msg($from, $msg);
|
||||
}
|
||||
PluginSet("Change the form of IP address");
|
||||
$arr = explode('.',$plugin_text);
|
||||
$msg = 'IP: '.$arr[0].'.'.$arr[1].'.'.$arr[2].'.'.$arr[3];
|
||||
$msg .= "\nint: ".($arr[0] * pow(256,3) + $arr[1] * pow(256,2) + $arr[2] * 256 + $arr[3]);
|
||||
$msg .= "\noct: 0".decoct($arr[0]).".0".decoct($arr[1]).".0".decoct($arr[2]).'.0'.decoct($arr[3]);
|
||||
$msg .= "\nhex: 0x".dechex($arr[0]).".0x".dechex($arr[1]).".0x".dechex($arr[2]).'.0x'.dechex($arr[3]);
|
||||
$msg .= "\nfucking hex: 0x0000000000".dechex($arr[0]).".0x0000000000".dechex($arr[1]).".0x0000000000".dechex($arr[2]).'.0x0000000000'.dechex($arr[3]);
|
||||
$msg .= "\nYou can combine them with any combination. Such as: 0".decoct($arr[0]).'.0x0000000000'.dechex($arr[1]).'.'.$arr[2].'.0x'.dechex($arr[3]);
|
||||
$BOT->msg($plugin_sendto, $msg);
|
@ -1,7 +1,6 @@
|
||||
<?php
|
||||
PluginList("trans", "translate");
|
||||
if (preg_match("/^".preg_quote(TAG, '/')."trans (.*)$/", $text, $matches)) {
|
||||
$matches = explode(" ", $matches[1], 2);
|
||||
PluginSet("translate");
|
||||
$matches = explode(" ", $plugin_text, 2);
|
||||
if (!isset($matches[1])) {
|
||||
$to = "en";
|
||||
$text = urlencode($matches[0]);
|
||||
@ -16,5 +15,3 @@ if (preg_match("/^".preg_quote(TAG, '/')."trans (.*)$/", $text, $matches)) {
|
||||
preg_match("/\[{.*?\}]/is", $trans, $trans_json);
|
||||
$msg = "Result: ".json_decode($trans_json[0],true)[0]["TranslatedText"];
|
||||
$BOT->msg($from, $msg);
|
||||
|
||||
}
|
@ -1,10 +1,8 @@
|
||||
<?php
|
||||
PluginList("tts", "Text To Speech");
|
||||
if (preg_match("/^".preg_quote(TAG, '/')."tts (.*)$/", $text, $matches)) {
|
||||
$mp3 = file_get_contents("http://tts.baidu.com/text2audio?lan=zh&ie=UTF-8&text=".urlencode($matches[1]));
|
||||
PluginSet("tts", "Text To Speech");
|
||||
$mp3 = file_get_contents("http://tts.baidu.com/text2audio?lan=zh&ie=UTF-8&text=".urlencode($plugin_text));
|
||||
$file = fopen($from.".mp3","w");
|
||||
echo fwrite($file,$mp3);
|
||||
fclose($file);
|
||||
$BOT->send_audio($from, "/home/wwwroot/1.vps.dennx.com/".$from.".mp3");
|
||||
//unlink($matches[1].".mp3");
|
||||
}
|
Loading…
Reference in New Issue
Block a user