本文整理汇总了C++中anope::string::end方法的典型用法代码示例。如果您正苦于以下问题:C++ string::end方法的具体用法?C++ string::end怎么用?C++ string::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类anope::string
的用法示例。
在下文中一共展示了string::end方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Run
void Privmsg::Run(MessageSource &source, const std::vector<Anope::string> ¶ms)
{
const Anope::string &receiver = params[0];
Anope::string message = params[1];
User *u = source.GetUser();
if (IRCD->IsChannelValid(receiver))
{
Channel *c = Channel::Find(receiver);
if (c)
{
EventManager::Get()->Dispatch(&Event::Privmsg::OnPrivmsg, u, c, message);
}
}
else
{
/* If a server is specified ([email protected] format), make sure it matches
* us, and strip it off. */
Anope::string botname = receiver;
size_t s = receiver.find('@');
bool nick_only = false;
if (s != Anope::string::npos)
{
Anope::string servername(receiver.begin() + s + 1, receiver.end());
botname = botname.substr(0, s);
nick_only = true;
if (!servername.equals_ci(Me->GetName()))
return;
}
else if (!IRCD->RequiresID && Config->UseStrictPrivmsg)
{
ServiceBot *bi = ServiceBot::Find(receiver);
if (!bi)
return;
Log(LOG_DEBUG) << "Ignored PRIVMSG without @ from " << u->nick;
u->SendMessage(bi, _("\"/msg %s\" is no longer supported. Use \"/msg %[email protected]%s\" or \"/%s\" instead."), bi->nick.c_str(), bi->nick.c_str(), Me->GetName().c_str(), bi->nick.c_str());
return;
}
ServiceBot *bi = ServiceBot::Find(botname, nick_only);
if (bi)
{
if (message[0] == '\1' && message[message.length() - 1] == '\1')
{
if (message.substr(0, 6).equals_ci("\1PING "))
{
Anope::string buf = message;
buf.erase(buf.begin());
buf.erase(buf.end() - 1);
IRCD->SendCTCP(bi, u->nick, "%s", buf.c_str());
}
else if (message.substr(0, 9).equals_ci("\1VERSION\1"))
{
Module *enc = ModuleManager::FindFirstOf(ENCRYPTION);
IRCD->SendCTCP(bi, u->nick, "VERSION Anope-%s %s :%s - (%s) -- %s", Anope::Version().c_str(), Me->GetName().c_str(), IRCD->GetProtocolName().c_str(), enc ? enc->name.c_str() : "(none)", Anope::VersionBuildString().c_str());
}
return;
}
EventReturn MOD_RESULT = EventManager::Get()->Dispatch(&Event::BotPrivmsg::OnBotPrivmsg, u, bi, message);
if (MOD_RESULT == EVENT_STOP)
return;
bi->OnMessage(u, message);
}
}
return;
}
示例2: OnPrivmsg
bool IRCdMessage::OnPrivmsg(const Anope::string &source, const std::vector<Anope::string> ¶ms)
{
const Anope::string &receiver = params.size() > 0 ? params[0] : "";
Anope::string message = params.size() > 1 ? params[1] : "";
/* Messages from servers can happen on some IRCds, check for . */
if (source.empty() || receiver.empty() || message.empty() || source.find('.') != Anope::string::npos)
return true;
User *u = finduser(source);
if (!u)
{
Log() << message << ": user record for " << source << " not found";
BotInfo *bi = findbot(receiver);
if (bi)
ircdproto->SendMessage(bi, source, "%s", "Internal error - unable to process request.");
return true;
}
if (receiver[0] == '#')
{
Channel *c = findchan(receiver);
if (c)
{
FOREACH_MOD(I_OnPrivmsg, OnPrivmsg(u, c, message));
}
}
else
{
/* If a server is specified ([email protected] format), make sure it matches
* us, and strip it off. */
Anope::string botname = receiver;
size_t s = receiver.find('@');
if (s != Anope::string::npos)
{
Anope::string servername(receiver.begin() + s + 1, receiver.end());
botname = botname.substr(0, s);
if (!servername.equals_ci(Config->ServerName))
return true;
}
else if (Config->UseStrictPrivMsg)
{
BotInfo *bi = findbot(receiver);
if (!bi)
return true;
Log(LOG_DEBUG) << "Ignored PRIVMSG without @ from " << source;
u->SendMessage(bi, _("\"/msg %s\" is no longer supported. Use \"/msg %[email protected]%s\" or \"/%s\" instead."), receiver.c_str(), receiver.c_str(), Config->ServerName.c_str(), receiver.c_str());
return true;
}
BotInfo *bi = findbot(botname);
if (bi)
{
EventReturn MOD_RESULT;
FOREACH_RESULT(I_OnBotPrivmsg, OnBotPrivmsg(u, bi, message));
if (MOD_RESULT == EVENT_STOP)
return true;
if (message[0] == '\1' && message[message.length() - 1] == '\1')
{
if (message.substr(0, 6).equals_ci("\1PING "))
{
Anope::string buf = message;
buf.erase(buf.begin());
buf.erase(buf.end() - 1);
ircdproto->SendCTCP(bi, u->nick, "%s", buf.c_str());
}
else if (message.substr(0, 9).equals_ci("\1VERSION\1"))
{
Module *enc = ModuleManager::FindFirstOf(ENCRYPTION);
ircdproto->SendCTCP(bi, u->nick, "VERSION Anope-%s %s :%s - (%s) -- %s", Anope::Version().c_str(), Config->ServerName.c_str(), ircd->name, enc ? enc->name.c_str() : "unknown", Anope::VersionBuildString().c_str());
}
return true;
}
bi->OnMessage(u, message);
}
}
return true;
}