Merge lp://qastaging/~anarcat/ibid/remind-648463 into lp://qastaging/~ibid-core/ibid/old-trunk-1.6

Proposed by anarcat
Status: Merged
Merged at revision: 1017
Proposed branch: lp://qastaging/~anarcat/ibid/remind-648463
Merge into: lp://qastaging/~ibid-core/ibid/old-trunk-1.6
Diff against target: 143 lines (+103/-2)
2 files modified
AUTHORS (+1/-0)
ibid/plugins/fun.py (+102/-2)
To merge this branch: bzr merge lp://qastaging/~anarcat/ibid/remind-648463
Reviewer Review Type Date Requested Status
Max Rabkin Needs Fixing
anarcat (community) final review please Needs Resubmitting
marcog (community) Needs Fixing
Stefano Rivera Approve
Jonathan Hitchcock Pending
Ibid Core Team testing, pythonicity, style Pending
Review via email: mp+40774@code.qastaging.launchpad.net

This proposal supersedes a proposal from 2010-11-04.

Description of the change

see #648463.

To post a comment you must log in.
Revision history for this message
marcog (marco-gallotta) wrote : Posted in a previous version of this proposal

8 +<<<<<<< TREE
9 * Kevin Woodland
10 +=======
11 + * Antoine Beaupré
12 +>>>>>>> MERGE-SOURCE

Borked merge

review: Needs Fixing
Revision history for this message
Stefano Rivera (stefanor) wrote : Posted in a previous version of this proposal

What Marco means is that since you branched from trunk, someone else has touched AUTHORS.

So you need to either:
bzr merge lp:ibid
Fix AUTHORS
bzr resolved AUTHORS
bzr commit -m "Merge from trunk"
bzr push

Or
bzr rebase lp:ibid
Fix AUTHORS
bzr resalved AUTHORS
bzr rebase-continue
bzr push

The first one puts the trunk changes after your changes (which is actually correct, but can get a bit messy). The rebase option puts the trunk changes *before* your changes (you need bzr-rewrite installed to do it), which messes with anyone who's already using your branch, but gives a prettier history.

Revision history for this message
Jonathan Hitchcock (vhata) wrote : Posted in a previous version of this proposal

- AUTHORS file has clashes in it.

- parser exceptions aren't handled

- the messages could do with a bit of punctuation and cleaning up

Otherwise, good start!

review: Needs Fixing
Revision history for this message
Stefano Rivera (stefanor) wrote : Posted in a previous version of this proposal

34 from ibid.utils import human_join, indefinite_article, identity_name, \
35 plural
36 +from ibid.utils import ago, format_date
37 +

Those should be joined.

For the addresponses, please use dictionary-style substitions, i.e.
112 + event.addresponse(u"okay, I will remind %s in %s", (who, ago(delta)))
becomes
event.addresponse(u"Okay, I will remind %(who)s in %(time)s", {
    'who': who,
    'time': ago(delta),
})

review: Needs Fixing
Revision history for this message
anarcat (anarcat) wrote : Posted in a previous version of this proposal

I fixed the clashes. Couldn't rebase as I don't have a recent enough bzr (!? debian squeeze?).

I feel that it's not a problem that parser exceptions are not handled: the bot just complains ("burp" and so on) and the user will figure it out... But I have implemented a handler anyways, I hope it's the right wording.

I have worked quite a lot on the messages (see bug report), so I would like specifics here before starting to hack at this again.

Thanks!

review: Needs Resubmitting
Revision history for this message
Stefano Rivera (stefanor) wrote : Posted in a previous version of this proposal

My comments in my last review still stand.

Yes, you should catch parser exceptions, otherwise user-mistakes show up in the bot-owner's logs. The current message isn't very good, many people don't know what parsing is. "Sorry, but I couldn't understand the time you gave me"

u'Generic timed reminders' <- that's a bit generic, something a little more descriptive would be good.

review: Needs Fixing
Revision history for this message
Max Rabkin (max-rabkin) wrote : Posted in a previous version of this proposal

Nice to see a new name in my review list!

64 + event.addresponse(u'%s: %s asked me to remind you %s, %s ago.', (who, from_who, what, ago(datetime.now()-from_when)))

(and two lines down)

We generally don't include the "%s:" in private messages, so you might want to check event.public.

Your total_seconds variable appears to contain a number of microseconds, so it should be called total_microseconds.

68 + @match(r'^(?:remind|ping)\s+(?:(me|\w+)\s+)?(at|on|in)\s+(.*?)(?:(about|of|to) (.*))?$')

You're inconsistent between '\s+' and ' '. Use ' ' (match turns it into '\s+' automatically). You also don't need the ^ and $.

Also, the only thing you do with the variable how is add it to what -- why not just match use '(.*)?' instead of '(?:(about|of|to) (.*))?'. This will also let one say "remind Taejo in 10 seconds to feed the cat".

It would be nice if we could allow "remind Taejo to feed the cat in 10 seconds", which is more natural, but I realise that the regex might get a little tricky.

Please use full sentences in docstrings. Start sentences with capitals and end them with periods.

When I tried "ping me at 10:50", I got this:

Traceback (most recent call last):
  File "/home/max/devel/ibid/remind-648463/ibid/core.py", line 33, in _process
    processor.process(event)
  File "/home/max/devel/ibid/remind-648463/ibid/plugins/__init__.py", line 145, in process
    method(event, *match.groups())
  File "/home/max/devel/ibid/remind-648463/ibid/plugins/fun.py", line 182, in remind
    ibid.dispatcher.call_later(total_seconds, self.announce, event, who, what, from_who, now)
UnboundLocalError: local variable 'now' referenced before assignment

review: Needs Fixing
Revision history for this message
anarcat (anarcat) wrote : Posted in a previous version of this proposal

> Nice to see a new name in my review list!

Thanks for all the reviews...

> 64 + event.addresponse(u'%s: %s asked me to remind you %s, %s
> ago.', (who, from_who, what, ago(datetime.now()-from_when)))
>
> (and two lines down)
>
> We generally don't include the "%s:" in private messages, so you might want to
> check event.public.

Fixed.

> Your total_seconds variable appears to contain a number of microseconds, so it
> should be called total_microseconds.

That is incorrect: it's a number of seconds. It's a reimplementation of delta.total_seconds(). Notice how the microseconds get divided by 10**6 at the end of that line.

> 68 +
> @match(r'^(?:remind|ping)\s+(?:(me|\w+)\s+)?(at|on|in)\s+(.*?)(?:(about|of|to)
> (.*))?$')
>
> You're inconsistent between '\s+' and ' '. Use ' ' (match turns it into '\s+'
> automatically). You also don't need the ^ and $.

fixed. i also added please.

> Also, the only thing you do with the variable how is add it to what -- why not
> just match use '(.*)?' instead of '(?:(about|of|to) (.*))?'. This will also
> let one say "remind Taejo in 10 seconds to feed the cat".

the problem is we need a token here to avoid eating the whole "what" with the time regex. since the time string can be very flexible, i'm not sure i can match it with a regex, so I prefer to have a bunch of keywords that allows us to parse the string better.

I don't see why we can't do what you want here anyways:

09:33:21 <anarcat> ibicat: remind me in 10 seconds to feed the cat
09:33:21 <ibicat> anarcat: okay, I will remind you in 10 seconds
09:33:31 <ibicat> anarcat: you asked me to remind you to feed the cat, 10 seconds ago.

> It would be nice if we could allow "remind Taejo to feed the cat in 10
> seconds", which is more natural, but I realise that the regex might get a
> little tricky.

Yeah, and then the argument order in the callback would be screwed up. This is actually how I started too, but then I switched, I don't remember why.

Maybe the arguments could be "named"? I'm not sure how to do this in this context...

> Please use full sentences in docstrings. Start sentences with capitals and end
> them with periods.

Fixed.

> When I tried "ping me at 10:50", I got this:

Fixed.

Now onto other reviews.

Revision history for this message
anarcat (anarcat) wrote : Posted in a previous version of this proposal

> My comments in my last review still stand.
>
> Yes, you should catch parser exceptions, otherwise user-mistakes show up in
> the bot-owner's logs. The current message isn't very good, many people don't
> know what parsing is. "Sorry, but I couldn't understand the time you gave me"
>
> u'Generic timed reminders' <- that's a bit generic, something a little more
> descriptive would be good.

Both fixed.

Revision history for this message
anarcat (anarcat) wrote : Posted in a previous version of this proposal

I have also fixed the addresponse() to use dictionnaries instead of printf-style interpolation.

I have yet to fix the order and flexibility of the regex. I feel this is not critical and can be fixed later. I have introduce a bunch of changes here and I'm hesitant to break this furthermore.

review: Needs Resubmitting (testing, final?)
Revision history for this message
anarcat (anarcat) wrote : Posted in a previous version of this proposal

One last comment here: to allow both "ping me in 5 about foo" and "ping me about foo in 5", we would need to allow for named subgroups to be passed as named arguments to the match function.

This doesn't document this as being possible:

http://ibid.omnia.za.net/docs/trunk/api/ibid.plugins.html

... so I will not struggle with it for now. But basically, I think what I would like is this:

    @match(r'(?:please )?(?:remind|ping) (?:(^P<who>me|\w+) )?(?P<at>at|on|in) (?P<when>.*?)(?:(?P<how>about|of|to) (?P<what>.*))?')
    def remind(self, event, who, at, when, how, what):

... and of course whatever is responsible for calling remind() would need to pass the regex dictionnary. This would also require to have multiple regex in the @match() block to allow us to have different patterns that would match the same callback (is that possible now?).

tumbleweed mentionned on irc how named groups would be useful for i18n eventually.

oh, and I have more stuff to push, the dictionnary thing is broken. hold on.

review: Needs Fixing
Revision history for this message
Max Rabkin (max-rabkin) wrote : Posted in a previous version of this proposal

<Taejo> Ibido: remind me at 11:00 about the cat
<Ibido> Taejo: I can't travel in time back to 22 minutes and 33 seconds ago (yet) so I'll tell you now about the cat

Haha, very nice.

review: Approve
Revision history for this message
Stefano Rivera (stefanor) wrote : Posted in a previous version of this proposal

Aaaaalmost there.

> from datetime import datetime

That belongs with the stdlib imports

16:54 <@tumbleweed> tibid: remind me in half an hour about DL meeting
16:54 < tibid> tumbleweed: Sorry, I couldn't understand the time you gave me
16:54 <@tumbleweed> tibid: remind me in 30 mins about DL meeting
16:54 < tibid> tumbleweed: Sorry, I couldn't understand the time you gave me
16:54 <@tumbleweed> tibid: remind me in 30 min about DL meeting
16:54 < tibid> tumbleweed: Sorry, I couldn't understand the time you gave me
16:54 <@tumbleweed> tibid: remind me in 30 minutes about DL meeting
16:54 < tibid> tumbleweed: okay, I will remind you in 30 minutes

Pity abbreviations don't work...

> "okay, I will"...

That should be "Okay, I will"...

> "you asked me"

Same there

135 + if what:
136 + event.addresponse(u"okay, I will remind %(who)s in %(time)s", {
137 + 'who': who,
138 + 'time': ago(delta)
139 + })
140 + else:
141 + event.addresponse(u"okay, I will ping %(who)s in %(time)s", {
142 + 'who': who,
143 + 'time': ago(delta)
144 + })

Seems like unnecessary duplication. Easily solved with %(action)s.

review: Needs Fixing
Revision history for this message
Stefano Rivera (stefanor) wrote : Posted in a previous version of this proposal

Whoops:

2010-10-07 16:59:43,336 ERROR core.dispatcher: Exception occured in Remind processor of fun plugin.
Event: {'account': 1, 'responses': [{'reply': u"I can't travel in time back to 15 hours, 59 minutes and 43 seconds ago (yet) so I'll tell you now to test", 'address': True, 'target': u'tumbleweed!<email address hidden>', 'conflate': True, 'source': u'atrum'}], 'source': u'atrum', 'addressed': True, 'processed': True, 'time': datetime.datetime(2010, 10, 7, 14, 59, 43, 330179), 'identity': 1, 'message': {'raw': u'remind me at 1am to test', 'deaddressed': u'remind me at 1am to test', 'clean': u'remind me at 1am to test', 'stripped': u'remind me at 1am to test'}, 'type': u'message', 'public': False, 'channel': u'tumbleweed!<email address hidden>', 'sender': {'nick': u'tumbleweed', 'connection': u'tumbleweed!<email address hidden>', 'id': u'tumbleweed'}}
Traceback (most recent call last):
  File "/home/stefanor/bzr/ibid/stefanor/tibid/ibid/core.py", line 29, in process
    processor.process(event)
  File "/home/stefanor/bzr/ibid/stefanor/tibid/ibid/plugins/__init__.py", line 145, in process
    method(event, *match.groups())
  File "/home/stefanor/bzr/ibid/stefanor/tibid/ibid/plugins/fun.py", line 201, in remind
    ibid.dispatcher.call_later(total_seconds, self.announce, event, who, what, from_who, now)
  File "/home/stefanor/bzr/ibid/stefanor/tibid/ibid/core.py", line 109, in call_later
    return reactor.callLater(delay, threads.deferToThread, self.delayed_call, callable, event, *args, **kw)
  File "/usr/lib/python2.6/dist-packages/twisted/internet/base.py", line 693, in callLater
    "%s is not greater than or equal to 0 seconds" % (_seconds,)
AssertionError: -57584 is not greater than or equal to 0 seconds

Revision history for this message
marcog (marco-gallotta) wrote : Posted in a previous version of this proposal

17:28 <marcog> remind me in 0 minutes about food
17:28 <tibid> okay, I will remind you in
17:28 <tibid> you asked me to remind you about food, 12 milliseconds ago.

review: Needs Fixing
Revision history for this message
marcog (marco-gallotta) wrote : Posted in a previous version of this proposal

How about adding an "announce <announcement> at 5pm"? Perhaps a second iteration.

Revision history for this message
marcog (marco-gallotta) wrote : Posted in a previous version of this proposal

17:29 <marcog> remind me to eat in 3 seconds
17:29 <tibid> Hello remind me to eat in 3 second

This ordering should work. The response is probably a weird match-alot wildcarded factoid, so ignore that.

review: Needs Fixing
Revision history for this message
Max Rabkin (max-rabkin) wrote : Posted in a previous version of this proposal

I like "announce" without any target.

As anarcat noted, alternative orders will be much easier when we fix #656201 (Named groups in match regexes) -- and I'm planning to do that soon.

Revision history for this message
Jonathan Hitchcock (vhata) wrote : Posted in a previous version of this proposal

12:32 <Vhata> tibid: remind me at 12:30 about foo
12:32 <tibid> Vhata: I can't travel in time back to 2 minutes and 16 seconds ago (yet) so I'll tell you now about foo

It's cute, but that's not what a human would do. I'd prefer: "I assume you mean 12:30 tomorrow - I'll tell you about foo then" (or something)

review: Needs Fixing
Revision history for this message
marcog (marco-gallotta) wrote : Posted in a previous version of this proposal

13:26 < drubin> Maaz: remind drubin to follow up on
                http://wiki.ubuntu-women.org/Courses/IRC
13:26 < Maaz> drubin: Excuse me?
13:26 < drubin> bad bot

I know Maaz doesn't have this brach merged, but AFAIK we don't handle this case of "remind me about X" without a time. I can't think of a best way to handle it except for maybe sending a memo the first time the user does something after one hour.

Revision history for this message
anarcat (anarcat) wrote : Posted in a previous version of this proposal

> 17:29 <marcog> remind me to eat in 3 seconds
> 17:29 <tibid> Hello remind me to eat in 3 second
>
> This ordering should work. The response is probably a weird match-alot
> wildcarded factoid, so ignore that.

I don't see that here.

16:25:17 <anarcat> ibicat: remind me to eat in 3 seconds
16:25:18 <ibicat> anarcat: Sorry...

Furthermore, I think that problem is related to the fact we don't allow named regex match groups which would allow me to support variable orders like this. For now, I am limited by the API and can't match both:

remind me in 1 minute about foo

and

remind me about foo in 1 minute

so we'll have to decide on which for now.

Revision history for this message
anarcat (anarcat) wrote : Posted in a previous version of this proposal

> Aaaaalmost there.
>
> > from datetime import datetime
>
> That belongs with the stdlib imports

Not sure what this means, should I move the import? Should I "import as"?

> 16:54 <@tumbleweed> tibid: remind me in half an hour about DL meeting
> 16:54 < tibid> tumbleweed: Sorry, I couldn't understand the time you gave me
> 16:54 <@tumbleweed> tibid: remind me in 30 mins about DL meeting
> 16:54 < tibid> tumbleweed: Sorry, I couldn't understand the time you gave me
> 16:54 <@tumbleweed> tibid: remind me in 30 min about DL meeting
> 16:54 < tibid> tumbleweed: Sorry, I couldn't understand the time you gave me
> 16:54 <@tumbleweed> tibid: remind me in 30 minutes about DL meeting
> 16:54 < tibid> tumbleweed: okay, I will remind you in 30 minutes
>
> Pity abbreviations don't work...

Yeah, sorry..

> > "okay, I will"...
>
> That should be "Okay, I will"...

fixed.

> > "you asked me"
>
> Same there

fixed.

> 135 + if what:
> 136 + event.addresponse(u"okay, I will remind %(who)s in
> %(time)s", {
> 137 + 'who': who,
> 138 + 'time': ago(delta)
> 139 + })
> 140 + else:
> 141 + event.addresponse(u"okay, I will ping %(who)s in
> %(time)s", {
> 142 + 'who': who,
> 143 + 'time': ago(delta)
> 144 + })
>
> Seems like unnecessary duplication. Easily solved with %(action)s.

fixed.

Revision history for this message
anarcat (anarcat) wrote : Posted in a previous version of this proposal

> Whoops:
>
[...]
> AssertionError: -57584 is not greater than or equal to 0 seconds

also fixed.

Revision history for this message
anarcat (anarcat) wrote : Posted in a previous version of this proposal

> 17:28 <marcog> remind me in 0 minutes about food
> 17:28 <tibid> okay, I will remind you in
> 17:28 <tibid> you asked me to remind you about food, 12 milliseconds ago.

This is a bug with "ago()". I have now a special handler in my code for this, but I consider this bug outside the scope of this...

Revision history for this message
anarcat (anarcat) wrote : Posted in a previous version of this proposal

I have added "remind" the list of allowed aliases for the "tell" plugin so that you can do:

17:15:10 <anarcat> ibicat: remind anarcat about foo
17:15:11 <ibicat> anarcat: Yessir
17:15:13 <anarcat> foo
17:15:14 <ibicat> anarcat: By the way, anarcat on IMC told me "remind anarcat about foo" 3 seconds ago

Now we could expand the regex of the tell, and ideally merge those two plugins, but I think this is currently okay and refactoring could happen after merge... don't you think? :)

Revision history for this message
anarcat (anarcat) wrote : Posted in a previous version of this proposal

Of course I approve my own changes here. :) I think I have repeatedly addressed all concerns addressed here.

The *only* things that would remain here, but I think should be in a second phase, are:

 1. "announcements" for everyone to hear
 2. merge with the memo plugin: share the syntax and the decorators
 3. merge with memo: make a memo if the person is not there at the given time

Since i do not think those should be blocking the merge, i am approving this. :)

review: Approve
Revision history for this message
Stefano Rivera (stefanor) wrote : Posted in a previous version of this proposal

> Not sure what this means, should I move the import? Should I "import as"?

I mean with the first block of imports, the ones from the standard library, as opposed to being next to dateutil. Above unicodedata, not above dateutil.

> Of course I approve my own changes here.

That's taken for-granted :P You shouldn't review your own merge request.

I see a conflict in memo. In fact, I don't understand why we change memo, now memo conflicts with remind:

22:45 < tumbleweed> tibid: remind me in 5 minutes about something
22:45 < tibid> tumbleweed: Got it, I'll remind me on atrum

That's presumably not what we want.

review: Needs Fixing
979. By anarcat

move datetime include with the other stdlib includes

Revision history for this message
anarcat (anarcat) wrote :
Download full text (4.3 KiB)

I again had problems with bzr, but I tried to push a fix for stefano's concerns:

anarcat@angela:plugins$ bzr push --no-strict lp:~anarcat/ibid/remind-648463
Enter passphrase for key '/home/anarcat/.ssh/id_dsa':
Traceback (most recent call last):
  File "/srv/bazaar.launchpad.net/production/launchpad-rev-11738/eggs/Twisted-10.1.0-py2.6-linux-x86_64.egg/twisted/internet/defer.py", line 441, in _runCallbacks
    self.result = callback(self.result, *args, **kw)
  File "/srv/bazaar.launchpad.net/production/launchpad-rev-11738/lib/lp/codehosting/vfs/branchfs.py", line 688, in got_path_info
    control_string, branch_string, repository_string)
  File "/srv/bazaar.launchpad.net/production/launchpad-rev-11738/lib/lp/codehosting/vfs/branchfsclient.py", line 122, in branchChanged
    repository_string)
  File "/srv/bazaar.launchpad.net/production/launchpad-rev-11738/lib/lp/services/twistedsupport/xmlrpc.py", line 50, in callRemote
    method_name, *args, **kwargs)
--- <exception caught here> ---
  File "/srv/bazaar.launchpad.net/production/launchpad-rev-11738/eggs/Twisted-10.1.0-py2.6-linux-x86_64.egg/twisted/internet/defer.py", line 125, in maybeDeferred
    result = f(*args, **kw)
  File "/srv/bazaar.launchpad.net/production/launchpad-rev-11738/lib/lp/services/twistedsupport/xmlrpc.py", line 35, in callRemote
    return getattr(self._proxy, method_name)(*args, **kwargs)
  File "/usr/lib/python2.6/xmlrpclib.py", line 1199, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib/python2.6/xmlrpclib.py", line 1489, in __request
    verbose=self.__verbose
  File "/usr/lib/python2.6/xmlrpclib.py", line 1253, in request
    return self._parse_response(h.getfile(), sock)
  File "/usr/lib/python2.6/xmlrpclib.py", line 1392, in _parse_response
    return u.close()
  File "/usr/lib/python2.6/xmlrpclib.py", line 838, in close
    raise Fault(**self._stack[0])
xmlrpclib.Fault: <Fault -1: 'Unexpected Zope exception: AssertionError: '>
Pushed up to revision 978.
anarcat@angela:plugins$ bzr push --no-strict lp:~anarcat/ibid/remind-648463
Enter passphrase for key '/home/anarcat/.ssh/id_dsa':
Traceback (most recent call last):
  File "/srv/bazaar.launchpad.net/production/launchpad-rev-11738/eggs/Twisted-10.1.0-py2.6-linux-x86_64.egg/twisted/internet/defer.py", line 441, in _runCallbacks
    self.result = callback(self.result, *args, **kw)
  File "/srv/bazaar.launchpad.net/production/launchpad-rev-11738/lib/lp/codehosting/vfs/branchfs.py", line 688, in got_path_info
    control_string, branch_string, repository_string)
  File "/srv/bazaar.launchpad.net/production/launchpad-rev-11738/lib/lp/codehosting/vfs/branchfsclient.py", line 122, in branchChanged
    repository_string)
  File "/srv/bazaar.launchpad.net/production/launchpad-rev-11738/lib/lp/services/twistedsupport/xmlrpc.py", line 50, in callRemote
    method_name, *args, **kwargs)
--- <exception caught here> ---
  File "/srv/bazaar.launchpad.net/production/launchpad-rev-11738/eggs/Twisted-10.1.0-py2.6-linux-x86_64.egg/twisted/internet/defer.py", line 125, in maybeDeferred
    result = f(*args, **kw)
  File "/srv/bazaar.launchpad.net/production/launchpad-rev-11738/lib/lp/services/twistedsupport/xmlr...

Read more...

review: Needs Resubmitting
Revision history for this message
Stefano Rivera (stefanor) wrote :

OK, I guess I'm happy, there's still a blank line below "from dateutil import parser" that should go.

review: Approve
Revision history for this message
Max Rabkin (max-rabkin) wrote :

usage = u'remind <person> in <time> about <something>'

"in" should be "(in|at)"

> OK, I guess I'm happy, there's still a blank line below "from dateutil import parser" that should go.

I think Stefano means the blank line *above*, since dateutil is in the standard libraries.

review: Approve
Revision history for this message
Stefano Rivera (stefanor) wrote :

Nope, I did mean what I said http://niemeyer.net/python-dateutil

Revision history for this message
Max Rabkin (max-rabkin) wrote :

> Nope, I did mean what I said http://niemeyer.net/python-dateutil

Right. I misread this: "The dateutil module provides powerful
extensions to the standard datetime module, available in Python 2.3+."

Revision history for this message
Max Rabkin (max-rabkin) wrote :

<Taejo> tibid: remind DeFi on 25/12/2010 that Kev wishes him a Merry Christmas
<tibid> Taejo: Sorry, I couldn't understand the time you gave me
<Taejo> tibid: remind DeFi on 12/25/2010 that Kev wishes him a Merry Christmas
<tibid> Taejo: Sorry, I couldn't understand the time you gave me
<Taejo> tibid: remind DeFi tomorrow that Kev wishes him a Merry Christmas
<tibid> Hello remind DeFi tomorrow that Kev wishes him a Merry Christma
<Taejo> tibid: remind DeFi on 25 December that Kev wishes him a Merry Christmas
<tibid> Taejo: Sorry, I couldn't understand the time you gave me

The "hello" is just a factoid, but what concerns me is that there is no clue what is and isn't allowed... after lots and lots of pointless exploration it turns out "25th December 2010" works. Is there no better date parser available?

Revision history for this message
Max Rabkin (max-rabkin) wrote :

\w+ doesn't work for who -- IRC allows, for example, | in nicks.

review: Needs Fixing
Revision history for this message
marcog (marco-gallotta) wrote :

> <Taejo> tibid: remind DeFi on 25/12/2010 that Kev wishes him a Merry Christmas
> <tibid> Taejo: Sorry, I couldn't understand the time you gave me
> <Taejo> tibid: remind DeFi on 12/25/2010 that Kev wishes him a Merry Christmas
> <tibid> Taejo: Sorry, I couldn't understand the time you gave me
> <Taejo> tibid: remind DeFi tomorrow that Kev wishes him a Merry Christmas
> <tibid> Hello remind DeFi tomorrow that Kev wishes him a Merry Christma
> <Taejo> tibid: remind DeFi on 25 December that Kev wishes him a Merry
> Christmas
> <tibid> Taejo: Sorry, I couldn't understand the time you gave me
>
> The "hello" is just a factoid, but what concerns me is that there is no clue
> what is and isn't allowed... after lots and lots of pointless exploration it
> turns out "25th December 2010" works. Is there no better date parser
> available?

http://code.google.com/p/parsedatetime/ looks like it could do the job.

Revision history for this message
Stefano Rivera (stefanor) wrote :

> http://code.google.com/p/parsedatetime/ looks like it could do the job.

LGTM. Can someone investigate where else it would be useful in Ibid? I seem to remember some time hacks in the timezone code.

I'm not mad about new dependencies, but this looks necessary.

Revision history for this message
marcog (marco-gallotta) wrote :

> > http://code.google.com/p/parsedatetime/ looks like it could do the job.
>
> LGTM. Can someone investigate where else it would be useful in Ibid? I seem to
> remember some time hacks in the timezone code.

I'm going to do a quick trial in reminder to see the results.

Revision history for this message
Stefano Rivera (stefanor) wrote :

Can someone investigate where else it would be useful in Ibid?

These could almost certainly benefit from it:
geography.TimeZone.convert
meetings.Poll.start_poll

These would probably work with it:
scripts/ibid-*graph

That would leave us only using dateutil's TZ functionality, which may easily be implementable without dateutil.

Revision history for this message
marcog (marco-gallotta) wrote :

> Can someone investigate where else it would be useful in Ibid?

lp:~ibid-dev/ibid/parsedatetime implements this in remind, geography.TimeZone.convert and meetings.Poll.start_poll.

Revision history for this message
Stefano Rivera (stefanor) wrote :

OK, so this branch can be merged with poor quality time parsing, and Marco will improve it in his parsedatetime branch.

However, we still need to deal with the remaining issues here, Max and Marco are still waiting for things to be fixed. Marco promises to re-review and make it clear what he thinks still needs to be done.

Revision history for this message
marcog (marco-gallotta) wrote :

I'm ignoring some little things I've already fixed in my branch, or things that will become non-issues or different issues in my branch.

> Maybe this should be merged with the memo plugin.

Remove this line. Also remember to remove the "remind" from memo as was mentioned above.

> usage = u'remind <person> in <time> about <something>'

Doesn't cover ping.

> who = who + ": "

Use who += ": "

> if what:
> event.addresponse(u'%(who)s%(from_who)s asked me to remind you %(what)s, %(ago)s ago.', {
> ...
> else:
> event.addresponse(u'%(who)s%(from_who)s asked me to ping you, %(ago)s ago.', {
> ...

Firstly, these two can be combined into one. What if the users says "ping me in 5 minutes about foo"? Then you're going to say "You asked me to remind you about foo 5 minutes ago". Notice the ping vs remind.

> @match(r'(?:please )?(?:remind|ping|alarm) (?:(me|\w+) )?((?:at|on|in) .*?)(?:(about|of|to) (.*))?')

Is \w+ sufficient to match nicks?

Do we need the optional "please"? I think "alarm" is going to go unused (I haven't seen it used in testing once). I think "of" might be unnecessary. How about an "announce" which doesn't target an individual?

> from_who = event.sender['nick']

You only use from_who 3 times. I'd rather use event.sender['nick'] each time to make the code easier to read.

> who = who.strip()

This seems redundant as the nick will already be stripped.

> # XXX: this is total_seconds() in 2.7

If we want to keep this comment, please remove the "XXX:". I think it could be removed though.

> 'time': " in " + ago(delta) if delta else "",

We don't have a if b else c in 2.5, which ibid supports. There are other places you use this.

For future iterations (I think we should ignore these for the initial commit):

1. Use ibid accounts.
2. Add deletion of reminders.
3. Limit the number of unsent reminders per user (avoid spam).

Revision history for this message
marcog (marco-gallotta) :
review: Needs Fixing
Revision history for this message
anarcat (anarcat) wrote :
Download full text (4.7 KiB)

> I'm ignoring some little things I've already fixed in my branch, or things
> that will become non-issues or different issues in my branch.
>
> > Maybe this should be merged with the memo plugin.
>
> Remove this line. Also remember to remove the "remind" from memo as was
> mentioned above.

Okay, removed. The patch on memo.py has already been dropped.

> > usage = u'remind <person> in <time> about <something>'
>
> Doesn't cover ping.

That is on purpose. I was told to keep the usage simple so that people discover other natural occurences. The original usage covered all use cases and I was told to change it. See https://bugs.launchpad.net/ibid/+bug/648463/comments/4

> > who = who + ": "
>
> Use who += ": "

Done.

> > if what:
> > event.addresponse(u'%(who)s%(from_who)s asked me to remind you %(what)s,
> %(ago)s ago.', {
> > ...
> > else:
> > event.addresponse(u'%(who)s%(from_who)s asked me to ping you, %(ago)s
> ago.', {
> > ...
>
> Firstly, these two can be combined into one.

Done.

> What if the users says "ping me
> in 5 minutes about foo"? Then you're going to say "You asked me to remind you
> about foo 5 minutes ago". Notice the ping vs remind.

That is also on purpose: the idea is that "ping" is a like a "remind" but without a subject (a "what").

> > @match(r'(?:please )?(?:remind|ping|alarm) (?:(me|\w+) )?((?:at|on|in)
> .*?)(?:(about|of|to) (.*))?')
>
> Is \w+ sufficient to match nicks?

Apparently not. A nickname is a hairy thing in IRC, according to RFC2812:

  nickname = ( letter / special ) *8( letter / digit / special / "-" )

  letter = %x41-5A / %x61-7A ; A-Z / a-z
  digit = %x30-39 ; 0-9
  special = %x5B-60 / %x7B-7D
                   ; "[", "]", "\", "`", "_", "^", "{", "|", "}"

I have updated the regex to follow that, but it's ugly and I'm uncertain of it now... but it seems to work:

17:40:20 <anarcat> ibicat: ping anarcat in 1 s
17:40:20 <ibicat> anarcat: Okay, I will ping you in 1 second
17:40:21 <ibicat> anarcat: You asked me to ping you, 1 second ago.
17:40:25 <anarcat> ibicat: ping anarca{}t in 1 s
17:40:25 <ibicat> anarcat: Okay, I will ping anarca{}t in 1 second
17:40:26 <ibicat> anarca{}t: anarcat asked me to ping you, 1 second ago.

> Do we need the optional "please"?

I think it's nice that the bot answers even if we are polite to him. I seem to remember seeing other instances of this in other plugins.

> I think "alarm" is going to go unused (I haven't seen it used in testing once).

We use it in another bot we're trying to replace here.

> I think "of" might be unnecessary.

You could ask "remind me of the nuclear meltdown in 200 years" or something... Would make sense in english, wouldn't it?

> How about an "announce" which doesn't target an individual?

That's an extra feature that's been requested elsewhere that is currently not targeted for this patch.

> > from_who = event.sender['nick']
>
> You only use from_who 3 times. I'd rather use event.sender['nick'] each time
> to make the code easier to read.

I thought 3 was a good threshold, but okay, done.

> > who = who.strip()
>
> This seems redundant as the nick will already be stripped.

Indeed,...

Read more...

review: Needs Resubmitting
Revision history for this message
Max Rabkin (max-rabkin) wrote :

> I must state now that I am getting a bit tired of re-resubmitting that patch over and over again. I can't seem to get it right and there always seem to be a little thing to keep the patch from getting merged in.

I agree with you, and we are trying to make the process a little easier for newcomers. I'm sure you understand that we want to have clean, reliable and user-friendly code, though, and I'd like to assure you that your second merge will go a lot more smoothly having gone through this once.

If you can suggest any way we can be more welcoming to new contributors, I'd love to hear them. Perhaps we should be more involved in making some of the smaller changes ourselves (we generally leave everything up to the original author, but it doesn't have to be that way).

980. By anarcat

stylistic changes, allow all standard nicknames

this is yet another round of reviews, this time addressing concerns of
marcog and Max Rabkin formulated on launchpad

Revision history for this message
anarcat (anarcat) wrote :

> > I must state now that I am getting a bit tired of re-resubmitting that patch
> over and over again. I can't seem to get it right and there always seem to be
> a little thing to keep the patch from getting merged in.
>
> I agree with you, and we are trying to make the process a little easier for
> newcomers. I'm sure you understand that we want to have clean, reliable and
> user-friendly code, though, and I'd like to assure you that your second merge
> will go a lot more smoothly having gone through this once.

I'm happy to hear that, I and fully understand the intent here - I admire your perseverance in peer-reviewing the code, that is a good thing, even if painful for someone like me that comes from a much more relaxed culture in that regard.

> If you can suggest any way we can be more welcoming to new contributors, I'd
> love to hear them. Perhaps we should be more involved in making some of the
> smaller changes ourselves (we generally leave everything up to the original
> author, but it doesn't have to be that way).

I think doing the small changes yourselves would help, especially after the 5th submission of the patch... :) While Python is a very elegant language, not everyone is familiar with all the little idiosyncracies of it, and especially not from a "version-compatibility" perspective, for example. I think focus should be on getting a working patch in, and style changes should be welcome as improvements on the patch.

For example, in this patch the second review request was mainly feature complete and didn't have any bugs reviewers could find. Subsequent reviews were all style issues and also broke down in more over-arching issues about the time/date parsing in the rest of the project, and which didn't concern this patch directly. I believe that #973 could have been committed and the issue be kept open for improvements. Instead, more small changes were requested to the patch, which added an extra month to the review process, and which brought us to november, and another iteration of mostly the same review, which brought us to 2011... and so on. :)

The fact that I wasn't familiar with bzr's and launchpad's peculiar development style made it difficult for me to send you good patches to review also. For example, I just now realized that I didn't *really* push the patch yesterday when I did a bzr push, I had to push to the specific branch... *ugh* :)

But I understand the need to have a formal review process and certainly appreciate that. I am worried that it makes contributions really hard on people. Maybe that's what I get for asking review on "pythonicity" and "style" though ;)

review: Needs Resubmitting (final review please)
Revision history for this message
Max Rabkin (max-rabkin) wrote :

> > Is \w+ sufficient to match nicks?
>
> Apparently not. A nickname is a hairy thing in IRC, according to RFC2812:
>
> nickname = ( letter / special ) *8( letter / digit / special / "-" )
>
> letter = %x41-5A / %x61-7A ; A-Z / a-z
> digit = %x30-39 ; 0-9
> special = %x5B-60 / %x7B-7D
> ; "[", "]", "\", "`", "_", "^", "{", "|", "}"
>
> I have updated the regex to follow that, but it's ugly and I'm uncertain of it
> now... but it seems to work:

Better to just use {chunk}, which matches any string of non-space characters -- not only is that complicated, but Ibid is not just for IRC, and some IRC servers allow a wider range of characters (my nick on irc.unilang.org is 대조). I'll fix it though.

review: Needs Fixing

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches