skoczen / will

Will is a simple, beautiful-to-code bot for slack, hipchat, and a whole lot more.
https://heywill.io
MIT License
406 stars 170 forks source link

Will bot doesn't seem to join newly created HipChat rooms #183

Open regner opened 9 years ago

regner commented 9 years ago

We have a self hosted version of HipChat and are testing out Will bot. It seems however that when a new room is created he doesn't join them and there is no way to get him to without restarting the bot.

Our config file doesn't list rooms, we just expect him to join them all. It also looks like having a plugin that allows people to invite him to a channel would be... not optimal.

Any suggestions?

skoczen commented 9 years ago

Hey @Regner ,

Thanks for reaching out - definitely hear you.

I don't have a fix at the moment - typically, the number of rooms tends to stabilize for most orgs, so it's been an issue that stops hurting (from what I've seen.)

However, I'm definitely open a PR that gives the behavior you suggest - that will should join any new rooms if he's set to all rooms.

In short, I'd see two paths:

  1. Hooking into a "room created" signal either via webhook or XMPP, or
  2. Periodically polling the list of rooms, and joining any new ones that fit ROOMS.

Both of those are reasonable solves, and should give you what you're looking for - if you have any time to work on them, a PR is definitely welcome!

regner commented 9 years ago

Having taken a quick look at it I think the problem is that when loading the settings if rooms are not specified the rooms allowed to join is set here: https://github.com/skoczen/will/blob/4233c20ce69d04fa1310459d56a67d13e1c69711/will/main.py#L251

There is a listener for new rooms and joining them here: https://github.com/skoczen/will/blob/4233c20ce69d04fa1310459d56a67d13e1c69711/will/listener.py#L66

When a new room is created it checks to see if the room is in the list of allowed rooms to join. However if you don't have rooms listed, because you want the bot in all rooms, then that list of allowed rooms is set at boot as a list of all rooms.

regner commented 9 years ago

Off the top of my head fixing this would require setting some kind of flag in the settings along the lines of "join_all" to True or False. Then when the list of rooms is updated if join_all is True update settings.ROOMS as well?

skoczen commented 9 years ago

Hey @Regner

Thanks for digging into this!

You know what they say about code you wrote six months ago.. Yep, you& your analysis look to be absolutely right.

Your solution sounds great - I'd just set settings.JOIN_ALL when parsing settings, if ROOMS isn't set.

Up for a PR? It may be a bit before I have time to get a new release out, but I'm a definite +1 to this. This is how things should work.

Thanks again!

regner commented 9 years ago

Cool, will see about finding some time to do a PR.

regner commented 9 years ago

When I originally looked at this I assumed that the "rooster_update" event was triggered when new rooms were created. It however does not look like that is the case. It only fires when the xmppclient asks for it to be updated. With that in mind, I don't see a way of joining newly created rooms without constantly updating the rooster with some kind of periodic task.

regner commented 9 years ago

Will bot listens to the event here: https://github.com/skoczen/will/blob/4233c20ce69d04fa1310459d56a67d13e1c69711/will/listener.py#L55

That event is only ever triggered from here: https://github.com/fritzy/SleekXMPP/blob/c024ac8f0b58d114d72660a1967f1632546606ed/sleekxmpp/clientxmpp.py#L231

skoczen commented 9 years ago

@Regner thanks for looking into this. In your specific scenario, how long a delay between room creation and will joining is acceptable? Thinking on polling solutions.

skoczen commented 9 years ago

Also, this is distinctly related to #36.

skoczen commented 9 years ago

And mildly to #157 .

regner commented 9 years ago

@Regner thanks for looking into this. In your specific scenario, how long a delay between room creation and will joining is acceptable? Thinking on polling solutions.

5 minutes would be my hope but it is far from the end of the world if it's more.

wontonst commented 5 years ago

If no further comments, I will close out this issue due to HipChat deprecation.