hubot-stalk
Version:
Hubot knows what your team is doing.
60 lines (48 loc) • 1.36 kB
text/coffeescript
class List
constructor: () ->
= null
= 3 # number of status to keep in memory
= 5 # number of actions to keep in memory
loadStore = =>
= .brain.data.stalkers_notes || {};
.logger.debug "Stalkers Notes Loaded: " + JSON.stringify(, null, 2)
.brain.on "loaded", loadStore
loadStore()
getUser: (name) ->
user = [name]
if user is undefined
user = {
name: null
lastStatus: null
lastAction: null
lastUpdate: null
following: false
stati: []
actions: []
}
[name] = user
user.name = name
user
follow: (name) ->
user =
user.following = true
user.following
following: (name) ->
user =
user.following
saveStatus: (name, status) ->
user =
user.stati.unshift status
user.lastStatus = status
user.lastUpdate = new Date()
if user.stati.length >
user.stati.pop()
.brain.save()
saveAction: (name, command) ->
user =
user.actions.unshift command
user.lastAction = command
user.lastUpdate = new Date()
if user.actions.length >
user.actions.pop()
module.exports = List