本文整理汇总了C++中LocalUser::SetMode方法的典型用法代码示例。如果您正苦于以下问题:C++ LocalUser::SetMode方法的具体用法?C++ LocalUser::SetMode怎么用?C++ LocalUser::SetMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LocalUser
的用法示例。
在下文中一共展示了LocalUser::SetMode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnModeChange
ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding)
{
LocalUser* user = IS_LOCAL(dest);
/* For remote clients, we don't take any action, we just allow it.
* The local server where they are will set their cloak instead.
* This is fine, as we will receive it later.
*/
if (!user)
{
dest->SetMode(this, adding);
return MODEACTION_ALLOW;
}
if (user->uuid == debounce_uid && debounce_ts == ServerInstance->Time())
{
// prevent spamming using /mode user +x-x+x-x+x-x
if (++debounce_count > 2)
return MODEACTION_DENY;
}
else
{
debounce_uid = user->uuid;
debounce_count = 1;
debounce_ts = ServerInstance->Time();
}
if (adding == user->IsModeSet(this))
return MODEACTION_DENY;
/* don't allow this user to spam modechanges */
if (source == dest)
user->CommandFloodPenalty += 5000;
if (adding)
{
std::string* cloak = ext.get(user);
if (!cloak)
{
/* Force creation of missing cloak */
creator->OnUserConnect(user);
cloak = ext.get(user);
}
if (cloak)
{
user->ChangeDisplayedHost(*cloak);
user->SetMode(this, true);
return MODEACTION_ALLOW;
}
else
return MODEACTION_DENY;
}
else
{
/* User is removing the mode, so restore their real host
* and make it match the displayed one.
*/
user->SetMode(this, false);
user->ChangeDisplayedHost(user->host.c_str());
return MODEACTION_ALLOW;
}
}