Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add NickPrefix command to view and set the nickprefix. #1382

Merged
merged 10 commits into from
Mar 15, 2017

Conversation

Cizzle
Copy link
Contributor

@Cizzle Cizzle commented Mar 9, 2017

Hides the internal keyword from ListKeys and adds the NickPrefix comand to view and optionally set another prefix.

void OnListKeysCommand(const CString& sCommand) {
if (BeginNV() == EndNV()) {
if (BeginNV() == EndNV() || BeginNV()->first.Equals(NICK_PREFIX_KEY)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're relying on comparison order between @ and letters. Why are you sure this always works?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NICK_PREFIX_KEY is actually also a "key", so we want to ignore it. If there are no other keys, NICK_PREFIX_KEY will be the first entry. Unless I misunderstood your comment.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you think it's the first entry? Maybe it's the last entry? Or somewhere in the middle?

SetNV(NICK_PREFIX_KEY, sPrefix);
PutModule("Setting Nick Prefix to " + sPrefix);
if (sStatusPrefix.CaseCmp(sPrefix, std::min(sp, np)) == 0)
PutModule("WARNING: overlap with Status Prefix (" + sStatusPrefix + "), this Nick Prefix will not be used!");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will not? I see SetNV above... But what's used instead then?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either "*" or ".", see NickPrefix(). Thought I'd allow setting it in case one changes it's status prefix instead afterwards.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you talking to me or to the user who tried to set such prefix?
I know about that function. But the current behavior would be surprising, and the message which user sees is misleading.

@@ -501,25 +504,36 @@ class CCryptMod : public CModule {
}
}

void OnNickPrefixCommand(const CString& sCommand) {
CString sPrefix = sCommand.Token(1, true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does a prefix with spaces inside mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, thought space could be used but seems they can't, messages from remote don't arrive at the client.

CString sStatusPrefix = GetUser()->GetStatusPrefix();
size_t sp = sStatusPrefix.size();
size_t np = sPrefix.size();
SetNV(NICK_PREFIX_KEY, sPrefix);
PutModule("Setting Nick Prefix to " + sPrefix);
if (sTail.empty())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be fine with just ignoring anything after the first parameter. It's obvious from the message anyway.

if (sPrefix.empty()) {
PutModule("Nick Prefix: " + NickPrefix());
} else if (sPrefix.size() > 1 && sPrefix.StartsWith(":")) {
PutModule("You cannot use : followed by other symbols as Nick Prefix.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's just disable anything starting with :, even if it's :abc or :

CString sPrefix = sCommand.Token(1);

if (sPrefix.empty()) {
/* if (sPrefix.empty()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove...

@DarthGandalf
Copy link
Member

The test fails

@codecov
Copy link

codecov bot commented Mar 15, 2017

Codecov Report

Merging #1382 into master will increase coverage by 0.04%.
The diff coverage is 33.33%.

@@            Coverage Diff             @@
##           master    #1382      +/-   ##
==========================================
+ Coverage    40.4%   40.45%   +0.04%     
==========================================
  Files         109      109              
  Lines       21297    21313      +16     
==========================================
+ Hits         8606     8623      +17     
+ Misses      12691    12690       -1
Impacted Files Coverage Δ
modules/crypt.cpp 48.48% <33.33%> (-3.48%)
src/Threads.cpp 87.06% <0%> (-5.18%)
src/HTTPSock.cpp 51.57% <0%> (-1.05%)
src/IRCNetwork.cpp 73.1% <0%> (+0.39%)
src/IRCSock.cpp 65.69% <0%> (+1.13%)
src/Modules.cpp 59.34% <0%> (+1.32%)
include/znc/Query.h 100% <0%> (+20%)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7feac39...afcafed. Read the comment docs.

@DarthGandalf DarthGandalf merged commit ab34760 into znc:master Mar 15, 2017
@Cizzle Cizzle deleted the feat_crypt_nickprefixcmd branch March 15, 2017 23:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants