tonybaloney / hubot-spark

A hubot integration for Cisco Spark
Apache License 2.0
14 stars 6 forks source link

Multiple rooms #5

Open khanly opened 8 years ago

khanly commented 8 years ago

HUBOT_SPARK_ROOMS - A list of room IDs that you want your bot to listen to, seperated with commas.

It works fine when I have only 1 room. When I add more than 1 room separated with comma, I get error message.

HUBOT_SPARK_ROOMS="xxxxxxx,yyyyyyy" (where xxxxxxx and yyyyyyy are room ids)

Please advise.

tonybaloney commented 8 years ago

hi @khanly what is the error? The code doesn't strip any spaces from the room ids I just noticed, so if there are any trailing spaces it would most likely fail

khanly commented 8 years ago

I have checked to make sure the room ids are correct and there are no spaces.

Unhandled rejection {"message":"Failed to get activity.","errors":[{"description":"Failed to get activity."}],"trackingId":"xxxxxxx"}

Unhandled rejection {"message":"Could not find a room with provided ID.","errors":[{"description":"Could not find a room with provided ID."}],"trackingId":"xxxxxxx"}

where "xxxxxxx" is the id.

tonybaloney commented 8 years ago

I'm unable to reproduce this.

anthonyshaw@baloney-book ~/my-bot $ $HUBOT_SPARK_ROOMS="Y2lzY29zcGFyazovL3VzL1JPT00vN2E1YzA0MTAtZWZlOC0xMWU1LWEzYWEtZjU
................................... 5Nzg1MGEwNjYz,Y2lzY29zcGFyazovL3VzL1JPT00vZjIwZDU1NDctNDY3OC0zMTI4LTlkY2UtOGUzYWI4Z
................................... Tg5MDdk"
anthonyshaw@baloney-book ~/my-bot $ ./bin/hubot -a spark
[Fri Jun 17 2016 15:41:42 GMT+1000 (AEST)] DEBUG Loading adapter spark
[Fri Jun 17 2016 15:41:42 GMT+1000 (AEST)] INFO Trying connection to https://api.ciscospark.com/v1
[Fri Jun 17 2016 15:41:42 GMT+1000 (AEST)] INFO Created connection instance to spark
[Fri Jun 17 2016 15:41:42 GMT+1000 (AEST)] DEBUG Completed adding rooms to list
[Fri Jun 17 2016 15:41:42 GMT+1000 (AEST)] DEBUG Created bot, setting up listeners
[Fri Jun 17 2016 15:41:42 GMT+1000 (AEST)] DEBUG Done with custom bot logic

Then tried the badgers example and the bot posted responses to both rooms.

khanly commented 8 years ago

You used

$HUBOT_SPARK_ROOMS="xxxxx,yyyy"

and I used

export HUBOT_SPARK_ROOMS="xxxxx,yyyy"

Could that be the problem?

khanly commented 8 years ago

You would have to wait like 2-3 minutes for it to appear in the terminal. Also, you would see a repeat of response with multiple rooms. Like if you have two rooms, the ping will have two pong responses i the chatroom.

tonybaloney commented 8 years ago

It's far from ideal. I was hoping to move to the official Cisco spark NPM package, but for now, it's closed source so that's not an option. The API doesn't have a steaming endpoint so I had to implement polling and the API doesn't say list messages since id (only timestamp) so it is succeptible to clock drift double hits. I've given feedback to the spark team, once this new API comes out I will update this whole module