Пример #1
0
            $bot->add_allymsg($message);
        } else {
            $bot->add_privmsg($message, $data['user']);
        }
        return true;
    } else {
        $bot->add_privmsg("Ne Ne Ne!", $data['user']);
    }
}, 'settlers');
$bot->add_msg_hook(array(PRIVATEIN, ALLYIN), "AddLawless", "LouBot_add_lawless", true, '/(addlawless|addll)/i', function ($bot, $data) {
    global $redis;
    if ($bot->is_ally_user($data['user']) && !$bot->is_himself($data['user'])) {
        $message = "Add lawless:";
        if (is_array($data['params'])) {
            foreach ($data['params'] as $ll) {
                if (Lou::is_string_pos(Lou::prepare_chat($ll))) {
                    // is position?
                    $pos = Lou::get_pos_by_string(Lou::prepare_chat($ll));
                    $continent = $bot->lou->get_continent_by_pos($pos);
                    $continent_key = "continent:{$continent}";
                    if ($redis->sAdd("{$continent_key}:lawless", $pos)) {
                        $message .= " {$pos}|Ok";
                        $str_time = (string) time();
                        $city_id = $redis->hGet('cities', $pos);
                        $city_key = "city:{$city_id}";
                        $city = $redis->hGetALL("{$city_key}:data");
                        $redis->hMset("{$city_key}:data", array('ll_time' => $str_time, 'll_name' => $city['name'], 'll_state' => $city['state'], 'll_points' => $city['points'], 'll_user_id' => $city['user_id'], 'll_category' => $city['category'], 'll_alliance_id' => $city['alliance_id']));
                    } else {
                        $message .= " {$pos}|Nok";
                    }
                }