$globalsettings["bot"]["lastbotcommands"]["commands"][$commandskey]) + $globalsettings["bot"]["lastbotcommands"]["commands"];
// restrict array length
$globalsettings["bot"]["lastbotcommands"]["commands"]=array_slice($globalsettings["bot"]["lastbotcommands"]["commands"], 0, $globalsettings["bot"]["lastbotcommands"]["count"]);
} // function end
function showlastbotcommands($arguments) {
global $globalsettings;
$outputcounter=0;
$output="list last ".$globalsettings["bot"]["lastbotcommands"]["count"]." botcommands: ";
if (array_key_exists(1,$arguments)) {
switch ($arguments[1]) {
case "help": $output.="lastbotcommands(list over all channels> lastbotcommands ".htmlspecialchars("")." (show only channel 123, use channelstatus) ";
$help=1;
break;
default:
if (!array_key_exists($arguments[1], $globalsettings["bot"]["channelinfo"])) {
$output.="channelid: ".$arguments[1]." does not exists! try: channelstatus
lastbotcommands ";
$help=1;
} else {
$setchannel=$arguments[1];
} // if (!array_key_exists($arguments[1], $globalsettings["bot"]["channelinfo"])) {
} // switch ($arguments)
} // if (array_key_exists(1,$arguments))
if (array_key_exists("commands", $globalsettings["bot"]["lastbotcommands"]) && is_array($globalsettings["bot"]["lastbotcommands"]["commands"]) && count($globalsettings["bot"]["lastbotcommands"]["commands"])!=0 && !isset($help)) {
foreach ($globalsettings["bot"]["lastbotcommands"]["commands"] as $command) {
if (!isset($setchannel)) {
$outputcounter++;
$output.="channel: ".$command["channelname"].", user: @".$command["username"]." ";
$output.="command(".date('m/d/Y H:i:s', $command["msgdate"])."): ".$command["message"]." -- ";
} else {
if ($setchannel==$command["channelid"]) {
$outputcounter++;
$output.="channel: ".$command["channelname"].", user: @".$command["username"]." ";
$output.="command(".date('m/d/Y H:i:s', $command["msgdate"])."): ".$command["message"]." -- ";
} // if ($setchannel==$command["channelid"])
} // if (!isset($setchannel))
} // foreach ($globalsettings["bot"]["lastbotcommands"]["commands"] as $commands)
} else {
if (!isset($help) || $outputcounter!=0) $output.="no botcommands used ";
} // if (array_key_exists("commands",$globalsettings["bot"]["lastbotcommands"]) && count($globalsettings["bot"]["lastbotcommands"]["commands"])!=0)
$topicid=-1;
sendmessageintochannel("pandabot owner", $output, $topicid);
} // function end
function channel_detail($channel){
global $globalsettings, $channelInfoNew;
$channelInfoKey=$channel[1];
$topicid=-1;
if (!array_key_exists($channelInfoKey, $channelInfoNew)) {
$output="channelid: ".$channelInfoKey." does not exists! ";
sendmessageintochannel("pandabot owner", $output, $topicid);
return;
} // if (!array_key_exists($channelInfoKey, $channelInfoNew))
$output="";
$output.="name: ".htmlspecialchars($channelInfoNew[$channelInfoKey]["name"])."
";
$output.="channelbotname: ".htmlspecialchars($channelInfoNew[$channelInfoKey]["channelbotname"])." ";
switch ($channelInfoNew[$channelInfoKey]["mode"]) {
case "a": $output.="mode: admin ";
break;
case "i": $output.="mode: interactiv ";
break;
case "ir": $output.="mode: interactiv+request ";
break;
case "r": $output.="mode: read only ";
break;
} // switch ($channelInfoNew[$channelInfoKey]["mode"])
$output.="typemapping: ".$channelInfoNew[$channelInfoKey]["typemapping"]." ";
switch ($channelInfoNew[$channelInfoKey]["autosync"]) {
case -1: $output.="autosync: false ";
break;
case 1: $output.="autosync: true ";
break;
case 2: $output.="autosync: force ";
break;
} // switch ($channelInfoNew[$channelInfoKey]["autosync"])
switch ($channelInfoNew[$channelInfoKey]["disabled"]) {
case -1: $output.="disabled: false ";
break;
case 1: $output.="disabled: true ";
break;
case 2: $output.="disabled: updatedb ";
break;
} // switch ($channelInfoNew[$channelInfoKey]["disabled"])
if (array_key_exists("-1", $channelInfoNew[$channelInfoKey]["to"])) {
$output.="to: no target channels configured ";
} else {
$output.="to: ";
foreach (array_keys($channelInfoNew[$channelInfoKey]["to"]) as $t) {
$output.=" - ".$channelInfoNew[$channelInfoKey]["to"][$t]["name"]." ";
} // foreach (array_keys($channelInfoNew[$channelInfoKey]["to"]) as $t)
} // if (array_key_exists("-1", $channelInfoNew[$channelInfoKey]["to"]))
$output.=" ";
if ($channelInfoNew[$channelInfoKey]["redirectout"]==-1) {
$output.="redirect: not configured ";
} else {
$output.="redirect from: ".htmlspecialchars($channelInfoNew[$channelInfoKey]["redirectout_name"])." ";
$output.="redirect mode: ".htmlspecialchars($channelInfoNew[$channelInfoKey]["redirectout_mode"])." ";
if ($channelInfoNew[$channelInfoKey]["redirectout_tochannel"]!=-1) {
$output.="redirect to: ".htmlspecialchars($channelInfoNew[$channelInfoKey]["redirectout_tochannel_name"])." ";
} else {
$output.="redirect to: ".htmlspecialchars($channelInfoNew[$channelInfoKey]["name"])." ";
} // if ($channelInfoNew[$channelInfoKey]["redirectout_tochannel"]==-1)
} // if ($channelInfoNew[$channelInfoKey]["redirectout"]==-1))
if (array_key_exists(2,$channel) && $channel[2]=="dump") {$output=htmlspecialchars(print_r($channelInfoNew[$channelInfoKey], true));}
sendmessageintochannel("pandabot owner", $output, $topicid);
} // function end
function ifconfigkeyvaluevalid($key, $value) {
global $globalsettings;
switch ($key) {
case "mode":
foreach($globalsettings["bot"]["channelmode"] as $mode) {
if ($value == $mode) {
return $value;
} // if ($value == $mode)
} // foreach($globalsettings["bot"]["channelmode"] as $mode)
return false;
break;
case "autosync":
// echo "autosync here ".$value."\n";
foreach($globalsettings["bot"]["autosyncmode"] as $mode) {
switch ($value) {
case "true": if ($mode==$value) return 1;
break;
case "force": if ($mode==$value) return 2;
break;
case "false": if ($mode==$value) return -1;
break;
} // switch ($mode)
} // foreach($globalsettings["bot"]["autosyncmode"] as $mode)
return false;
break;
case "disabled":
// echo "disabled here ".$value."\n";
foreach($globalsettings["bot"]["disabledmode"] as $mode) {
switch ($value) {
case "true": if ($mode==$value) return 1;
break;
case "updatedb": if ($mode==$value) return 2;
break;
case "false": if ($mode==$value) return -1;
break;
} // switch ($mode)
} // foreach($globalsettings["bot"]["autosyncmode"] as $mode)
return false;
break;
case "channelbotname":
// echo "channelbotname here ".$value."\n";
if (preg_match("/^[a-zA-Z]+$/", $value) && strlen($value)<7) {
return $value;
} else {
return false;
} // if (preg_match("/^[a-zA-Z]+$/", $value)
break;
} // switch ($key)
} // function end
function setchannel($arguments) {
global $globalsettings, $channelInfoNew;
$usage="usage: setchannel ".htmlspecialchars("