mirror of
https://github.com/znc/znc.git
synced 2026-08-07 17:33:34 +02:00
Improve cyrusauth UI, make more strings translatable (#1354)
This commit is contained in:
+39
-38
@@ -44,20 +44,18 @@ class CClientNotifyMod : public CModule {
|
||||
public:
|
||||
MODCONSTRUCTOR(CClientNotifyMod) {
|
||||
AddHelpCommand();
|
||||
AddCommand("Method", static_cast<CModCommand::ModCmdFunc>(
|
||||
&CClientNotifyMod::OnMethodCommand),
|
||||
"<message|notice|off>", "Sets the notify method");
|
||||
AddCommand("NewOnly", static_cast<CModCommand::ModCmdFunc>(
|
||||
&CClientNotifyMod::OnNewOnlyCommand),
|
||||
"<on|off>",
|
||||
"Turns notifications for unseen IP addresses on or off");
|
||||
AddCommand("OnDisconnect", static_cast<CModCommand::ModCmdFunc>(
|
||||
&CClientNotifyMod::OnDisconnectCommand),
|
||||
"<on|off>",
|
||||
"Turns notifications for clients disconnecting on or off");
|
||||
AddCommand("Show", static_cast<CModCommand::ModCmdFunc>(
|
||||
&CClientNotifyMod::OnShowCommand),
|
||||
"", "Show the current settings");
|
||||
AddCommand("Method", t_d("<message|notice|off>"),
|
||||
t_d("Sets the notify method"),
|
||||
[=](const CString& sLine) { OnMethodCommand(sLine); });
|
||||
AddCommand("NewOnly", t_d("<on|off>"),
|
||||
t_d("Turns notifications for unseen IP addresses on or off"),
|
||||
[=](const CString& sLine) { OnNewOnlyCommand(sLine); });
|
||||
AddCommand(
|
||||
"OnDisconnect", t_d("<on|off>"),
|
||||
t_d("Turns notifications for clients disconnecting on or off"),
|
||||
[=](const CString& sLine) { OnDisconnectCommand(sLine); });
|
||||
AddCommand("Show", "", t_d("Shows the current settings"),
|
||||
[=](const CString& sLine) { OnShowCommand(sLine); });
|
||||
}
|
||||
|
||||
bool OnLoad(const CString& sArgs, CString& sMessage) override {
|
||||
@@ -80,10 +78,12 @@ class CClientNotifyMod : public CModule {
|
||||
CString sRemoteIP = GetClient()->GetRemoteIP();
|
||||
if (!m_bNewOnly ||
|
||||
m_sClientsSeen.find(sRemoteIP) == m_sClientsSeen.end()) {
|
||||
SendNotification(
|
||||
"Another client authenticated as your user. "
|
||||
"Use the 'ListClients' command to see all " +
|
||||
CString(GetUser()->GetAllClients().size()) + " clients.");
|
||||
SendNotification(t_p("<This message is impossible for 1 client>",
|
||||
"Another client authenticated as your user. "
|
||||
"Use the 'ListClients' command to see all {1} "
|
||||
"clients.",
|
||||
GetUser()->GetAllClients().size())(
|
||||
GetUser()->GetAllClients().size()));
|
||||
|
||||
// the set<> will automatically disregard duplicates:
|
||||
m_sClientsSeen.insert(sRemoteIP);
|
||||
@@ -92,58 +92,59 @@ class CClientNotifyMod : public CModule {
|
||||
|
||||
void OnClientDisconnect() override {
|
||||
if (m_bOnDisconnect) {
|
||||
SendNotification(
|
||||
"A client disconnected from your user. "
|
||||
"Use the 'ListClients' command to see the " +
|
||||
CString(GetUser()->GetAllClients().size()) +
|
||||
" remaining client(s).");
|
||||
SendNotification(t_p("<This message is impossible for 1 client>",
|
||||
"A client disconnected from your user. Use "
|
||||
"the 'ListClients' command to see the {1} "
|
||||
"remaining clients.",
|
||||
GetUser()->GetAllClients().size())(
|
||||
GetUser()->GetAllClients().size()));
|
||||
}
|
||||
}
|
||||
|
||||
void OnMethodCommand(const CString& sCommand) {
|
||||
const CString& sArg = sCommand.Token(1, true).AsLower();
|
||||
const CString sArg = sCommand.Token(1, true).AsLower();
|
||||
|
||||
if (sArg != "notice" && sArg != "message" && sArg != "off") {
|
||||
PutModule("Usage: Method <message|notice|off>");
|
||||
PutModule(t_s("Usage: Method <message|notice|off>"));
|
||||
return;
|
||||
}
|
||||
|
||||
m_sMethod = sArg;
|
||||
SaveSettings();
|
||||
PutModule("Saved.");
|
||||
PutModule(t_s("Saved."));
|
||||
}
|
||||
|
||||
void OnNewOnlyCommand(const CString& sCommand) {
|
||||
const CString& sArg = sCommand.Token(1, true).AsLower();
|
||||
const CString sArg = sCommand.Token(1, true).AsLower();
|
||||
|
||||
if (sArg.empty()) {
|
||||
PutModule("Usage: NewOnly <on|off>");
|
||||
PutModule(t_s("Usage: NewOnly <on|off>"));
|
||||
return;
|
||||
}
|
||||
|
||||
m_bNewOnly = sArg.ToBool();
|
||||
SaveSettings();
|
||||
PutModule("Saved.");
|
||||
PutModule(t_s("Saved."));
|
||||
}
|
||||
|
||||
void OnDisconnectCommand(const CString& sCommand) {
|
||||
const CString& sArg = sCommand.Token(1, true).AsLower();
|
||||
const CString sArg = sCommand.Token(1, true).AsLower();
|
||||
|
||||
if (sArg.empty()) {
|
||||
PutModule("Usage: OnDisconnect <on|off>");
|
||||
PutModule(t_s("Usage: OnDisconnect <on|off>"));
|
||||
return;
|
||||
}
|
||||
|
||||
m_bOnDisconnect = sArg.ToBool();
|
||||
SaveSettings();
|
||||
PutModule("Saved.");
|
||||
PutModule(t_s("Saved."));
|
||||
}
|
||||
|
||||
void OnShowCommand(const CString& sLine) {
|
||||
PutModule("Current settings: Method: " + m_sMethod +
|
||||
", for unseen IP addresses only: " + CString(m_bNewOnly) +
|
||||
", notify on disconnecting clients: " +
|
||||
CString(m_bOnDisconnect));
|
||||
PutModule(
|
||||
t_f("Current settings: Method: {1}, for unseen IP addresses only: "
|
||||
"{2}, notify on disconnecting clients: {3}")(
|
||||
m_sMethod, m_bNewOnly, m_bOnDisconnect));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -153,5 +154,5 @@ void TModInfo<CClientNotifyMod>(CModInfo& Info) {
|
||||
}
|
||||
|
||||
USERMODULEDEFS(CClientNotifyMod,
|
||||
"Notifies you when another IRC client logs into or out of your "
|
||||
"account. Configurable.")
|
||||
t_s("Notifies you when another IRC client logs into or out of "
|
||||
"your account. Configurable."))
|
||||
|
||||
+21
-23
@@ -22,15 +22,12 @@ class CCtcpFloodMod : public CModule {
|
||||
public:
|
||||
MODCONSTRUCTOR(CCtcpFloodMod) {
|
||||
AddHelpCommand();
|
||||
AddCommand("Secs", static_cast<CModCommand::ModCmdFunc>(
|
||||
&CCtcpFloodMod::OnSecsCommand),
|
||||
"<limit>", "Set seconds limit");
|
||||
AddCommand("Lines", static_cast<CModCommand::ModCmdFunc>(
|
||||
&CCtcpFloodMod::OnLinesCommand),
|
||||
"<limit>", "Set lines limit");
|
||||
AddCommand("Show", static_cast<CModCommand::ModCmdFunc>(
|
||||
&CCtcpFloodMod::OnShowCommand),
|
||||
"", "Show the current limits");
|
||||
AddCommand("Secs", t_d("<limit>"), t_d("Set seconds limit"),
|
||||
[=](const CString& sLine) { OnSecsCommand(sLine); });
|
||||
AddCommand("Lines", t_d("<limit>"), t_d("Set lines limit"),
|
||||
[=](const CString& sLine) { OnLinesCommand(sLine); });
|
||||
AddCommand("Show", "", t_d("Show the current limits"),
|
||||
[=](const CString& sLine) { OnShowCommand(sLine); });
|
||||
}
|
||||
|
||||
~CCtcpFloodMod() override {}
|
||||
@@ -76,8 +73,8 @@ class CCtcpFloodMod : public CModule {
|
||||
if (m_iNumCTCP < m_iThresholdMsgs)
|
||||
return CONTINUE;
|
||||
else if (m_iNumCTCP == m_iThresholdMsgs)
|
||||
PutModule("Limit reached by [" + Nick.GetHostMask() +
|
||||
"], blocking all CTCP");
|
||||
PutModule(t_f("Limit reached by {1}, blocking all CTCP")(
|
||||
Nick.GetHostMask()));
|
||||
|
||||
// Reset the timeout so that we continue blocking messages
|
||||
m_tLastCTCP = time(nullptr);
|
||||
@@ -98,14 +95,14 @@ class CCtcpFloodMod : public CModule {
|
||||
const CString& sArg = sCommand.Token(1, true);
|
||||
|
||||
if (sArg.empty()) {
|
||||
PutModule("Usage: Secs <limit>");
|
||||
PutModule(t_s("Usage: Secs <limit>"));
|
||||
return;
|
||||
}
|
||||
|
||||
m_iThresholdSecs = sArg.ToUInt();
|
||||
if (m_iThresholdSecs == 0) m_iThresholdSecs = 1;
|
||||
|
||||
PutModule("Set seconds limit to [" + CString(m_iThresholdSecs) + "]");
|
||||
OnShowCommand("");
|
||||
Save();
|
||||
}
|
||||
|
||||
@@ -113,22 +110,23 @@ class CCtcpFloodMod : public CModule {
|
||||
const CString& sArg = sCommand.Token(1, true);
|
||||
|
||||
if (sArg.empty()) {
|
||||
PutModule("Usage: Lines <limit>");
|
||||
PutModule(t_s("Usage: Lines <limit>"));
|
||||
return;
|
||||
}
|
||||
|
||||
m_iThresholdMsgs = sArg.ToUInt();
|
||||
if (m_iThresholdMsgs == 0) m_iThresholdMsgs = 2;
|
||||
|
||||
PutModule("Set lines limit to [" + CString(m_iThresholdMsgs) + "]");
|
||||
OnShowCommand("");
|
||||
Save();
|
||||
}
|
||||
|
||||
void OnShowCommand(const CString& sCommand) {
|
||||
PutModule("Current limit is " + CString(m_iThresholdMsgs) +
|
||||
" CTCPs "
|
||||
"in " +
|
||||
CString(m_iThresholdSecs) + " secs");
|
||||
CString sMsgs = t_p("1 CTCP message", "{1} CTCP messages",
|
||||
m_iThresholdMsgs)(m_iThresholdMsgs);
|
||||
CString sSecs = t_p("every second", "every {1} seconds",
|
||||
m_iThresholdSecs)(m_iThresholdSecs);
|
||||
PutModule(t_f("Current limit is {1} {2}")(sMsgs, sSecs));
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -143,11 +141,11 @@ template <>
|
||||
void TModInfo<CCtcpFloodMod>(CModInfo& Info) {
|
||||
Info.SetWikiPage("ctcpflood");
|
||||
Info.SetHasArgs(true);
|
||||
Info.SetArgsHelpText(
|
||||
Info.SetArgsHelpText(Info.t_s(
|
||||
"This user module takes none to two arguments. The first argument is "
|
||||
"the number of lines after which the flood-protection is triggered. "
|
||||
"The second argument is the time (s) to in which the number of lines "
|
||||
"is reached. The default setting is 4 CTCPs in 2 seconds");
|
||||
"The second argument is the time (sec) to in which the number of lines "
|
||||
"is reached. The default setting is 4 CTCPs in 2 seconds"));
|
||||
}
|
||||
|
||||
USERMODULEDEFS(CCtcpFloodMod, "Don't forward CTCP floods to clients")
|
||||
USERMODULEDEFS(CCtcpFloodMod, t_s("Don't forward CTCP floods to clients"))
|
||||
|
||||
+34
-35
@@ -39,15 +39,12 @@ class CSASLAuthMod : public CModule {
|
||||
m_cbs[1].context = nullptr;
|
||||
|
||||
AddHelpCommand();
|
||||
AddCommand("CreateUser", t_d("[yes|no]"),
|
||||
t_d("Create ZNC user upon first successful login"),
|
||||
[=](const CString& sLine) { CreateUserCommand(sLine); });
|
||||
AddCommand("CloneUser", t_d("[username]"),
|
||||
t_d("User to be used as the template for new users"),
|
||||
[=](const CString& sLine) { CloneUserCommand(sLine); });
|
||||
AddCommand("DisableCloneUser",
|
||||
static_cast<CModCommand::ModCmdFunc>(
|
||||
&CSASLAuthMod::DisableCloneUserCommand));
|
||||
AddCommand("Show", "", t_d("Shows current settings"),
|
||||
[=](const CString& sLine) { ShowCommand(sLine); });
|
||||
AddCommand("CreateUsers", t_d("yes|clone <username>|no"),
|
||||
t_d("Create ZNC users upon first successful login, "
|
||||
"optionally from a template"),
|
||||
[=](const CString& sLine) { CreateUsersCommand(sLine); });
|
||||
}
|
||||
|
||||
~CSASLAuthMod() override { sasl_done(); }
|
||||
@@ -169,37 +166,39 @@ class CSASLAuthMod : public CModule {
|
||||
|
||||
const CString& GetMethod() const { return m_sMethod; }
|
||||
|
||||
void CreateUserCommand(const CString& sLine) {
|
||||
CString sCreate = sLine.Token(1);
|
||||
|
||||
if (!sCreate.empty()) {
|
||||
SetNV("CreateUser", sCreate);
|
||||
}
|
||||
|
||||
if (CreateUser()) {
|
||||
PutModule(t_s("We will create users on their first login"));
|
||||
} else {
|
||||
void ShowCommand(const CString& sLine) {
|
||||
if (!CreateUser()) {
|
||||
PutModule(t_s("We will not create users on their first login"));
|
||||
}
|
||||
}
|
||||
|
||||
void CloneUserCommand(const CString& sLine) {
|
||||
CString sUsername = sLine.Token(1);
|
||||
|
||||
if (!sUsername.empty()) {
|
||||
SetNV("CloneUser", sUsername);
|
||||
}
|
||||
|
||||
if (ShouldCloneUser()) {
|
||||
PutModule(t_f("We will clone {1}")(CloneUser()));
|
||||
} else if (ShouldCloneUser()) {
|
||||
PutModule(
|
||||
t_f("We will create users on their first login, using user "
|
||||
"[{1}] as a template")(CloneUser()));
|
||||
} else {
|
||||
PutModule(t_s("We will not clone a user"));
|
||||
PutModule(t_s("We will create users on their first login"));
|
||||
}
|
||||
}
|
||||
|
||||
void DisableCloneUserCommand(const CString& sLine) {
|
||||
DelNV("CloneUser");
|
||||
PutModule(t_s("Clone user disabled"));
|
||||
void CreateUsersCommand(const CString& sLine) {
|
||||
CString sCreate = sLine.Token(1);
|
||||
if (sCreate == "no") {
|
||||
DelNV("CloneUser");
|
||||
SetNV("CreateUser", CString(false));
|
||||
PutModule(t_s("We will not create users on their first login"));
|
||||
} else if (sCreate == "yes") {
|
||||
DelNV("CloneUser");
|
||||
SetNV("CreateUser", CString(true));
|
||||
PutModule(t_s("We will create users on their first login"));
|
||||
} else if (sCreate == "clone" && !sLine.Token(2).empty()) {
|
||||
SetNV("CloneUser", sLine.Token(2));
|
||||
SetNV("CreateUser", CString(true));
|
||||
PutModule(
|
||||
t_f("We will create users on their first login, using user "
|
||||
"[{1}] as a template")(sLine.Token(2)));
|
||||
} else {
|
||||
PutModule(
|
||||
t_s("Usage: CreateUsers yes, CreateUsers no, or CreateUsers "
|
||||
"clone <username>"));
|
||||
}
|
||||
}
|
||||
|
||||
bool CreateUser() const { return GetNV("CreateUser").ToBool(); }
|
||||
|
||||
Reference in New Issue
Block a user