Fix for ticket:2981: Bitbucket hook doesn't work when specifying project

I basically just copied the fix from the ``github.py`` web hook dialect.
`firstOrNothing` is a wrong name though: it does not match what its docstring says.