dcsan / gitterbot

GitterBot / gitter chatbot with Wiki integration, and more!
https://gitter.im/dcsan/gitterbot
61 stars 83 forks source link

Add gitterbot to remaining FCC rooms #148

Closed dcsan closed 9 years ago

dcsan commented 9 years ago

Gitterbot is awesome. Campers are using it like crazy. Have you been monitoring the statistics? He does a few key things remarkably well I was wondering whether you could roll him out in the rest of our rooms There are about 400 of these - is there a good way to do these in batch? They’re listed here: https://github.com/FreeCodeCamp/freecodecamp/wiki/Official-Free-Code-Camp-Chat-Rooms and https://github.com/FreeCodeCamp/freecodecamp/wiki/List-of-Free-Code-Camp-city-based-Campsites

dcsan commented 9 years ago

this should be as simple as adding to list of rooms here: https://github.com/dcsan/gitterbot/blob/master/nap/data/RoomData.js#L205

those lists of rooms could be refactored from a list of hashes to just one-line roomname array although thats not needed at this point

dcsan commented 9 years ago

@abhisekp let me know if you can do this @QuincyLarson was keen to get the bot live in more rooms and so your help would be appreciated. this is mostly a text edit so it should be OK to just try it and see if we have problems with the rate limit and need a planB.

abhisekp commented 9 years ago

@dcsan I guess this will only be an addition of objects similar to as follows. Right?

{
    name: "FreeCodeCamp/Bhubaneswar"
}

I can do that. First I need to filter out all the chat rooms from the chat room wiki page and make it look like object with name property. Some cleanup work required. I need some time.

oab00 commented 9 years ago

@abhisekp you could make a one-line roomname array and then add a one-line map function at the end to turn them into objects :smile:

var rooms = ['Help', 'Help2'].map(function(room) { return { name: room }; });

as can be seen here -> http://repl.it/BC6M

abhisekp commented 9 years ago

@oab00 sure. Nice. That would be really great for later when the rooms will be read from a flattened array.

dcsan commented 9 years ago

i think most of the main rooms are added, its just the city rooms need to all be added

https://github.com/FreeCodeCamp/freecodecamp/wiki/List-of-Free-Code-Camp-city-based-Campsites

so copy that list and remove any punctuation.

dcsan commented 9 years ago

i guess you didn't manage to test this?

we'll have to see what happens when we run this. i think it may time out gitter API but we only have to join each room ONCE EVER. so we could either

abhisekp commented 9 years ago

You could make the bot join the rooms in chunks!

dcsan commented 9 years ago

yeah with an interval or iterator if you want to try and write some fancy ES6 code.

discussion https://gitter.im/gitterHQ/fcc?at=55d4b3ca569fb38114106509

abhisekp commented 9 years ago

@dcsan update the above comment. The link is broken.

dcsan commented 9 years ago

oh that's a private chat. relevant parts are on #105


@QuincyLarson Is this on startup when joining rooms or just general usage giving people browny points, etc?
dcsan 09:50
hi - I know about one situation where at startup we join a bunch of rooms. when the app starts it will fire a ton of calls immeidately, which triggers the limit.
we have a bunch of regional rooms, so want to add another 400 rooms or so
i think if i switched the whole codebase to use a different API I can get room events without actually listening to the rooms?
but haven't got around to that yet
ie your realtime API
mydigitalself 10:05
i think if i switched the whole codebase to use a different API I can get room events without actually listening to the rooms?
exactly, the way you're doing it on startup right now is probabyl what's causing that issue - does it go away a few minutes after startup and then operates just fine?
dcsan 10:05
https://gitter.im/gitterHQ/fcc?at=55ca6298569f5b53655486af
yep, if i wait a minute or so its fine
i just wanted to check - that event above
  if (msg.notification === 'user_notification') {
that gets fired from the RT client, will happen whenver a message is received in ANY of the rooms that user is joined to?
(as long as we haven't logged in as the bot and turned off notifications for certain rooms manually)
mydigitalself 10:07
exactly
dcsan 10:07
so we would still have to "join" the rooms at least once
if there are 400 rooms we want to do that programmatically but i can just write a "setInterval" script to do that once
after that, just switch to using your new RT api and using the event above
so your nwapp is using
https://github.com/gitterHQ/desktop/blob/master/nwapp/index.js#L11
var Gitter = require('gitter-realtime-client');
but i still need to use the REST api to send messages
dcsan 10:17
currently I "join" the room (even though I maybe already joined) in order to get a Room Object, that I can stream from.
     that.gitter.rooms.join(roomUrl, function(err, room) {
        ....
          var chats = room.streaming().chatMessages();
          chats.on("chatMessages", function(message) {
to avoid doing that I need to replace this code with parts from the RT api:
just checking / thinking aloud