示例#1
0
	void OnNoticeChannel(User *u, Channel *c, const Flux::vector &params)
	{
		if(!u || !c)
			return;

		if(c->name != Config->LogChannel)
			return;

		Flux::string msg;

		for(unsigned i = 0; i < params.size(); ++i)
			msg += params[i] + ' ';

		msg.trim();
		Flux::string nolog = params.size() == 2 ? params[1] : "";

		if(nolog != "#nl" && u)
			CLog("-Notice- %s: %s", u->nick.c_str(), Flux::Sanitize(msg).c_str());
	}
示例#2
0
// Private Function! used by Flux::string.implode()
Flux::string __ConcatenateString(const Flux::vector &str, char delim = ' ')
{
	Flux::string temp;
	for (unsigned i = 0; i < str.size(); ++i)
	{
		if(!temp.empty())
		temp += delim;
		temp += str[i];
	}
	
	return temp;
}
示例#3
0
  void OnPrivmsgChannel(User *u, Channel *c, const Flux::vector &params)
  {
    //Flux::vector MessageParams = StringVector(params, ' ');
    Flux::string msg;
    for(unsigned i=0; i < params.size(); ++i)
      msg += params[i]+' ';

    Flux::string cmd = params.empty()?"":params[0];

    if(cmd.equals_ci("!encyclopedia"))
    {
      SetQuery(1, params);
      Brain(u,query);
    }

    if(msg.search_ci(Config->BotNick+", what do you know about "))
    {
      SetQuery(6, params);
      Brain(u, query);
    }

    else if(msg.search_ci(Config->BotNick+", what is a ") ^ msg.search_ci(Config->BotNick+", what is the") ^ msg.search_ci(Config->BotNick+", tell me about ") ^ msg.search_ci(Config->BotNick+", who are the ") ^ msg.search_ci(Config->BotNick+", what is an "))
    {
      SetQuery(4, params);
      Brain(u, query);
    }

    else if(msg.search_ci(Config->BotNick+", what is ") ^ msg.search_ci(Config->BotNick+", what are ") ^ msg.search_ci(Config->BotNick+", who is ") ^ msg.search_ci(Config->BotNick+", what's a ") ^ msg.search_ci(Config->BotNick+", what's an "))
    {
      SetQuery(3, params);
      Brain(u, query);
    }

    else if(msg.search_ci(Config->BotNick+", tell me what you know about "))
    {
      SetQuery(7, params);
      Brain(u, query);
    }
  }
示例#4
0
	void OnPrivmsgChannel(User *u, Channel *c, const Flux::vector &params)
	{
		Flux::string nolog = params.size() == 2 ? params[1] : "";

		if(!u || !c)
			return;

		if(c->name != Config->LogChannel)
			return;

		Flux::string msg = ConcatinateVector(params);

		if(nolog != "#nl" && u)
		{
			if(nolog == "\001ACTION")
			{
				msg = msg.erase(0, 8);
				CLog("*** %s %s", u->nick.c_str(), Flux::Sanitize(msg).c_str());
			}
			else
				CLog("<%s> %s", u->nick.c_str(), msg.c_str());
		}
	}
示例#5
0
文件: m_system.cpp 项目: Ephasic/ANT
  void OnNumeric(int i, Network *n, const Flux::vector &params)
  {
    if((i == 5))
    {
      // Skip the nickname and the "are supported by this server" parts of the message
      for(unsigned o = 1; o < params.size() - 1; ++o)
      {
	Flux::vector sentence = ParamitizeString(params[o], '=');
	Flux::string word = sentence[0];
	Flux::string param = sentence.size() > 1 ? sentence[1] : "";

	if(word.equals_ci("NETWORK"))
	  n->isupport.Network = param;

	if(word.equals_ci("CHANTYPES"))
	  n->isupport.ChanTypes = param;

	if(word.equals_ci("AWAYLEN"))
	  n->isupport.AwayLen = static_cast<int>(param);

	if(word.equals_ci("KICKLEN"))
	  n->isupport.KickLen = static_cast<int>(param);

	if(word.equals_ci("MAXBANS"))
	  n->isupport.MaxBans = static_cast<int>(param);

	if(word.equals_ci("MAXCHANNELS"))
	  n->isupport.MaxChannels = static_cast<int>(param);

	if(word.equals_ci("CHANNELLEN"))
	  n->isupport.ChannelLen = static_cast<int>(param);

	if(word.equals_ci("NICKLEN"))
	  n->isupport.NickLen = static_cast<int>(param);

	if(word.equals_ci("TOPICLEN"))
	  n->isupport.TopicLen = static_cast<int>(param);

	n->isupport.other[word] = param;
      }
    }

    if((i == 4))
    {
      /* Numeric 004
       * params[0] = Bots nickname
       * params[1] = servername
       * params[2] = ircd version
       * params[3] = user modes
       * params[4] = channel modes
       */

      n->b->CheckNickname();

      n->isupport.ServerHost = params[1];
      n->isupport.IRCdVersion = params[2];
      n->isupport.UserModes = params[3];
      n->isupport.ChanModes = params[4];
    }

    if((i == 376))
      new SyncTimer(n);

    /* Nickname is in use numeric
     * Numeric 433
     * params[0] = our current nickname
     * params[1] = Attempted nickname
     * params[2] = message (useless)
     */
    if((i == 433))
    {
      // Make sure we're not incrementing if the server sends a random 443
      if(params[1].search(Config->NicknamePrefix))
      {
	Flux::string number = params[1].substr(Config->NicknamePrefix.size());
	if(static_cast<int>(number) == n->b->BotNum)
	  n->b->BotNum++;
      }

      n->b->CheckNickname();
    }
  }
示例#6
0
 void SetQuery(unsigned n, const Flux::vector &params)
 {
   query.clear();
   if (n < params.size()) for(unsigned i=n; i < params.size(); ++i) query += params[i]+' ';
 }