hubot-archive / hubot-auth

Assign roles to users and restrict command access in other scripts
149 stars 54 forks source link

Extra message when trying to ask for roles #16

Closed cycomachead closed 8 years ago

cycomachead commented 9 years ago

See this shell output, the first message is unnecessary:

Alonzo> @Alonzo who has TA role?
Shell: Sorry, only admins can assign roles.
Shell: There are no people that have the 'TA' role.
``
sdimkov commented 9 years ago

You probably use alias for your hubot and it is short-name for Alonzo?

There is a bug in Hubot which causes the same issues for me. See https://github.com/github/hubot/pull/927

hitochan777 commented 8 years ago

I think this is because there are two regex which match the above message. The first reply is caused by /@?(.+) ha(s|ve) (["'\w: -_]+) role/i and the second reply is caused by /who has (["'\w: -_]+) role\?*$/i. I didn't know regex matches more than once...

cycomachead commented 8 years ago

Ran into this again... Considering attempting a fix.

I'm assuming the more specific regex should always be matched. (In the example provided the intention was the second command to be run.)

In this example:

Michael: I don't have deploy role
Alonzo Church: @Michael OK, Michael Ball doesn't have the 'deploy' role.
        @Michael I don't does not exist

The first one should be the only regex matched, right?

I know with Middleware there is a way to prevent multiple middlewae functions from executing, but I can't tell what happens for listener regex's.