Closed MMzF7 closed 1 year ago
I quickly put this together: https://github.com/progval/Limnoria/compare/master...matiasw:Limnoria:seen-now
I tested it, and it worked in the situations I could think of, but maybe I missed some corner cases..?
If it looks good, I will make a PR.
Looks good. Add tests and send a PR, thanks!
My code was missing the case where a named user is still in the channel/not. Have a look: https://github.com/progval/Limnoria/compare/master...matiasw:Limnoria:seen-now
So, let's review the possible cases I need to test against:
@seen nick
seen #channel nick
@seen user nick
@seen user #channel nick
And, for all of these, see if the bot correctly reports that the user is still in the channel when they are, and doesn't when they're not. Make sense? Missing anything?
One thing that I was thinking about was the @seen last
, either in channel or in private. In this case, we do not have the nick of the speaker of the last line immediately available; should we dig it out and report on whether they're still in the channel?
As a practical matter, which is a better structure: modify the existing test cases like testSeen
to handle testing the in-channel status, or adding entirely new test cases?
You don't need to test both in-channel and in private.
And, for all of these, see if the bot correctly reports that the user is still in the channel when they are, and doesn't when they're not. Make sense? Missing anything?
There's also the case of them being in channel but not saying anything.
One thing that I was thinking about was the @seen last, either in channel or in private. In this case, we do not have the nick of the speaker of the last line immediately available
Why?
There's also the case of them being in channel but not saying anything.
Ah, right. I added code to handle that case: https://github.com/progval/Limnoria/compare/master...matiasw:Limnoria:seen-now
One thing that I was thinking about was the
@seen last
, either in channel or in private. In this case, we do not have the nick of the speaker of the last line immediately availableWhy?
Because it's not passed to the last
method: https://github.com/matiasw/Limnoria/blob/c9305b43ffc164ae4623bc65760877e8d0d3cb48/plugins/Seen/plugin.py#L298
We could extract it from the said
db entry, but unless I'm mistaken, it's not "directly available" (note that the msg.nick
is the nick of the user calling the plugin, not the sought-after nick).
We could extract it from the said db entry
sounds good
Ok, that case is now handled: https://github.com/progval/Limnoria/compare/master...matiasw:Limnoria:seen-now
Could you more seasoned devs give me some pointers for writing the tests..?
Yes, I have read that, but I'm still wavering on where & how to start... sorry for my noobishness, I can of course just beat my head against the wall until the blood spells out a clue, but I'd rather hear it in a friendly tone.
This plugin doesn't handle multiple networks with a channel of the same name gracefully. Steps to reproduce:
@seen nick
on #channel@network1I will look into it later... this is enough for today.
This plugin doesn't handle multiple networks with a channel of the same name gracefully
That's fine, there are a few places like this where Limnoria has this issue
I added the first test: https://github.com/progval/Limnoria/commit/1484a7c19d9c7dc11d7ac9ec241389ce570a3937
...but, I need help writing the rest of the cases. Let's start with the one where the user is not in the channel anymore: how do I test to make sure that "is in the channel now" is not in the reply to seen
? I mean, I think I can use assertRegexp
with ^(?:(?!is in the channel now).)*$
(I think?), but how to feed the dummy data of the user joining and parting to the bot?
think I can use assertRegexp with ^(?:(?!is in the channel now).)*$
assertNotRegexp
how to feed the dummy data of the user joining and parting to the bot?
self.irc.feedMsg(ircmsgs.join(self.channel, ..., prefix=...))
Ok, there's one new test case at https://github.com/progval/Limnoria/compare/master...matiasw:Limnoria:seen-now
I ran into a case that is unhandled in the current Seen: when a user has joined, said nothing, and parted, the bot replies to seen nick
with "I have not seen nick". As I see it, it would be better if it said nick was last seen leaving #channel with the part message <part message>
. I think I need to add something to the bot's doPart
, but it is not immediately clear to me what..?
when a user has joined, said nothing, and parted, the bot replies to seen nick with "I have not seen nick". As I see it, it would be better if it said nick was last seen leaving #channel with the part message
.
the Seen plugin provides two commands: @seen
and @any
(aka. @seen any
). The latter should show the part message.
Ok, in that case, the tests should now be comprehensive at https://github.com/progval/Limnoria/compare/master...matiasw:Limnoria:seen-now
I've created a PR: https://github.com/progval/Limnoria/pull/1559
Limnoria replying to seen command or "any" (seen plugin command) if the nick is currently online as "Nick is online right now, last spoken x hr x minutes ago $nick message here". This modification will be very helpful.