Example #1
0
void BnxDriver::LoadBot(const IniFile::Section &clSection) {
	bool bEnabled = clSection.GetValue<bool>("enabled", true);

	if (!bEnabled)
		return;

	std::string strServer = clSection.GetValue<std::string>("server", "");
	std::string strNickname = clSection.GetValue<std::string>("nickname", "");

	if (strServer.empty() || strNickname.empty())
		return;

	BnxBot *pclBot = GetBot(clSection.GetName());

	if (pclBot == NULL) {
		pclBot = new BnxBot();
		pclBot->SetProfileName(clSection.GetName());

		m_vBots.push_back(pclBot);
	}

	std::string strPort = clSection.GetValue<std::string>("port", "6667");
	std::string strUsername = clSection.GetValue<std::string>("username", "BnxBot");
	std::string strRealName = clSection.GetValue<std::string>("realname", "BnxBot");
	std::string strAccessList = clSection.GetValue<std::string>("accesslist", "access.lst");
	std::string strShitList = clSection.GetValue<std::string>("shitlist", "shit.lst");
	std::string strSeenList = clSection.GetValue<std::string>("seenlist", "seen.lst");
	std::string strResponseRules = clSection.GetValue<std::string>("responserules", "response.txt");
	std::string strHomeChannels = clSection.GetValue<std::string>("homechannels", "");
	std::string strNickServ = clSection.GetValue<std::string>("nickserv", "");
	std::string strNickServPassword = clSection.GetValue<std::string>("nickservpassword", "");
	
	pclBot->SetServerAndPort(strServer, strPort);
	pclBot->SetNickServAndPassword(strNickServ, strNickServPassword);
	pclBot->SetNickname(strNickname);
	pclBot->SetUsername(strUsername);
	pclBot->SetRealName(strRealName);
	pclBot->LoadResponseRules(strResponseRules);
	pclBot->LoadAccessList(strAccessList);
	pclBot->LoadShitList(strShitList);
	pclBot->LoadSeenList(strSeenList);
	pclBot->SetLogFile(m_strLogFile);
	pclBot->SetHomeChannels(strHomeChannels);
}
  void LoadFromSystemSection(Config::Layer* layer, const IniFile::Section& section) const
  {
    const std::string section_name = section.GetName();

    // Regular key,value pairs
    const IniFile::Section::SectionMap& section_map = section.GetValues();

    for (const auto& value : section_map)
    {
      const auto location = MapINIToRealLocation(section_name, value.first);

      if (location.section.empty() && location.key.empty())
        continue;

      layer->Set(location, value.second);
    }
  }
Example #3
0
  void LoadFromSystemSection(Config::Layer* config_layer, const IniFile::Section& section) const
  {
    const std::string section_name = section.GetName();
    if (section.HasLines())
    {
      // Trash INI File chunks
      std::vector<std::string> chunk;
      section.GetLines(&chunk, true);

      if (chunk.size())
      {
        const auto mapped_config = MapINIToRealLocation(section_name, "");

        if (mapped_config.section.empty() && mapped_config.key.empty())
          return;

        auto* config_section =
            config_layer->GetOrCreateSection(mapped_config.system, mapped_config.section);
        config_section->SetLines(chunk);
      }
    }

    // Regular key,value pairs
    const IniFile::Section::SectionMap& section_map = section.GetValues();

    for (const auto& value : section_map)
    {
      const auto mapped_config = MapINIToRealLocation(section_name, value.first);

      if (mapped_config.section.empty() && mapped_config.key.empty())
        continue;

      auto* config_section =
          config_layer->GetOrCreateSection(mapped_config.system, mapped_config.section);
      config_section->Set(mapped_config.key, value.second);
    }
  }