Skip to content

Commit

Permalink
1.1.5
Browse files Browse the repository at this point in the history
   - code cleanup
  • Loading branch information
S3x0r committed Dec 28, 2020
1 parent 2c5fb88 commit d987fc8
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 176 deletions.
2 changes: 1 addition & 1 deletion CONFIG.INI
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ command_prefix = '!'
ctcp_response = 'yes'

; ctcp version response (please do not change it:)
ctcp_version = 'MINION (1.1.4) powered by minions!'
ctcp_version = 'MINION (1.1.5) powered by minions!'

; ctcf finger response
ctcp_finger = 'MINION'
Expand Down
5 changes: 4 additions & 1 deletion DOCS/CHANGELOG.TXT
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@


v1.1.5 changes (28.12.2020):
- code cleanup

v1.1.4 changes (26.12.2020):
- Plugin: restart - now escapes from parent process
- Plugin: server - now escapes from parent process
Expand Down
18 changes: 8 additions & 10 deletions src/core_commands.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
'Visit <a href="https://github.com/S3x0r/MINION/">this page</a> for more information.') : false;
//---------------------------------------------------------------------------------------------------------

function CoreCmd_Seen()
function plugin_seen()
{
if (OnEmptyArg('seen <nickname> to check specified user when was last seen on channel')) {
} else { /* prevent directory traversal */
Expand All @@ -39,8 +39,6 @@ function CoreCmd_Seen()
response(file_get_contents(DATADIR."/SEEN/{$GLOBALS['args']}")) : response('No such user in my database.');

}

cliLog("[PLUGIN: seen] Used by: {$GLOBALS['USER']} ({$GLOBALS['USER_HOST']}), channel: ".getBotChannel());
}
}
//---------------------------------------------------------------------------------------------------------
Expand All @@ -61,7 +59,7 @@ function SeenSave()
@file_put_contents($seenDataDir.$GLOBALS['USER'], $data) : @file_put_contents($seenDataDir.$GLOBALS['USER'], $data);
}
//---------------------------------------------------------------------------------------------------------
function CoreCmd_Pause()
function plugin_pause()
{
response('Pausing all activity');

Expand All @@ -72,7 +70,7 @@ function CoreCmd_Pause()
cliLog('[bot] Im in Pause mode');
}
//---------------------------------------------------------------------------------------------------------
function CoreCmd_Unpause()
function plugin_unpause()
{
if (isset($GLOBALS['stop'])) {
unset($GLOBALS['stop']);
Expand All @@ -85,7 +83,7 @@ function CoreCmd_Unpause()
}
}
//---------------------------------------------------------------------------------------------------------
function CoreCmd_Panel()
function plugin_panel()
{
if (OnEmptyArg('panel <help> to list commands')) {
} else {
Expand Down Expand Up @@ -138,7 +136,7 @@ function CoreCmd_Panel()
cliLog("[PLUGIN: panel] Used by: {$GLOBALS['USER']} ({$GLOBALS['USER_HOST']}), channel: ".getBotChannel());
}
//---------------------------------------------------------------------------------------------------------
function CoreCmd_Load()
function plugin_load()
{
if (empty($GLOBALS['args'])) {
response("Usage {$GLOBALS['CONFIG_CMD_PREFIX']}load <plugin_name>");
Expand All @@ -147,7 +145,7 @@ function CoreCmd_Load()
}
}
//---------------------------------------------------------------------------------------------------------
function CoreCmd_Unload()
function plugin_unload()
{
if (empty($GLOBALS['args'])) {
response("Usage {$GLOBALS['CONFIG_CMD_PREFIX']}unload <plugin_name>");
Expand Down Expand Up @@ -217,8 +215,8 @@ function CoreCmd_RegisterToBot()
}
} else {
$hashed = hash('sha256', $GLOBALS['args']);
/* if user is already an owner */
$hashed == $GLOBALS['CONFIG_OWNER_PASSWD'] ? response('You are already my owner') : false;
/* if user is already an owner */
$hashed == $GLOBALS['CONFIG_OWNER_PASSWD'] ? response('You are already my owner') : false;
}
}
} catch (Exception $e) {
Expand Down
17 changes: 12 additions & 5 deletions src/ctcp.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,16 @@
'Visit <a href="https://github.com/S3x0r/MINION/">this page</a> for more information.') : false;
//---------------------------------------------------------------------------------------------------------

function CTCP()
function if_CTCP()
{
global $rawcmd;

if (empty($GLOBALS['stop']) && $GLOBALS['CONFIG_CTCP_RESPONSE'] == 'yes' && isset($rawcmd[1][0]) && $rawcmd[1][0] == '') {
on_CTCP();
}
}
//---------------------------------------------------------------------------------------------------------
function on_CTCP()
{
switch ($GLOBALS['rawcmd'][1]) {
case 'version':
Expand Down Expand Up @@ -59,16 +68,14 @@ function CTCP()
break;

case 'ping':
$a = str_replace(' ', '', $GLOBALS['args']);
toServer("NOTICE {$GLOBALS['USER']} :PING {$a}");
toServer("NOTICE {$GLOBALS['USER']} :PING ".str_replace(' ', '', $GLOBALS['args']));

cliLog("[bot] ctcp PING by: {$GLOBALS['USER']} ({$GLOBALS['USER_HOST']})");
PlaySound('ctcp.mp3');
break;

case 'time':
$a = date("F j, Y, g:i a");
toServer("NOTICE {$GLOBALS['USER']} :TIME {$a}");
toServer("NOTICE {$GLOBALS['USER']} :TIME ".date("F j, Y, g:i a"));

cliLog("[bot] ctcp TIME by: {$GLOBALS['USER']} ({$GLOBALS['USER_HOST']})");
PlaySound('ctcp.mp3');
Expand Down
2 changes: 1 addition & 1 deletion src/define.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
exit('This script can\'t be run from a web browser. Use CLI terminal to run it<br>'.
'Visit <a href="https://github.com/S3x0r/MINION/">this page</a> for more information.') : false;
//---------------------------------------------------------------------------------------------------------
define('VER', '1.1.4');
define('VER', '1.1.5');
//---------------------------------------------------------------------------------------------------------
define('START_TIME', time());
define('PHP_VER', phpversion());
Expand Down
24 changes: 20 additions & 4 deletions src/events.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,24 @@
'Visit <a href="https://github.com/S3x0r/MINION/">this page</a> for more information.') : false;
//---------------------------------------------------------------------------------------------------------

function if_REPLY()
{
global $rawDataArray;

if (isset($rawDataArray[1]) && is_numeric($rawDataArray[1])) {
function_exists('on_'.$rawDataArray[1]) ? call_user_func('on_'.$rawDataArray[1]) : false;
}
}
//---------------------------------------------------------------------------------------------------------
function if_OPERATION()
{
global $rawDataArray;

if (isset($rawDataArray[1]) && in_array($rawDataArray[1], ['JOIN', 'PART', 'KICK', 'TOPIC', 'PRIVMSG', 'NICK', 'QUIT', 'MODE'])) {
function_exists('on_'.$rawDataArray[1]) ? call_user_func('on_'.$rawDataArray[1]) : false;
}
}
//---------------------------------------------------------------------------------------------------------
function on_server_ping()
{
/* send PONG */
Expand All @@ -28,10 +46,8 @@ function on_server_ping()
//---------------------------------------------------------------------------------------------------------
function on_001() /* server message */
{
/* :server.name 001 minion :Welcome to the Testnet IRC Network minion!minion@localhost */

/* 1.set server name */
$GLOBALS['serverName'] = $GLOBALS['rawDataArray'][0];
setServerName($GLOBALS['rawDataArray'][0]);

/* 1.set bot nickname */
setBotNickname($GLOBALS['rawDataArray'][2]);
Expand Down Expand Up @@ -273,7 +289,7 @@ function on_quit()
//---------------------------------------------------------------------------------------------------------
function on_TOPIC() /* topic change */
{
cliLog('['.getBotChannel().'] * '.$GLOBALS['USER'].'('.$GLOBALS['USER_HOST'].') sets topic: "'.inputFromLine('3').'"');
cliLog('['.getBotChannel().'] * '.$GLOBALS['USER'].' ('.$GLOBALS['USER_HOST'].') sets topic: "'.inputFromLine('3').'"');
}
//---------------------------------------------------------------------------------------------------------
function on_privmsg()
Expand Down
42 changes: 42 additions & 0 deletions src/plugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,48 @@
'Visit <a href="https://github.com/S3x0r/MINION/">this page</a> for more information.') : false;
//---------------------------------------------------------------------------------------------------------

function if_PLUGIN()
{
global $rawcmd;
global $rawDataArray;
global $mask;

/* Unpause -OWNER- core command */
(HasOwner($mask) && isset($rawcmd[1]) && $rawcmd[1] == $GLOBALS['CONFIG_CMD_PREFIX'].'unpause') ? plugin_Unpause() : false;

if (empty($GLOBALS['stop'])) {
/* register to bot - core command */
(isset($rawcmd[1]) && $rawcmd[1] == 'register' && $rawDataArray[2] == getBotNickname()) ? CoreCmd_RegisterToBot() : false;
//---------------------------------------------------------------------------------------------------------
/* response to plugins requests */
if (isset($rawcmd[1][0]) && $rawcmd[1][0] == $GLOBALS['CONFIG_CMD_PREFIX']) {
$pluginReq = str_replace($GLOBALS['CONFIG_CMD_PREFIX'], '', $rawcmd[1]);
$p = $GLOBALS['CONFIG_CMD_PREFIX'];

/* OWNER */
if (HasOwner($mask) && in_array_r($rawcmd[1], [$p.'seen', $p.'panel', $p.'load', $p.'unload', $p.'pause',
$GLOBALS['OWNER_PLUGINS'], $GLOBALS['ADMIN_PLUGINS'], $GLOBALS['USER_PLUGINS']])) {
call_user_func('plugin_'.$pluginReq);
pluginUsageCli($pluginReq);
/* ADMIN */
} elseif (!HasOwner($mask) && HasAdmin($mask) && in_array_r($rawcmd[1], [$p.'seen', $GLOBALS['ADMIN_PLUGINS'], $GLOBALS['USER_PLUGINS']])) {
call_user_func('plugin_'.$pluginReq);
pluginUsageCli($pluginReq);
/* USER */
} elseif (!HasOwner($mask) && !HasAdmin($mask) && in_array_r($rawcmd[1], [$p.'seen', $GLOBALS['USER_PLUGINS']])) {
call_user_func('plugin_'.$pluginReq);
pluginUsageCli($pluginReq);
}

if (!function_exists('plugin_')) {
function plugin_()
{
}
}
}
}
}
//---------------------------------------------------------------------------------------------------------
function LoadPlugins()
{
$CountedOwner = count(glob("PLUGINS/OWNER/*.php", GLOB_BRACE));
Expand Down
Loading

0 comments on commit d987fc8

Please sign in to comment.