Skip to content

Commit b304f7b

Browse files
authored
x
1 parent 2523fa1 commit b304f7b

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

bot.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,23 @@ function get_vardump($var) {
3737
}
3838
};
3939

40-
for ($i=0; $i<sizeof($config["plugins"]); $i++) {
41-
$actual_plugin = include "plugins/".$config["plugins"][$i];
40+
foreach ($config["plugins"] as $plugin) {
41+
$actual_plugin = include_once "plugins/".$plugin;
42+
$actioned = false;
4243
if (isset($actual_plugin["pre_process"])) {
43-
call_user_func($actual_plugin["pre_process"], $bot, $msg, $matches);
44+
call_user_func($actual_plugin["pre_process"], $msg);
4445
};
4546
if (isset($actual_plugin["exe"])) {
46-
for ($m=0; $m<sizeof($actual_plugin["patterns"]); $m++) {
47-
preg_match($actual_plugin["patterns"][$m], $msg["text"], $matches, PREG_OFFSET_CAPTURE);
47+
foreach ($actual_plugin["patterns"] as $pattern) {
48+
preg_match($pattern, $msg["text"], $matches, PREG_OFFSET_CAPTURE);
4849
if ($matches) {
49-
call_user_func($actual_plugin["exe"], $bot, $msg, $matches);
50+
call_user_func($actual_plugin["exe"], $msg, $matches);
51+
$actioned = true;
5052
break;
51-
}
52-
}
53+
};
54+
};
5355
};
56+
if ($actioned) { break; };
5457
};
5558

5659
ini_set('display_errors', 1);

0 commit comments

Comments
 (0)