-1, "peerid" => -1, "status" => "nook", "info" => "no to settings @ admin channel", "to_topic" => -1, "topic_name" => -1, "name" => -1); $channelInfoNew["pandabot owner"]["name"]="@".$getSelf["username"]; $channelInfoNew["pandabot owner"]["forward"]="nook"; $channelInfoNew["pandabot owner"]["topicchannel"]=-1; $channelInfoNew["pandabot owner"]["redirectout"]=-1; $channelInfoNew["pandabot owner"]["redirectout_name"]=-1; $channelInfoNew["pandabot owner"]["redirectout_mode"]="link"; $channelInfoNew["pandabot owner"]["redirectout_tochannel"]=-1; $channelInfoNew["pandabot owner"]["redirectout_tochannel_name"]=-1; $channelInfoNew["pandabot owner"]["channelbotname"]=$globalsettings["bot"]["botname"]; $channelInfoNew["pandabot owner"]["repostinfomsg_msgid"]=-1; $channelInfoNew["pandabot owner"]["repostinfomsg_time"]=-1; $channelInfoNew["pandabot owner"]["repostinfomsg_timemode"]=-1; $channelInfoNew["pandabot owner"]["repostinfomsg_topicid"]=-1; $channelInfoNew["pandabot owner"]["channeluser"]=-1; logger("loadChannelConfig: using: ".$channelsConf); checkChannelsConf($channelsConf); $myChans=made("", "getDialogIds()", -1); $data=yaml_parse_file($channelsConf); $countsections=1; foreach(array_keys($data) as $k) { $info="ready"; // channelstatus info if (array_key_exists("from", $data[$k])) { $from=$data[$k]['from']; $t=explode(":", $from); // topic on from channel if (array_key_exists(2,$t)) { $from=$t[0]."-".$t[2]; } else $from=$t[0]; // topic hack... if (!CheckMyChannels($myChans, $t[0])) { $from_status="nook"; $from_info="not on channel"; $channelInfoNew[$from]["name"]=$k; $channelInfoNew[$from]["forward"]="nook"; $channelInfoNew[$from]["disabled"]=1; } else { $from_status="ok"; $from_info="ready"; } $channelInfoNew[$from]["chanid"]=$t[0]; $channelInfoNew[$from]["peerid"]="-100".$t[0]; $typemapping=$t; if (array_key_exists(1, $typemapping)) { if ($typemapping[1]=="topic") { $channelInfoNew[$from]["typemapping"]="video"; } else { $channelInfoNew[$from]["typemapping"]=$typemapping[1]; } // if ($typemapping=="topic") } else { $channelInfoNew[$from]["typemapping"]="video"; } // if (array_key_exists(1, $typemapping) - else $channelInfoNew[$from]["status"]=$from_status; $channelInfoNew[$from]["info"]=$from_info; $from_topic_id=-1; $from_topic_name="-1"; if ($channelInfoNew[$from]["status"] != "nook" ) if (array_key_exists(2,$t)) { $from_topic_id=$t[2]; $from_topic_name=getTopicName($channelInfoNew[$from]["chanid"], $t[2]); } // if (array_key_exists(2,$t)) $channelInfoNew[$from]["from_topic_id"]=$from_topic_id; $channelInfoNew[$from]["from_topic_name"]=$from_topic_name; } else { $from_status="nook"; $from_info="no from settings @ channel.conf, section: [".$k."]"; $from=$k; // take human input section name, when from not set @ conf $channelInfoNew[$from]["chanid"]=-1; $channelInfoNew[$from]["peerid"]=-1; $channelInfoNew[$from]["status"]=$from_status; $channelInfoNew[$from]["info"]=$from_info; $channelInfoNew[$from]["from_topic_id"]=-1; $channelInfoNew[$from]["from_topic_name"]=-1; } // if (array_key_exists("from", $data[$k])) - else if (array_key_exists("mode", $data[$k])) { $mode=$data[$k]['mode']; } else $mode=-1; $channelInfoNew[$from]["mode"]=$mode; if (array_key_exists("redirectout", $data[$k])) { $channelInfoNew[$from]["redirectout"]=explode(":",$data[$k]['redirectout'])[0]; if (array_key_exists("1",explode(":",$data[$k]['redirectout']))) { $channelInfoNew[$from]["redirectout_mode"]=explode(":",$data[$k]['redirectout'])[1]; } else $channelInfoNew[$from]["redirectout_mode"]="link"; if (array_key_exists("2",explode(":",$data[$k]['redirectout']))) { $channelInfoNew[$from]["redirectout_tochannel"]=explode(":",$data[$k]['redirectout'])[2]; } else $channelInfoNew[$from]["redirectout_tochannel"]=-1; } else $channelInfoNew[$from]["redirectout"]=-1; if (array_key_exists("channelbotname", $data[$k])) { $channelInfoNew[$from]["channelbotname"]=$data[$k]["channelbotname"]; } else { $channelInfoNew[$from]["channelbotname"]=$globalsettings["bot"]["botname"]; } // if (array_key_exists("channelbotname", $data[$k])) if (array_key_exists("repostinfomsg", $data[$k])) { $channelInfoNew[$from]["repostinfomsg_msgid"]=explode(":", $data[$k]["repostinfomsg"])[0]; $channelInfoNew[$from]["repostinfomsg_time"]=explode(":", $data[$k]["repostinfomsg"])[1]; $channelInfoNew[$from]["repostinfomsg_timemode"]=explode(":", $data[$k]["repostinfomsg"])[2]; $channelInfoNew[$from]["repostinfomsg_topicid"]=explode(":", $data[$k]["repostinfomsg"])[3]; // avoid spam $minseconds=$globalsettings["channels"]["repostinfomintimer"] * 60; $minminutes=$globalsettings["channels"]["repostinfomintimer"]; if ($channelInfoNew[$from]["repostinfomsg_timemode"]=="seconds" && ($channelInfoNew[$from]["repostinfomsg_time"] < $minseconds)) { $channelInfoNew[$from]["repostinfomsg_time"]=$minseconds; } // if ($channelInfoNew[$from]["repostinfomsg_timemode"]=="seconds" && ($channelInfoNew[$from]["repostinfomsg_time"] < 600)) if ($channelInfoNew[$from]["repostinfomsg_timemode"]=="minutes" && ($channelInfoNew[$from]["repostinfomsg_time"] < $minminutes)) { $channelInfoNew[$from]["repostinfomsg_time"]=$minminutes; } // if ($channelInfoNew[$from]["repostinfomsg_timemode"]=="minutes" && ($channelInfoNew[$from]["repostinfomsg_time"] < 10)) } else { $channelInfoNew[$from]["repostinfomsg_msgid"]=-1; $channelInfoNew[$from]["repostinfomsg_time"]=-1; $channelInfoNew[$from]["repostinfomsg_timemode"]=-1; $channelInfoNew[$from]["repostinfomsg_topicid"]=-1; } // if (array_key_exists("repost", $data[$k])) if (array_key_exists("autosync", $data[$k])) { switch($data[$k]["autosync"]) { case "true": $autosync=1; break; case "force": $autosync=2; break; default: $autosync=-1; } // switch($data[$k]["autosync"]) } else $autosync=-1; // if (array_key_exists("autosync", $data[$k])) $channelInfoNew[$from]["autosync"]=$autosync; if (array_key_exists("disabled", $data[$k]) && $channelInfoNew[$from]["status"] != "nook" ) { switch($data[$k]["disabled"]) { case "true": $disabled=1; $channelInfoNew[$from]["disabled"]=1; $channelInfoNew[$from]["status"]="nook"; $channelInfoNew[$from]["info"]="disabled by user"; break; case "updatedb": $disabled=2; $channelInfoNew[$from]["disabled"]=2; $channelInfoNew[$from]["status"]="ok"; $channelInfoNew[$from]["info"]="no forward into channel by user(updatedb)"; break; default: $disabled=-1; $channelInfoNew[$from]["disabled"]=-1; $channelInfoNew[$from]["status"]="ok"; $channelInfoNew[$from]["info"]="ready"; } // switch($data[$k]["disabled"]) } else { $disabled=-1; if ($channelInfoNew[$from]["status"] != "nook") { $channelInfoNew[$from]["disabled"]=-1; $channelInfoNew[$from]["status"]="ok"; $channelInfoNew[$from]["info"]="ready"; } // if ($channelInfoNew[$from]["status"] != "nook") } // if (array_key_exists("disabled", $data[$k]) && $channelInfoNew[$from]["status"] != "nook" ) { - else // $channelInfoNew[$from]["disabled"]=$disabled; if (array_key_exists("to", $data[$k])) { $to=$data[$k]['to']; } else $to=-1; if (is_array($to)) { if ($mode == -1) { $mode="r"; $channelInfoNew[$from]["mode"]=$mode; } // if mode not set, then change it to r $countto=1; foreach ($to as $t) { $t=explode(":", $t); if (array_key_exists(2,$t) && CheckMyChannels($myChans, $t[0])) { $to_topic=$t[2]; $tn=getConfTopicName($channelInfoNew, $t[0], $t[2]); if ($tn==false) {$topic_name=getTopicName($t[0], $t[2]);} else $topic_name=$tn; } else { $to_topic=-1; $topic_name="-1"; } if (!CheckMyChannels($myChans, $t[0])) { $to_status="nook"; $to_info="not on channel"; $name="no name"; } else { $to_status="ok"; $to_info="ready"; $name="-1"; } $channelInfoNew[$from]["to"][$t[0]]=array("chanid" => $t[0], "peerid" => "-100".$t[0], "status" => $to_status, "info" => $to_info, "to_topic" => $to_topic, "topic_name" => $topic_name, "name" => $name); if (array_key_exists($channelInfoNew[$from]["to"][$t[0]]["chanid"], $channelInfoNew)) { if ($channelInfoNew[$channelInfoNew[$from]["to"][$t[0]]["chanid"]]["disabled"] != -1) $channelInfoNew[$from]["to"][$t[0]]["info"]=$channelInfoNew[$channelInfoNew[$from]["to"][$t[0]]["chanid"]]["info"]; // if ($channelInfoNew[$channelInfoNew[$from]["to"][$t[0]]["chanid"]]["disabled"] == 1) $channelInfoNew[$from]["to"][$t[0]]["status"]=$channelInfoNew[$channelInfoNew[$from]["to"][$t[0]]["chanid"]]["status"]; } // if (array_key_exists($channelInfoNew[$from]["to"][$t[0]]["chanid"], $channelInfoNew)) $countto++; } // foreach ($to as $t) } else { $name="-1"; $topic_name="-1"; $to_status="nook"; $to_info="no to settings @ channel.conf, section: [".$k."]"; $to_topic=-1; $channelInfoNew[$from]["to"]["-1"]=array("chanid" => -1, "peerid" => -1, "status" => $to_status, "info" => $to_info, "to_topic" => $to_topic, "topic_name" => $topic_name, "name" => $name); } // if (is_array($to)) - else $countsections++; } // foreach($keys as $k) // info section $allchannels=array(); foreach ($channelInfoNew as $chan) { if ($chan["mode"] != "a" ) { // do not insert admin channel if ($chan["peerid"]!="-1") if ($chan["status"]=="ok" || ($chan["status"]=="nook" && $chan["disabled"]==1 && $chan["info"] != "not on channel")) if (!asearch($chan["peerid"], $allchannels)) $allchannels[]=$chan["peerid"]; foreach($chan["to"] as $t) if ($t["status"]=="ok") if (!asearch($t["peerid"], $allchannels)) $allchannels[]=$t["peerid"]; } // if ($chan["mode"] != "a" ) } $dialog=made("messages", "getPeerDialogs", array("peers" => $allchannels)); foreach (array_keys($channelInfoNew) as $k) { if ($channelInfoNew[$k]["mode"] != "a" ) { // do not change admin user if ($channelInfoNew[$k]["peerid"]!="-1") { if ($channelInfoNew[$k]["status"]=="ok" || ($channelInfoNew[$k]["status"] == "nook" && $channelInfoNew[$k]["disabled"] == 1 && $channelInfoNew[$k]["info"] != "not on channel")) { /* if ($channelInfoNew[$k]["from_topic_id"] !=-1 ) { $channelInfoNew[$k]["name"]=removeChannelAds(cleanupString(CheckDialog($dialog, $channelInfoNew[$k]["peerid"], "chats", "title")))."-".$channelInfoNew[$k]["from_topic_name"]; } else $channelInfoNew[$k]["name"]=removeChannelAds(cleanupString(CheckDialog($dialog, $channelInfoNew[$k]["peerid"], "chats", "title"))); */ if ($channelInfoNew[$k]["from_topic_id"] !=-1 ) { $channelInfoNew[$k]["name"]=CheckDialog($dialog, $channelInfoNew[$k]["peerid"], "chats", "title")."-".$channelInfoNew[$k]["from_topic_name"]; } else $channelInfoNew[$k]["name"]=CheckDialog($dialog, $channelInfoNew[$k]["peerid"], "chats", "title"); if (CheckDialog($dialog, $channelInfoNew[$k]["peerid"], "chats", "forum") == 1) { $channelInfoNew[$k]["topicchannel"]=1; } else $channelInfoNew[$k]["topicchannel"]=-1; if (CheckDialog($dialog, $channelInfoNew[$k]["peerid"], "chats", "noforwards") == 1) { $channelInfoNew[$k]["forward"]="nook"; $channelInfoNew[$k]["status"]="nook"; $channelInfoNew[$k]["info"]="forward disabled"; } else { $channelInfoNew[$k]["forward"]="ok"; } // if (CheckDialog($dialog, $channelInfoNew[$k]["chanid"], "chats", "noforwards") == 1) - else if (is_array(CheckDialog($dialog,$channelInfoNew[$k]["peerid"], "chats", "restriction_reason"))) { $restriction_reason=CheckDialog($dialog,$channelInfoNew[$k]["peerid"], "chats", "restriction_reason"); switch ($restriction_reason["0"]["reason"]) { case "copyright": $channelInfoNew[$k]["status"]="nook"; $channelInfoNew[$k]["info"]=$restriction_reason["0"]["text"]; break; case "porn": $channelInfoNew[$k]["status"]="ok"; $channelInfoNew[$k]["info"]="ready, but: ".$restriction_reason["0"]["text"]; break; default: $channelInfoNew[$k]["status"]="ok"; $channelInfoNew[$k]["info"]="ready, but: ".$restriction_reason["0"]["text"]; } // switch ($dialog["chats"]["0"]["restriction_reason"]["0"]["reason"]) } // if (is_array(CheckDialog($dialog,$channelInfoNew[$k]["chanid"], "chats", "restriction_reason")) } // if ($channelInfoNew[$k]["chanid"]!="-1") if ($channelInfoNew[$k]["status"]=="ok") } else { $channelInfoNew[$k]["name"]=$k; } // if ($channelInfoNew[$k]["chanid"]!="-1") - else foreach(array_keys($channelInfoNew[$k]["to"]) as $tk) if ($channelInfoNew[$k]["to"][$tk]["status"]=="ok") { /* $channelInfoNew[$k]["to"][$tk]["name"]=removeChannelAds(cleanupString(CheckDialog($dialog, $channelInfoNew[$k]["to"][$tk]["peerid"], "chats", "title"))); */ $channelInfoNew[$k]["to"][$tk]["name"]=CheckDialog($dialog, $channelInfoNew[$k]["to"][$tk]["peerid"], "chats", "title"); } // foreach(array_keys($channelInfoNew[$k]["to"]) as $tk) if ($channelInfoNew[$k]["to"][$tk]["status"]=="ok") } // if ($channelInfoNew[$k]["mode"] != "a" ) } // foreach (array_keys($channelInfoNew) as $k) // redirectout - extra round foreach (array_keys($channelInfoNew) as $k) { if ($channelInfoNew[$k]["redirectout"]!="-1") { if (array_key_exists($channelInfoNew[$k]["redirectout"],$channelInfoNew)) { $channelInfoNew[$k]["redirectout_name"]=$channelInfoNew[$channelInfoNew[$k]["redirectout"]]["name"]; } else $channelInfoNew[$k]["redirectout"]=-1; } // if ($channelInfoNew[$k]["redirectout"]!="-1") } // foreach (array_keys($channelInfoNew) as $k) // redirectout_tochannel - extra round && predefine admins element foreach (array_keys($channelInfoNew) as $k) { if ($channelInfoNew[$k]["redirectout"]!="-1") { if (array_key_exists($channelInfoNew[$k]["redirectout_tochannel"],$channelInfoNew)) { $channelInfoNew[$k]["redirectout_tochannel_name"]=$channelInfoNew[$channelInfoNew[$k]["redirectout_tochannel"]]["name"]; } else $channelInfoNew[$k]["redirectout_tochannel"]=-1; } // if ($channelInfoNew[$k]["redirectout"]!="-1") } // foreach (array_keys($channelInfoNew) as $k) $globalsettings["channels"]["channelinfo"]=$channelInfoNew; shm_put_var($shm, 4, $globalsettings["channels"]["channelinfo"]); // print_r($globalsettings); // exit(); return $globalsettings["channels"]["channelinfo"]; } // function end function writeChannelConfig($channelInfoNew) { global $globalsettings; //print_r($channelInfoNew); $channelsConf="conf/channels.conf"; if (file_exists($channelsConf)) unlink($channelsConf); // remove channels.conf $header="# attention: bot rewrite hes own conf file in human readable form # all \"to:\" channels automatical r mode and will be readed # all channels without \"to:\" will be still readed and saved in database # from and section names must be unique, otherwise, the last find will be used # example section config: # ----------------------- # # '': # mode: r # modus i for interactiv (botcommands) or r for readonly - ir = interactiv + request mode # channelbotname: name # overwrites pandabot.conf:botcommand eg. eva, adam or ... default is pandabot.conf:botcommand # autosync: true # or false - is false by default - ATTENTION! TARGET CHANNEL SHOULD BE FULL READ @ DATABASE! # disabled: true # or updatedb or false - is false by default # from: # from:type:topicid - forward only files from specificated topic # to: # - # - :topic: # send forwards in topic # - # - # - ... # # redirectout: :: # means print search/ last results from another channel() to current channel # is configured, he will search in channelid and forward to targetchannelid # eg. channel1: search in channelid and will forward to targetchannelid # use ! last channel:current to list last entrys in current channel # use ! search channel:current to search in current channel # # repostinfomsg: :