Exemplo n.º 1
0
void sv::Bot::handle_bot_commands(Message& com)
{	
	std::vector<std::string> v = com.command_params();
   
	if(com.find_command("?quit"))
	{
        if (com.sender == owner)
        {
            quit();
        }
        else send_priv("You are not authorized to run that command!", channel);
	}
	else if(com.find_command("?join") && v.size() > 0)
	{				
        if (com.sender == owner)
        {
            join(v[0]);
        }
        else send_priv("You are not authorized to run that command!", channel);
	}
    else if(com.find_command("?exit"))
	{		
        if (com.sender == owner)
        {
            exit = true;
        }
        else send_priv("You are not authorized to run that command!", channel);
	}
	else if(com.find_command("?tell") && v.size() > 2)
	{
		std::string temp;//(botcommands.size(),0);
		std::for_each(v.begin() + 2, v.end(),[&](std::string s){temp += " " + s;});
		
		bool b = (v[0] == "private");
		msg_relay[v[1]].push_back(std::make_tuple(com.sender, temp, b));
	}
	else if(com.find_command("?help"))
	{
		help();
	}
	
	else if(com.find_command("?weather") && !v.empty())
	{
		std::string s = (v.size() > 1) ? v[1] + "/" + v[0] : v[0];		
		send_priv( util::weather(s, api_key), channel);
	}
	else if(com.find_command("?cowsay"))
	{
		send_cow();
	}
}
Exemplo n.º 2
0
void sv::Bot::check_messages(const std::string& user)
{
	if(msg_relay.find(user) != msg_relay.end())
	{
		if(!msg_relay[user].empty())
		{
			for(const auto& a : msg_relay[user])
			{
				if(std::get<2>(a))
					send_priv("While you were out " + std::get<0>(a) +" said: " + std::get<1>(a), user);
				else
					send_priv("@" + user + " While you were out " + std::get<0>(a) +" said: " + std::get<1>(a), channel);
							
			}
			msg_relay[user].clear();
		}
	}
}
Exemplo n.º 3
0
void sv::Bot::help()
{
	send_priv("\2aBot - An IRC bot to be entered into a cplusplus.com monthly community competition http://cppcomp.netne.net/showthread.php?tid=4 \2", channel);
	send_priv("-- \2?join <channel>\2  join the specified channel", channel);
	send_priv("-- \2?quit\2  quit current channel\n", channel);
	send_priv("-- \2?exit\2  shutdown " + nick + "\n", channel);
	send_priv("-- \2?tell <private|public> <nick> <message>\2  Send <message> to <nick> in channel if public or via privmsg if private.", channel);
	send_priv("-- \2?cowsay\2 display a fortune told by a cow", channel);
    if (!api_key.empty())
        send_priv("-- \2?weather <zip> | <city> <state|province|country>\2 get current weather conditions", channel);
    
}
Exemplo n.º 4
0
void sv::Bot::send_cow()
{
	const int pad = 2;
	const int w = 60;
	auto data = util::cow_data();
	send_priv(" " + std::string(w + pad,'_'), channel);
	for(auto& a : data)
	{		
		send_priv("| " + a + ((a.size() < w) ? std::string(w - a.size(), ' ') : "") + "|", channel);
	}
	send_priv(" " + std::string(w + pad,'-'), channel);
	send_priv("     \\  ^__^", channel);
	send_priv("      \\ (oo)\\_______", channel);
	send_priv("        (__)\\       )\\/\\", channel);
	send_priv("             ||----w |", channel);
	send_priv("             ||     ||", channel);
}
Exemplo n.º 5
0
Arquivo: client.c Projeto: kedric/42
int		is_cmd(t_env *env, int cs)
{
	char	*tmp;

	tmp = NULL;
	tmp = ft_strtrim(env->fds[cs].save);
	if (tmp[0] == '/')
	{
		if (ft_strncmp(env->fds[cs].save, "/nick ", 6) == 0)
			change_nickname(env, cs);
		if (ft_strncmp(env->fds[cs].save, "/join ", 6) == 0)
			change_chan(env, cs);
		if (ft_strncmp(env->fds[cs].save, "/leave", 6) == 0)
			leave_chan(env, cs);
		if (ft_strncmp(env->fds[cs].save, "/send ", 6) == 0)
			send_priv(env, cs);
		return (0);
	}
	return (1);
}
Exemplo n.º 6
0
void loot_corpse( obj_data* corpse, char_data* ch, char_data* victim )
{
  if( ch == NULL || ch->pcdata == NULL
    || victim->species == NULL || corpse == NULL ) 
    return;

  int level = level_setting( &ch->pcdata->pfile->settings,
    SET_AUTOLOOT );

  if( level == 0 )
    return;

  if( level == 1 ) {
    send_priv( ch, &corpse->contents, "contains", corpse ); 
    return;
    }

  /*
  for( obj = corpse->contents; obj != NULL; obj = next ) {
    next = obj->next_content;
    if( obj->pIndexData->item_type == ITEM_MONEY ) {
      for( i = 0; i < MAX_COIN; i++ )
        if( obj->pIndexData->vnum == coin_vnum[i] )
          amount += obj->number*coin_value[i];
      }
    else {
      if( !is_set( ch->pcdata->pfile->flags, PLR_AUTO_LOOT ) ) 
        continue;
      }
    obj->next_list = get;
    get            = obj;
    obj->selected  = obj->number;
    }

  get_obj( ch, get, corpse );

  if( is_set( ch->pcdata->pfile->flags, PLR_AUTO_SPLIT ) ) 
    split_money( ch, amount, FALSE );
  */
}