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 swap command to autoattach module #1582

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Add swap command to autoattach module #1582

wants to merge 6 commits into from

Conversation

zchrykng
Copy link

This allows you do swap the position of two rules in the order

To make this work well, we needed to change how settings for the mofule
are stored. This includes a function and check to migrate existing rules over.

This allows you do swap the position of two rules in execution order

To make this work well, we needed to change how settings for the module
are stored. This includes a function and check to migrate existing rules over.
Copy link
Member

@DarthGandalf DarthGandalf left a comment

Choose a reason for hiding this comment

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

Please add a test.

@@ -116,22 +118,36 @@ class CChanAttach : public CModule {
}
}

void HandleSwap(const CString& sLine) {
u_int iA = sLine.Token(1).ToUInt();
Copy link
Member

Choose a reason for hiding this comment

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

Where does this typedef come from?

Copy link
Author

Choose a reason for hiding this comment

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

At least on my machine it is part of the system headers. I was looking at how one of the other modules handled numeric input and copied it from there.

void HandleList(const CString& sLine) {
int Index;
Copy link
Member

Choose a reason for hiding this comment

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

iIndex? please follow the style around...

Copy link
Author

Choose a reason for hiding this comment

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

Will push a fix for this and other some of the other issues soon.

}

delete Index;
Copy link
Member

Choose a reason for hiding this comment

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

WAT?

Copy link
Author

Choose a reason for hiding this comment

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

Sorry, my C++ is really rusty. Will push with fix soon.


Add(bNegated, sChan, sSearch, sHost);
}
Save();
Copy link
Member

Choose a reason for hiding this comment

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

Why?

Copy link
Author

Choose a reason for hiding this comment

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

Because I apparently can't read and misunderstood was some of what the original code was doing. Push coming soon.

}


for (VCString::const_iterator rit = rules.begin(); rit != rules.end();
Copy link
Member

Choose a reason for hiding this comment

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

Why not foreach loop?

Copy link
Member

@DarthGandalf DarthGandalf left a comment

Choose a reason for hiding this comment

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

For what you're trying to do, inserting a new rule into a specified position would probably more useful than swapping 2 rules

client.Write("PRIVMSG *autoattach :Add * test *");
client.ReadUntil("Added to list");
client.Write("PRIVMSG *autoattach :Swap 1 2")
client.ReadUntil("Rules Swapped");
Copy link
Member

Choose a reason for hiding this comment

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

I can show you much easier implementation which will still pass this test:

AddCommand("Swap", "", "",
                   [=](const CString& sLine) { PutModule("Rules Swapped"); });

Can you code here the exact issue which you were facing without this new functionality in place? That's the point of having a test.

Copy link
Author

Choose a reason for hiding this comment

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

Okay, I am working on expanding this, but the thing I'm not sure how to test is the client correctly not attaching when the ignore rule is in place.

return false;
} else {
std::iter_swap(m_vMatches.begin() + (Start - 1),
m_vMatches.begin() + (End - 1));
Copy link
Member

Choose a reason for hiding this comment

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

std::swap(matches[start], maches[end]);

?

return true;
}

bool Swap(int Start, int End) {
Copy link
Member

Choose a reason for hiding this comment

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

Something is wrong with naming of the variables. Where is the prefix?

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