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

Log user quit messages #1395

Merged
merged 1 commit into from
Apr 22, 2017
Merged

Conversation

elyscape
Copy link
Contributor

@elyscape elyscape commented Apr 10, 2017

Since OnIRCDisconnected() doesn't include the quit message, and OnQuit() isn't called when the user quits, we need to hook OnSendToIRC().

@codecov
Copy link

codecov bot commented Apr 10, 2017

Codecov Report

Merging #1395 into master will decrease coverage by 0.02%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1395      +/-   ##
==========================================
- Coverage   40.82%   40.79%   -0.03%     
==========================================
  Files         109      109              
  Lines       21777    21785       +8     
==========================================
- Hits         8890     8888       -2     
- Misses      12887    12897      +10
Impacted Files Coverage Δ
modules/log.cpp 20.57% <0%> (-0.71%) ⬇️
modules/simple_away.cpp 58.77% <0%> (-1.76%) ⬇️

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 9146ea6...d32ac7c. Read the comment docs.

@elyscape
Copy link
Contributor Author

elyscape commented Apr 10, 2017

An alternative way to handle this would be to add a new module hook that fires when the user quits, something like OnUserQuit()/OnUserQuitMessage(). Should I do that instead?

@elyscape
Copy link
Contributor Author

Looks like OnUserQuit() exists and is called when a client sends a quit message, which isn't the same thing. So in that case maybe OnUserIRCQuit()/OnUserIRCQuitMessage()?

@elyscape elyscape mentioned this pull request Apr 10, 2017
modules/log.cpp Outdated
@@ -114,6 +114,8 @@ class CLogMod : public CModule {
const vector<CChan*>& vChans) override;
EModRet OnTopic(CNick& Nick, CChan& Channel, CString& sTopic) override;

EModRet OnSendToIRC(CString &sLine) override;
Copy link
Member

Choose a reason for hiding this comment

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

Move & to left

modules/log.cpp Outdated
CIRCNetwork* pNetwork = GetNetwork();
CMessage Message(sLine);
OnQuit(pNetwork->GetIRCNick(),
static_cast<CQuitMessage>(Message).GetReason(),
Copy link
Member

Choose a reason for hiding this comment

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

There is Message.As()

modules/log.cpp Outdated
@@ -399,6 +401,18 @@ void CLogMod::OnQuit(const CNick& Nick, const CString& sMessage,
}
}

CModule::EModRet CLogMod::OnSendToIRC(CString &sLine) {
if (sLine.Token(0) != "QUIT") {
Copy link
Member

Choose a reason for hiding this comment

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

This may break if any tag is sent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How do you 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.

Oh, I see. That being said, do we ever send quit messages with tags?

@elyscape
Copy link
Contributor Author

elyscape commented Apr 11, 2017

If #1398 is merged before this, I can rebase this on top of that to use OnSendToIRCMessage instead of OnSendToIRC. That would have the dual benefits of simplifying the check for quit messages and removing the need to check for tags.

Since OnIRCDisconnected() doesn't include the quit message, and OnQuit()
isn't called when the user quits, we need to hook OnSendToIRCMessage().
@elyscape
Copy link
Contributor Author

Reworked to use OnSendToIRCMessage().

@DarthGandalf DarthGandalf merged commit c28d5ad into znc:master Apr 22, 2017
@elyscape elyscape deleted the feature/log-user-quits branch April 22, 2017 15:56
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