本文整理汇总了C++中CAutoVoiceUser类的典型用法代码示例。如果您正苦于以下问题:C++ CAutoVoiceUser类的具体用法?C++ CAutoVoiceUser怎么用?C++ CAutoVoiceUser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CAutoVoiceUser类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnLoad
bool OnLoad(const CString& sArgs, CString& sMessage) override {
// Load the chans from the command line
unsigned int a = 0;
VCString vsChans;
sArgs.Split(" ", vsChans, false);
for (const CString& sChan : vsChans) {
CString sName = "Args";
sName += CString(a);
AddUser(sName, "*", sChan);
}
// Load the saved users
for (MCString::iterator it = BeginNV(); it != EndNV(); ++it) {
const CString& sLine = it->second;
CAutoVoiceUser* pUser = new CAutoVoiceUser;
if (!pUser->FromString(sLine) || FindUser(pUser->GetUsername().AsLower())) {
delete pUser;
} else {
m_msUsers[pUser->GetUsername().AsLower()] = pUser;
}
}
return true;
}
示例2: FindUserByHost
CAutoVoiceUser* FindUserByHost(const CString& sHostmask, const CString& sChannel = "") {
for (const auto& it : m_msUsers) {
CAutoVoiceUser* pUser = it.second;
if (pUser->HostMatches(sHostmask) && (sChannel.empty() || pUser->ChannelMatches(sChannel))) {
return pUser;
}
}
return nullptr;
}
示例3: FindUserByHost
CAutoVoiceUser* FindUserByHost(const CString& sHostmask, const CString& sChannel = "") {
for (map<CString, CAutoVoiceUser*>::iterator it = m_msUsers.begin(); it != m_msUsers.end(); ++it) {
CAutoVoiceUser* pUser = it->second;
if (pUser->HostMatches(sHostmask) && (sChannel.empty() || pUser->ChannelMatches(sChannel))) {
return pUser;
}
}
return NULL;
}
示例4: OnAddUserCommand
void OnAddUserCommand(const CString& sLine) {
CString sUser = sLine.Token(1);
CString sHost = sLine.Token(2);
if (sHost.empty()) {
PutModule("Usage: AddUser <user> <hostmask> [channels]");
} else {
CAutoVoiceUser* pUser = AddUser(sUser, sHost, sLine.Token(3, true));
if (pUser) {
SetNV(sUser, pUser->ToString());
}
}
}
示例5: OnDelChansCommand
void OnDelChansCommand(const CString& sLine) {
CString sUser = sLine.Token(1);
CString sChans = sLine.Token(2, true);
if (sChans.empty()) {
PutModule("Usage: DelChans <user> <channel> [channel] ...");
return;
}
CAutoVoiceUser* pUser = FindUser(sUser);
if (!pUser) {
PutModule("No such user");
return;
}
pUser->DelChans(sChans);
PutModule("Channel(s) Removed from user [" + pUser->GetUsername() + "]");
SetNV(pUser->GetUsername(), pUser->ToString());
}
示例6: OnModCommand
virtual void OnModCommand(const CString& sLine) {
CString sCommand = sLine.Token(0).AsUpper();
if (sCommand.Equals("HELP")) {
PutModule("Commands are: ListUsers, AddChans, DelChans, AddUser, DelUser");
} else if (sCommand.Equals("ADDUSER") || sCommand.Equals("DELUSER")) {
CString sUser = sLine.Token(1);
CString sHost = sLine.Token(2);
if (sCommand.Equals("ADDUSER")) {
if (sHost.empty()) {
PutModule("Usage: " + sCommand + " <user> <hostmask> [channels]");
} else {
CAutoVoiceUser* pUser = AddUser(sUser, sHost, sLine.Token(3, true));
if (pUser) {
SetNV(sUser, pUser->ToString());
}
}
} else {
DelUser(sUser);
DelNV(sUser);
}
} else if (sCommand.Equals("LISTUSERS")) {
if (m_msUsers.empty()) {
PutModule("There are no users defined");
return;
}
CTable Table;
Table.AddColumn("User");
Table.AddColumn("Hostmask");
Table.AddColumn("Channels");
for (map<CString, CAutoVoiceUser*>::iterator it = m_msUsers.begin(); it != m_msUsers.end(); ++it) {
Table.AddRow();
Table.SetCell("User", it->second->GetUsername());
Table.SetCell("Hostmask", it->second->GetHostmask());
Table.SetCell("Channels", it->second->GetChannels());
}
PutModule(Table);
} else if (sCommand.Equals("ADDCHANS") || sCommand.Equals("DELCHANS")) {
CString sUser = sLine.Token(1);
CString sChans = sLine.Token(2, true);
if (sChans.empty()) {
PutModule("Usage: " + sCommand + " <user> <channel> [channel] ...");
return;
}
CAutoVoiceUser* pUser = FindUser(sUser);
if (!pUser) {
PutModule("No such user");
return;
}
if (sCommand.Equals("ADDCHANS")) {
pUser->AddChans(sChans);
PutModule("Channel(s) added to user [" + pUser->GetUsername() + "]");
} else {
pUser->DelChans(sChans);
PutModule("Channel(s) Removed from user [" + pUser->GetUsername() + "]");
}
SetNV(pUser->GetUsername(), pUser->ToString());
} else {
PutModule("Unknown command, try HELP");
}
}