Skip to content
This repository has been archived by the owner on Apr 13, 2019. It is now read-only.

User.mask() fails for custom mask string #94

Open
blowback opened this issue Aug 18, 2012 · 5 comments
Open

User.mask() fails for custom mask string #94

blowback opened this issue Aug 18, 2012 · 5 comments

Comments

@blowback
Copy link

The regex pattern in Mask.new() expects the general form nick!user@host. User.mask() however allows you to specify a custom printf-format style string, in which any or all of [nick, user, mask] may be elided - it then calls Mask.new() which fails.

e.g.

mask = User.mask.new("%u@%h")

lib/cinch/mask.rb:17:in `initialize': undefined method `[]' for nil:NilClass (NoMethodError)

I have changed the regex in Mask.new to:

@nick, @user, @host = mask.match(/(?:(.+)!)?(?:(.+)@)?(.+)/)[1..-1]

However, this whole thing probably needs rethinking.

I would suggest that User.mask() take no args and return a Mask object (in canonical n!u@h form), and that User.some_other_method(mask="%n!%u@%h") return a String, since if you have customised the mask string, you can't really expect it to participate in Mask operations.

@dominikh
Copy link
Member

This will require some thinking, but generally you are right. At first I was going to say that you are expected to not leave out fields in the mask specification you pass to User#mask, but that makes no difference considering that %a (authname) is something that would never be part of a mask as IRC understands it.

So yeah, I'll have to think of a better method name. Keep in mind though that I cannot fundamentally change how User#mask works until I release Cinch 3.0 (which is not planned at all yet), because that would break backwards compatibility. So all cases that currently do not raise an exception have to continue to work.

@blowback
Copy link
Author

Yes, tricky one, but currently anyone calling mask() with a custom format string is going to get an error anyway unless they have the magic n!u@h pattern in there somewhere.

Maybe prepend it to the user string if the user string doesn't already start with that? Or retry with the standard string if Mask.new fails? Or raise an exception that explains matters?

@dominikh
Copy link
Member

By no means does it have to include %n, %u and %h. "*!*@*" would be just as valid. It just has to match something!something@something.

@blowback
Copy link
Author

Yes, I know, that's why I said 'n' and not '%n'.

@dominikh
Copy link
Member

The rational behind allowing custom masks was to be able to generate masks such as *!*@something, not to completely leave out fields.

Why exactly we allow fields such as auth name and real name eludes me right now, though…

stickerboy added a commit to stickerboy/irc-scripts that referenced this issue May 18, 2015
 - track nick changes
 - track kicked users
 - star action messages in logs
 - fix ban logging (can't use custom mask string yet - cinchrb/cinch#94)
 - file file write mode, so logs don't get overridden

Know issues:
 - Doesn't track bot messages or notices
 - Doesn't create new file at midnight (needs more testing)
 - Action replies prepend "ACTION" to the message, need to strip that out
Sepheus pushed a commit to stickerboy/irc-scripts that referenced this issue Jan 19, 2016
 - track nick changes
 - track kicked users
 - star action messages in logs
 - fix ban logging (can't use custom mask string yet - cinchrb/cinch#94)
 - file file write mode, so logs don't get overridden

Know issues:
 - Doesn't track bot messages or notices
 - Doesn't create new file at midnight (needs more testing)
 - Action replies prepend "ACTION" to the message, need to strip that out
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants