c++ - Command filtering -


currently writing irc bot fun , have trouble setting bot listen commands. ( works !quit not !join or !leave )

void onprivmsg(ircmessage message, ircclient* client) {     // received text     std::string text = message.parameters.at(message.parameters.size() - 1);      if (text[0] == '!')     {     if (text == "!join #channel" || text == "!join #channel")         client->sendirc("join #channel");     if (text == "!leave #channel" || text == "!leave #channel")         client->sendirc("part #channel");     if (text == "!quit" || text == "!quit")         client->sendirc("quit");     } else{         client->sendirc("privmsg #channel :wrong command.");     } } 

i'm calling so:

client.hookirccommand("privmsg", &onprivmsg); 

how channel name (#channelispecify) text message line?

example: if i'd type "!join #funnyposts" in irc join channel #funnyposts. appriciate kind of help.

figured out. filters different commands , acts accordingly.

if (text[0] == '!') {     std::string commandapi = text.substr(0, text.find(" "));     if (commandapi == "!join" || commandapi == "!join"){         if (commandapi[0] = '!'){             commandapi[0] = '/';         }         std::string channel2 = text.substr(text.find("#"));         client->sendirc("privmsg " + channel2 + " :joining channel");         client->sendirc("join " + channel2);     } 

Comments