本文整理汇总了C++中anope::string类的典型用法代码示例。如果您正苦于以下问题:C++ string类的具体用法?C++ string怎么用?C++ string使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了string类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: bot_raw_ban
/* Makes a simple ban and kicks the target
* @param requester The user requesting the kickban
* @param ci The channel
* @param u The user being kicked
* @param reason The reason
*/
void bot_raw_ban(User *requester, ChannelInfo *ci, User *u, const Anope::string &reason)
{
if (!u || !ci)
return;
if (ModeManager::FindUserModeByName(UMODE_PROTECTED) && u->IsProtected() && requester != u)
{
ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", translate(requester, ACCESS_DENIED));
return;
}
AccessGroup u_access = ci->AccessFor(u), req_access = ci->AccessFor(requester);
if (ci->HasFlag(CI_PEACE) && u != requester && u_access >= req_access)
return;
if (matches_list(ci->c, u, CMODE_EXCEPT))
{
ircdproto->SendPrivmsg(ci->bi, ci->name, "%s", translate(requester, _("User matches channel except.")));
return;
}
Anope::string mask;
get_idealban(ci, u, mask);
ci->c->SetMode(NULL, CMODE_BAN, mask);
/* Check if we need to do a signkick or not -GD */
if (ci->HasFlag(CI_SIGNKICK) || (ci->HasFlag(CI_SIGNKICK_LEVEL) && !req_access.HasPriv("SIGNKICK")))
ci->c->Kick(ci->bi, u, "%s (%s)", !reason.empty() ? reason.c_str() : ci->bi->nick.c_str(), requester->nick.c_str());
else
ci->c->Kick(ci->bi, u, "%s", !reason.empty() ? reason.c_str() : ci->bi->nick.c_str());
}
开发者ID:xxgrunge,项目名称:anope196,代码行数:38,代码来源:botserv.cpp
示例2: DoDel
void DoDel(CommandSource &source, NickServ::Account *nc, Anope::string certfp)
{
std::vector<NSCertEntry *> cl = nc->GetRefs<NSCertEntry *>(certentry);
if (certfp.empty())
{
User *u = source.GetUser();
if (u)
certfp = u->fingerprint;
}
if (certfp.empty())
{
this->OnSyntaxError(source, "DEL");
return;
}
NSCertEntry *cert = FindCert(cl, certfp);
if (!cert)
{
source.Reply(_("\002{0}\002 not found on the certificate list of \002{1}\002."), certfp, nc->GetDisplay());
return;
}
cert->Delete();
Log(nc == source.GetAccount() ? LOG_COMMAND : LOG_ADMIN, source, this) << "to DELETE certificate fingerprint " << certfp << " from " << nc->GetDisplay();
source.Reply(_("\002{0}\002 deleted from the access list of \002{1}\002."), certfp, nc->GetDisplay());
}
开发者ID:carriercomm,项目名称:anope,代码行数:29,代码来源:cert.cpp
示例3: SendChannel
void SendChannel(Channel *c)
{
Anope::string modes = c->GetModes(true, true);
if (modes.empty())
modes = "+";
UplinkSocket::Message() << "SJOIN " << c->creation_time << " " << c->name << " " << modes << " :";
}
开发者ID:xxgrunge,项目名称:anope196,代码行数:7,代码来源:bahamut.cpp
示例4: OnEncrypt
EventReturn OnEncrypt(const Anope::string &src, Anope::string &dest) override
{
if (!md5)
return EVENT_CONTINUE;
Encryption::Context *context = md5->CreateContext();
context->Update(reinterpret_cast<const unsigned char *>(src.c_str()), src.length());
context->Finalize();
Encryption::Hash hash = context->GetFinalizedHash();
char digest[32], digest2[16];
memset(digest, 0, sizeof(digest));
if (hash.second > sizeof(digest))
throw CoreException("Hash too large");
memcpy(digest, hash.first, hash.second);
for (int i = 0; i < 32; i += 2)
digest2[i / 2] = XTOI(digest[i]) << 4 | XTOI(digest[i + 1]);
Anope::string buf = "oldmd5:" + Anope::Hex(digest2, sizeof(digest2));
Log(LOG_DEBUG_2) << "(enc_old) hashed password from [" << src << "] to [" << buf << "]";
dest = buf;
delete context;
return EVENT_ALLOW;
}
开发者ID:dream1986,项目名称:anope,代码行数:27,代码来源:old.cpp
示例5: DeleteModule
ModuleReturn ModuleManager::DeleteModule(Module *m)
{
if (!m || !m->handle)
return MOD_ERR_PARAMS;
void *handle = m->handle;
Anope::string filename = m->filename;
Log(LOG_DEBUG) << "Unloading module " << m->name;
dlerror();
void (*destroy_func)(Module *m) = function_cast<void (*)(Module *)>(dlsym(m->handle, "AnopeFini"));
const char *err = dlerror();
if (!destroy_func || (err && *err))
{
Log() << "No destroy function found for " << m->name << ", chancing delete...";
delete m; /* we just have to chance they haven't overwrote the delete operator then... */
}
else
destroy_func(m); /* Let the module delete it self, just in case */
if (dlclose(handle))
Log() << dlerror();
if (!filename.empty())
unlink(filename.c_str());
return MOD_ERR_OK;
}
开发者ID:xxgrunge,项目名称:anope196,代码行数:29,代码来源:modulemanager.cpp
示例6: Run
/*
* RFC 2813, 4.2.2: Njoin Message:
* The NJOIN message is used between servers only.
* It is used when two servers connect to each other to exchange
* the list of channel members for each channel.
*
* Even though the same function can be performed by using a succession
* of JOIN, this message SHOULD be used instead as it is more efficient.
*
* Received: :dev.anope.de NJOIN #test :DukeP2,@DukeP,%test,+test2
*/
void Run(MessageSource &source, const std::vector<Anope::string> ¶ms) override
{
std::list<Message::Join::SJoinUser> users;
commasepstream sep(params[1]);
Anope::string buf;
while (sep.GetToken(buf))
{
Message::Join::SJoinUser sju;
/* Get prefixes from the nick */
for (char ch; (ch = ModeManager::GetStatusChar(buf[0]));)
{
buf.erase(buf.begin());
sju.first.AddMode(ch);
}
sju.second = User::Find(buf);
if (!sju.second)
{
Log(LOG_DEBUG) << "NJOIN for non-existent user " << buf << " on " << params[0];
continue;
}
users.push_back(sju);
}
Message::Join::SJoin(source, params[0], 0, "", users);
}
开发者ID:bonnedav,项目名称:anope,代码行数:40,代码来源:ngircd.cpp
示例7: DoDelete
void DoDelete(CommandSource &source, ChanServ::Channel *ci, const Anope::string &word)
{
if (!badwords->GetBadWordCount(ci))
{
source.Reply(_("Bad word list for \002{0}\002 is empty."), ci->GetName());
return;
}
bool override = !source.AccessFor(ci).HasPriv("BADWORDS");
/* Special case: is it a number/list? Only do search if it isn't. */
if (!word.empty() && isdigit(word[0]) && word.find_first_not_of("1234567890,-") == Anope::string::npos)
{
unsigned int deleted = 0;
NumberList(word, true,
[&](unsigned int num)
{
if (!num || num > badwords->GetBadWordCount(ci))
return;
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "DEL " << badwords->GetBadWord(ci, num - 1)->GetWord();
++deleted;
badwords->EraseBadWord(ci, num - 1);
},
开发者ID:bonnedav,项目名称:anope,代码行数:25,代码来源:badwords.cpp
示例8: CleanupRuntimeDirectory
void ModuleManager::CleanupRuntimeDirectory()
{
Anope::string dirbuf = services_dir + "/modules/runtime";
Log(LOG_DEBUG) << "Cleaning out Module run time directory (" << dirbuf << ") - this may take a moment please wait";
DIR *dirp = opendir(dirbuf.c_str());
if (!dirp)
{
Log(LOG_DEBUG) << "Cannot open directory (" << dirbuf << ")";
return;
}
for (dirent *dp; (dp = readdir(dirp));)
{
if (!dp->d_ino)
continue;
if (Anope::string(dp->d_name).equals_cs(".") || Anope::string(dp->d_name).equals_cs(".."))
continue;
Anope::string filebuf = dirbuf + "/" + dp->d_name;
unlink(filebuf.c_str());
}
closedir(dirp);
}
开发者ID:xxgrunge,项目名称:anope196,代码行数:25,代码来源:modulemanager.cpp
示例9: Check
bool Check(User *u, XLine *x) override
{
if (x->regex)
{
Anope::string uh = u->GetIdent() + "@" + u->host, nuhr = u->nick + "!" + uh + "#" + u->realname;
return std::regex_match(uh.str(), *x->regex) || std::regex_match(nuhr.str(), *x->regex);
}
if (!x->GetNick().empty() && !Anope::Match(u->nick, x->GetNick()))
return false;
if (!x->GetUser().empty() && !Anope::Match(u->GetIdent(), x->GetUser()))
return false;
if (!x->GetReal().empty() && !Anope::Match(u->realname, x->GetReal()))
return false;
if (x->c && x->c->match(u->ip))
return true;
if (x->GetHost().empty() || Anope::Match(u->host, x->GetHost()) || Anope::Match(u->ip.addr(), x->GetHost()))
return true;
return false;
}
开发者ID:Robby-,项目名称:anope,代码行数:25,代码来源:operserv.cpp
示例10: Parse
void IRCDProto::Parse(const Anope::string &buffer, Anope::string &source, Anope::string &command, std::vector<Anope::string> ¶ms)
{
spacesepstream sep(buffer);
if (buffer[0] == ':')
{
sep.GetToken(source);
source.erase(0, 1);
}
sep.GetToken(command);
for (Anope::string token; sep.GetToken(token);)
{
if (token[0] == ':')
{
if (!sep.StreamEnd())
params.push_back(token.substr(1) + " " + sep.GetRemaining());
else
params.push_back(token.substr(1));
break;
}
else
params.push_back(token);
}
}
开发者ID:bonnedav,项目名称:anope,代码行数:26,代码来源:process.cpp
示例11: InitLanguages
void Language::InitLanguages()
{
#if GETTEXT_FOUND
Log(LOG_DEBUG) << "Initializing Languages...";
Languages.clear();
if (!bindtextdomain("anope", Anope::LocaleDir.c_str()))
Log() << "Error calling bindtextdomain, " << Anope::LastError();
else
Log(LOG_DEBUG) << "Successfully bound anope to " << Anope::LocaleDir;
setlocale(LC_ALL, "");
spacesepstream sep(Config->GetBlock("options")->Get<Anope::string>("languages"));
Anope::string language;
while (sep.GetToken(language))
{
const Anope::string &lang_name = Translate(language.c_str(), _("English"));
if (lang_name == "English")
{
Log() << "Unable to use language " << language;
continue;
}
Log(LOG_DEBUG) << "Found language " << language;
Languages.push_back(language);
}
#else
Log() << "Unable to initialize languages, gettext is not installed";
#endif
}
开发者ID:SaberUK,项目名称:anope,代码行数:32,代码来源:language.cpp
示例12:
cidr::cidr(const Anope::string &ip)
{
bool ipv6 = ip.find(':') != Anope::string::npos;
size_t sl = ip.find_last_of('/');
if (sl == Anope::string::npos)
{
this->cidr_ip = ip;
this->cidr_len = ipv6 ? 128 : 32;
this->addr.pton(ipv6 ? AF_INET6 : AF_INET, ip);
}
else
{
Anope::string real_ip = ip.substr(0, sl);
Anope::string cidr_range = ip.substr(sl + 1);
this->cidr_ip = real_ip;
this->cidr_len = ipv6 ? 128 : 32;
try
{
if (cidr_range.is_pos_number_only())
this->cidr_len = convertTo<unsigned int>(cidr_range);
}
catch (const ConvertException &) { }
this->addr.pton(ipv6 ? AF_INET6 : AF_INET, real_ip);
}
}
开发者ID:bonnedav,项目名称:anope,代码行数:27,代码来源:sockets.cpp
示例13: pton
void sockaddrs::pton(int type, const Anope::string &address, int pport)
{
this->clear();
switch (type)
{
case AF_INET:
{
int i = inet_pton(type, address.c_str(), &sa4.sin_addr);
if (i <= 0)
this->clear();
else
{
sa4.sin_family = type;
sa4.sin_port = htons(pport);
}
break;
}
case AF_INET6:
{
int i = inet_pton(type, address.c_str(), &sa6.sin6_addr);
if (i <= 0)
this->clear();
else
{
sa6.sin6_family = type;
sa6.sin6_port = htons(pport);
}
break;
}
default:
break;
}
}
开发者ID:bonnedav,项目名称:anope,代码行数:34,代码来源:sockets.cpp
示例14: LocalUser
ServiceBot::ServiceBot(const Anope::string &nnick, const Anope::string &nuser, const Anope::string &nhost, const Anope::string &nreal, const Anope::string &bmodes) : LocalUser(nnick, nuser, nhost, "", "", Me, nreal, Anope::CurTime, "", IRCD ? IRCD->UID_Retrieve() : "", NULL), botmodes(bmodes)
{
this->type = UserType::BOT;
this->lastmsg = Anope::CurTime;
this->introduced = false;
bi = botinfo.Create();
bi->bot = this;
bi->SetNick(nnick);
bi->SetUser(nuser);
bi->SetHost(nhost);
bi->SetRealName(nreal);
bi->SetCreated(Anope::CurTime);
Event::OnCreateBot(&Event::CreateBot::OnCreateBot, this);
// If we're synchronised with the uplink already, send the bot.
if (Me && Me->IsSynced())
{
Anope::string tmodes = !this->botmodes.empty() ? ("+" + this->botmodes) : IRCD->DefaultPseudoclientModes;
if (!tmodes.empty())
this->SetModesInternal(this, tmodes.c_str());
//XXX
//XLine x(this->nick, "Reserved for services");
//IRCD->SendSQLine(NULL, &x);
IRCD->SendClientIntroduction(this);
this->introduced = true;
}
}
开发者ID:bonnedav,项目名称:anope,代码行数:31,代码来源:bots.cpp
示例15: DoCheckAuthentication
void DoCheckAuthentication(XMLRPCServiceInterface *iface, XMLRPCClientSocket *source, XMLRPCRequest *request)
{
Anope::string username = request->data.size() > 0 ? request->data[0] : "";
Anope::string password = request->data.size() > 1 ? request->data[1] : "";
if (username.empty() || password.empty())
request->reply("error", "Invalid parameters");
else
{
NickAlias *na = findnick(username);
if (!na)
request->reply("error", "Invalid account");
else
{
EventReturn MOD_RESULT;
FOREACH_RESULT(I_OnCheckAuthentication, OnCheckAuthentication(NULL, NULL, std::vector<Anope::string>(), na->nc->display, password));
if (MOD_RESULT == EVENT_ALLOW)
{
request->reply("result", "Success");
request->reply("account", na->nc->display);
}
else
request->reply("error", "Invalid password");
}
}
}
开发者ID:xxgrunge,项目名称:anope196,代码行数:27,代码来源:m_xmlrpc_main.cpp
示例16:
// :42X UID Adam 1 1348535644 +aow Adam 192.168.0.5 192.168.0.5 42XAAAAAB 0 192.168.0.5 :Adam
void plexus::UID::Run(MessageSource &source, const std::vector<Anope::string> ¶ms)
{
/* An IP of 0 means the user is spoofed */
Anope::string ip = params[6];
if (ip == "0")
ip.clear();
time_t ts;
try
{
ts = convertTo<time_t>(params[2]);
}
catch (const ConvertException &)
{
ts = Anope::CurTime;
}
NickServ::Nick *na = NULL;
try
{
if (params[8].is_pos_number_only() && convertTo<time_t>(params[8]) == ts)
na = NickServ::FindNick(params[0]);
}
catch (const ConvertException &) { }
if (params[8] != "0" && !na)
na = NickServ::FindNick(params[8]);
User::OnIntroduce(params[0], params[4], params[9], params[5], ip, source.GetServer(), params[10], ts, params[3], params[7], na ? na->GetAccount() : NULL);
}
开发者ID:Robby-,项目名称:anope,代码行数:30,代码来源:plexus.cpp
示例17: OnChanRegistered
void OnChanRegistered(ChanServ::Channel *ci) override
{
/* Set default bot flags */
spacesepstream sep(Config->GetModule(this)->Get<Anope::string>("defaults", "greet fantasy"));
for (Anope::string token; sep.GetToken(token);)
ci->SetS<bool>("BS_" + token.upper(), true);
}
开发者ID:SaberUK,项目名称:anope,代码行数:7,代码来源:botserv.cpp
示例18: Identify
void User::Identify(NickServ::Nick *na)
{
if (this->nick.equals_ci(na->GetNick()))
{
na->SetLastUsermask(this->GetIdent() + "@" + this->GetDisplayedHost());
na->SetLastRealhost(this->GetIdent() + "@" + this->host);
na->SetLastRealname(this->realname);
na->SetLastSeen(Anope::CurTime);
}
IRCD->SendLogin(this, na);
this->Login(na->GetAccount());
EventManager::Get()->Dispatch(&Event::NickIdentify::OnNickIdentify, this);
if (this->IsServicesOper())
{
Anope::string m = this->nc->o->GetType()->modes;
if (!m.empty())
{
this->SetModes(NULL, "%s", m.c_str());
this->SendMessage(Me, "Changing your usermodes to \002{0}\002", m.c_str());
UserMode *um = ModeManager::FindUserModeByName("OPER");
if (um && !this->HasMode("OPER") && m.find(um->mchar) != Anope::string::npos)
IRCD->SendOper(this);
}
if (IRCD->CanSetVHost && !this->nc->o->GetVhost().empty())
{
this->SendMessage(Me, "Changing your vhost to \002{0}\002", this->nc->o->GetVhost());
this->SetDisplayedHost(this->nc->o->GetVhost());
IRCD->SendVhost(this, "", this->nc->o->GetVhost());
}
}
}
开发者ID:dream1986,项目名称:anope,代码行数:35,代码来源:users.cpp
示例19: Sanitize
Anope::string Sanitize(const Anope::string &string) override
{
Anope::string ret = string;
for (int i = 0; special[i].character.empty() == false; ++i)
ret = ret.replace_all_cs(special[i].character, special[i].replace);
return ret;
}
开发者ID:gerrit-rws,项目名称:anope,代码行数:7,代码来源:xmlrpc.cpp
示例20: IsValid
bool ChannelModeKey::IsValid(Anope::string &value) const
{
if (!value.empty() && value.find(':') == Anope::string::npos && value.find(',') == Anope::string::npos)
return true;
return false;
}
开发者ID:RanadeepPolavarapu,项目名称:IRCd,代码行数:7,代码来源:modes.cpp
注:本文中的anope::string类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论