本文整理汇总了C++中CAutoVoiceUser::AddChans方法的典型用法代码示例。如果您正苦于以下问题:C++ CAutoVoiceUser::AddChans方法的具体用法?C++ CAutoVoiceUser::AddChans怎么用?C++ CAutoVoiceUser::AddChans使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CAutoVoiceUser
的用法示例。
在下文中一共展示了CAutoVoiceUser::AddChans方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnAddChansCommand
void OnAddChansCommand(const CString& sLine) {
CString sUser = sLine.Token(1);
CString sChans = sLine.Token(2, true);
if (sChans.empty()) {
PutModule("Usage: AddChans <user> <channel> [channel] ...");
return;
}
CAutoVoiceUser* pUser = FindUser(sUser);
if (!pUser) {
PutModule("No such user");
return;
}
pUser->AddChans(sChans);
PutModule("Channel(s) added to user [" + pUser->GetUsername() + "]");
SetNV(pUser->GetUsername(), pUser->ToString());
}
示例2: 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");
}
}