Esempio n. 1
0
/**
 * \fn Flux::string search(Flux::string s, Flux::string command)
 * \brief generates search links for url's
 * This is what generates the search links.
 */
Flux::string search(const Flux::string &text, const Flux::string &command)
{
	Flux::string searchstring = text.url_str();

	if(searchstring.empty())
		return "Empty searchstring.";
	else
	{
		if(command.equals_ci("google"))
			return "http://www.google.com/search?q=" + searchstring;
		else if(command.equals_ci("youtube"))
			return "http://www.youtube.com/results?search_query=" + searchstring;
		else if(command.equals_ci("tpb"))
			return "http://thepiratebay.org/search/" + searchstring;
		else if(command.equals_ci("define"))
			return "http://dictionary.reference.com/browse/" + searchstring;
		else if(command.equals_ci("urban"))
			return "http://www.urbandictionary.com/define.php?term=" + searchstring;
		else if(command.equals_ci("movie"))
			return "www.letmewatchthis.ch/index.php?search_keywords=" + searchstring;
		else if(command.equals_ci("lmgtfy"))
			return "http://lmgtfy.com/?q=" + searchstring;
		else
			return "http://www.google.com/search?q=" + searchstring;
	}
}
Esempio n. 2
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);
    }
  }
Esempio n. 3
0
  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();
    }
  }