hubot-archive / hubot-seen

A hubot script that tracks when/where users were last seen.
https://www.npmjs.org/package/hubot-seen
24 stars 15 forks source link

Slack channel name #10

Closed WaleedAshraf closed 8 years ago

WaleedAshraf commented 8 years ago

Right now bot prints slack channel ID i.e xwy was last seen in G1YLK964G less than a minute ago

can't we convert channel id to channel name?

patcon commented 8 years ago

I'd accept that PR if someone could confirm that it works for both slack and irc :)

WaleedAshraf commented 8 years ago

Well Im just confirming that does it happens every where? Or is just me facing this issue?

patcon commented 8 years ago

Slack adaptor has some different behaviour than IRC adaptor in relation to room id's, so while I haven't used this script on slack, it sounds about right

WaleedAshraf commented 8 years ago

Right, I added slack channel name against id in hubot brain.

dgautsch commented 7 years ago

@WaleedAshraf what did you do to accomplish this? Thanks.

WaleedAshraf commented 7 years ago

@dgautsch When ever my bot joins a new channel, I call this method,

robot.respond /channel add (.+)$/i, (msg) ->
        channelName = msg.match[1]
        channelID = msg.message.room
        console.log "Starting channel add: #{channelID} : #{channelName}"
        try
          robot.brain.set channelID, channelName
        catch err
          return msg.send err
        msg.send "Channel Added!"

and then modified seen script a bit, as

lastRoom = robot.brain.get last.chan
        if(lastRoom)
          msg.send "#{nick} was last seen in ##{lastRoom} #{date_string}"
        else
          msg.send "#{nick} was last seen #{date_string}"

check it here: https://github.com/WaleedAshraf/caari/blob/staging/scripts/seen.coffee#L90