String rest = st.rest ().trim ();
int level;
bool identified = false;
- userFunction * f = cnx->bot->userFunctions[command];
+ std::map<std::string, class userFunction*,
+ std::less<std::string> >::const_iterator uf_iter
+ = cnx->bot->userFunctions.find (command);
+ userFunction * f = 0;
+
+ if (uf_iter != cnx->bot->userFunctions.end ())
+ f = uf_iter->second;
+ else
+ return;
+
if (f)
{
if (f->needsChannelName)
to = st.nextToken ();
rest = st.rest ();
}
- if (!Utils::isChannel (to))
- {
- from->sendNotice ("\002You need to supply a channel name"
- " for this command\002");
- return;
- }
- if (!cnx->bot->channelList->getChannel (to))
- {
- from->sendNotice (String ("\002I am not on channel\002 ") +
- to);
- return;
- }
- level = Utils::getLevel (cnx->bot, from->getAddress (), to);
- User *u = 0;
- if (Channel * c = cnx->bot->channelList->getChannel (to))
- u = c->getUser (from->getNick ());
- if (!u || !u->userListItem)
- identified = true;
- else
- identified = u->userListItem->passwd == ""
- || u->userListItem->identified > 0;
- }
- else
- {
- level = Utils::getLevel (cnx->bot, from->getAddress ());
+ if (!Utils::isChannel (to))
+ {
+ from->sendNotice ("\002You need to supply a channel name"
+ " for this command\002");
+ return;
+ }
+ if (!cnx->bot->channelList->getChannel (to))
+ {
+ from->sendNotice (String ("\002I am not on channel\002 ") +
+ to);
+ return;
+ }
+ level = Utils::getLevel (cnx->bot, from->getAddress (), to);
+ User *u = 0;
+ if (Channel * c = cnx->bot->channelList->getChannel (to))
+ u = c->getUser (from->getNick ());
+ if (!u || !u->userListItem)
identified = true;
- }
- if (level >= f->minLevel)
- {
- cnx->bot->logLine (from->getAddress () + " did " + command +
- " " + rest);
+ else
+ identified = u->userListItem->passwd == ""
+ || u->userListItem->identified > 0;
+ }
+ else
+ {
+ level = Utils::getLevel (cnx->bot, from->getAddress ());
+ identified = true;
+ }
+ if (level >= f->minLevel)
+ {
+ cnx->bot->logLine (from->getAddress () + " did " + command +
+ " " + rest);
#ifdef USESCRIPTS
- if (f->argsCount != -1)
- {
- Parser::parseScriptFunction (cnx, to, f->needsChannelName,
- f->scmFunc, f->argsCount,
- rest);
- }
- else
- {
- f->function (cnx, from, to, rest);
- }
+ if (f->argsCount != -1)
+ {
+ Parser::parseScriptFunction (cnx, to, f->needsChannelName,
+ f->scmFunc, f->argsCount,
+ rest);
+ }
+ else
+ {
+ f->function (cnx, from, to, rest);
+ }
#else
- f->function (cnx, from, to, rest);
+ f->function (cnx, from, to, rest);
#endif
- }
- else
- {
- if (!identified)
- from->
- sendNotice (String
- ("\002You are not identified on channel\002 ") +
- to);
- }
- }
+ }
+ else
+ {
+ if (!identified)
+ from->
+ sendNotice (String
+ ("\002You are not identified on channel\002 ") +
+ to);
+ }
+ }
}
#ifdef USESCRIPTS