• Модуль: imbot
  • Путь к файлу: ~/bitrix/modules/imbot/lib/bot/network.php
  • Класс: BitrixImBotBotNetwork
  • Вызов: Network::getUserGeoData
static function getUserGeoData()
{
	if (isset(MainApplication::getInstance()->getKernelSession()['IMBOT']['GEO_DATA']))
	{
		return MainApplication::getInstance()->getKernelSession()['IMBOT']['GEO_DATA'];
	}

	$countryCode = MainServiceGeoIpManager::getCountryCode();
	if (!$countryCode)
	{
		return defined('BOT_CLIENT_GEO_DATA') ? BOT_CLIENT_GEO_DATA : '';
	}

	$countryName = MainServiceGeoIpManager::getCountryName('', 'ru');
	if (!$countryName)
	{
		$countryName = MainServiceGeoIpManager::getCountryName();
	}

	$cityName = MainServiceGeoIpManager::getCityName('', 'ru');
	if (!$cityName)
	{
		$cityName = MainServiceGeoIpManager::getCityName();
	}

	$result = $countryCode.($countryName? ' / '.$countryName: '').($cityName? ' / '.$cityName: '');
	
	MainApplication::getInstance()->getKernelSession()['IMBOT']['GEO_DATA'] = $result;

	return $result;
}