当前位置: 首页>>代码示例>>C++>>正文


C++ Channel::SendMessage方法代码示例

本文整理汇总了C++中Channel::SendMessage方法的典型用法代码示例。如果您正苦于以下问题:C++ Channel::SendMessage方法的具体用法?C++ Channel::SendMessage怎么用?C++ Channel::SendMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Channel的用法示例。


在下文中一共展示了Channel::SendMessage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: OnLog

	EventResult OnLog(Log *l)
	{
		Channel *c = findchannel(Config->LogChan);

		if(!c)
			return EVENT_CONTINUE;

		std::stringstream logstream;
		Flux::string message = Flux::Sanitize(l->buffer.str());

		if(l->u && !l->c)
			message = l->u->nick + " " + message;

		if(l->u && l->c)
			message = l->u->nick + " used " + l->c->name + " " + message;

		switch(l->type)
		{
			case LOG_NORMAL:
				logstream << message;
				break;
			case LOG_THREAD:

				if(protocoldebug)
					logstream << "[THREAD] " << message;

				break;
			case LOG_DEBUG:

				if(dev || protocoldebug)
					logstream << message;

				break;
//       case LOG_DEVEL:
//  if(!protocoldebug && dev)
//    logstream << message;
//  break;
			case LOG_RAWIO:
				return EVENT_CONTINUE;
			case LOG_CRITICAL:
				logstream << "\0034[CRITICAL] " << message << "\017";
				break;
			case LOG_WARN:
				logstream << "\0037[WARNING]\017 " << message;
				break;
			default:
				break;
		}

		c->SendMessage(NoTermColor(logstream.str()));
		return EVENT_CONTINUE;
	}
开发者ID:Justasic,项目名称:Navn,代码行数:52,代码来源:m_logchan.cpp

示例2: Run

  void Run(CommandSource &source, const Flux::vector &params)
  {
    User *u = source.u;
    Channel *c = source.c;
    Flux::string area = params[0], tmpfile = TextFile::TempFile(binary_dir+"/runtime/navn_xml.tmp.XXXXXX");

    if(tmpfile.empty())
    {
      Log() << "Failed to get temp file";
      return;
    }
    area.trim();

    Flux::string url = Config->Parser->Get("Modules", "WeatherURL", "http://www.google.com/ig/api?weather=%l");
    url = url.replace_all_cs("%l", area.is_number_only()?area:area.url_str());

    Log(LOG_DEBUG) << "wget weather url \"" << url << "\" for !weather command used";
    system(Flux::string("wget -q -O "+tmpfile+" - "+url).c_str());
    XMLFile *xf = new XMLFile(tmpfile);

    Flux::string city = xf->Tags["xml_api_reply"].Tags["weather"].Tags["forecast_information"].Tags["city"].Attributes["data"].Value;
    Flux::string condition = xf->Tags["xml_api_reply"].Tags["weather"].Tags["current_conditions"].Tags["condition"].Attributes["data"].Value;
    Flux::string temp_f = xf->Tags["xml_api_reply"].Tags["weather"].Tags["current_conditions"].Tags["temp_f"].Attributes["data"].Value;
    Flux::string temp_c = xf->Tags["xml_api_reply"].Tags["weather"].Tags["current_conditions"].Tags["temp_c"].Attributes["data"].Value;
    Flux::string humidity = xf->Tags["xml_api_reply"].Tags["weather"].Tags["current_conditions"].Tags["humidity"].Attributes["data"].Value;
    Flux::string windy = xf->Tags["xml_api_reply"].Tags["weather"].Tags["current_conditions"].Tags["wind_condition"].Attributes["data"].Value;

    delete xf;

    if(city.strip().empty())
    {
      source.Reply("Weather information for \2%s\2 not found.", area.c_str());
      return;
    }
    int temp_k = static_cast<int>(temp_c) + 273; // Calculate degrees kelvin from degrees celsius
    c->SendMessage("%s Current Condition: %s, %s, %s, %s %cF %s %cC %iK", city.strip().c_str(), condition.strip().c_str(), humidity.strip().c_str(), windy.strip().c_str(), temp_f.c_str(), 0x00B0, temp_c.c_str(), 0x00B0, temp_k);

    Log(u, this) << "to get weather for area '" << area << "'";
  }
开发者ID:DeathBlade,项目名称:Navn,代码行数:39,代码来源:m_weather.cpp


注:本文中的Channel::SendMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。