Bug 81101 - sheriffbot should also be addressable with a comma in addition to colon
Summary: sheriffbot should also be addressable with a comma in addition to colon
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Gustavo Noronha (kov)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-03-14 06:24 PDT by Gustavo Noronha (kov)
Modified: 2012-03-15 05:50 PDT (History)
3 users (show)

See Also:


Attachments
Patch (2.05 KB, patch)
2012-03-14 06:28 PDT, Gustavo Noronha (kov)
no flags Details | Formatted Diff | Diff
Patch (2.09 KB, patch)
2012-03-14 15:40 PDT, Gustavo Noronha (kov)
abarth: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Gustavo Noronha (kov) 2012-03-14 06:24:48 PDT
sheriffbot should also be addressable with a comma in addition to colon
Comment 1 Gustavo Noronha (kov) 2012-03-14 06:28:30 PDT
Created attachment 131836 [details]
Patch
Comment 2 Gustavo Noronha (kov) 2012-03-14 06:30:21 PDT
The IRC client I use adds a comma after the nickname, when tab-completing, instead of a :. sheriffbot ignores those messages, would be good to allow both.
Comment 3 Adam Barth 2012-03-14 15:00:49 PDT
Comment on attachment 131836 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=131836&action=review

> Tools/Scripts/webkitpy/common/net/irc/ircbot.py:79
> +        if not irclib.irc_lower(request[:nickname_length]).startswith(irclib.irc_lower(self.connection.get_nickname())):

What's the point of trimming request to nickname_length if you're going to use startswith anyway?

> Tools/Scripts/webkitpy/common/net/irc/ircbot.py:84
> +        if request[nickname_length] == ':':

Won't this crash if len(request) == nickname_length ?

> Tools/Scripts/webkitpy/common/net/irc/ircbot.py:85
> +            request = request.split(':')

Also, don't we need to use split(":", 1) to avoid breaking in cases like:

sheriffbot: some message with a : character

?
Comment 4 Gustavo Noronha (kov) 2012-03-14 15:40:12 PDT
Created attachment 131941 [details]
Patch
Comment 5 Gustavo Noronha (kov) 2012-03-14 15:41:59 PDT
(In reply to comment #3)
> > Tools/Scripts/webkitpy/common/net/irc/ircbot.py:79
> > +        if not irclib.irc_lower(request[:nickname_length]).startswith(irclib.irc_lower(self.connection.get_nickname())):
> 
> What's the point of trimming request to nickname_length if you're going to use startswith anyway?

The idea was to only apply irc_lower on what was needed for the test, but it's probably a worthless micro-optimization anyway.

> > Tools/Scripts/webkitpy/common/net/irc/ircbot.py:85
> > +            request = request.split(':')
> 
> Also, don't we need to use split(":", 1) to avoid breaking in cases like:
> 
> sheriffbot: some message with a : character

And the original code even did it, properly =). Thanks for the review!
Comment 6 Adam Barth 2012-03-14 15:53:12 PDT
Comment on attachment 131941 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=131941&action=review

> Tools/Scripts/webkitpy/common/net/irc/ircbot.py:86
> +        # Some IRC clients, like xchat-gnome, default to using a comma
> +        # when addressing someone.
> +        try:
> +            vocative_separator = request[len(connection.get_nickname())]
> +        except IndexError:
> +            return

This patch is fine, but you don't really need to use a try-catch block here.  A simple length test should work fine.  :)
Comment 7 Gustavo Noronha (kov) 2012-03-15 05:50:43 PDT
Committed r110837: <http://trac.webkit.org/changeset/110837>