Created
May 7, 2014 10:59
-
-
Save eskim/b1acfa7f7bf0c33969c2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CAMP_CODES = | |
"0005": "강동" | |
"0013": "중랑" | |
"0012": "자라섬" | |
Agent.check = -> | |
true | |
Agent.receive = (evts)-> | |
@log 'events', evts | |
aid = evts.agent_id | |
items = evts.payload.items | |
@log('receive events') | |
msgs = []; | |
e_list = items | |
qs = _.map items, (e)=> | |
memKey = [aid, e.PlayDate, e.GroupCode].join(":") | |
remains = e.ProductRemainCount | |
@memory(memKey).then (prev)=> | |
@log(memKey + " : " + prev + ", " + remains) | |
if !prev or (prev != remains) | |
msg = [aid, e.PlayDate, e.GroupName, remains].join(" : ") | |
msgs.push(msg) | |
@memory(memKey, remains) | |
q.all(qs).then => | |
if msgs.length | |
@create_event({title: "Huginn", url:"http://huginn.app.esfoo.com", message:msgs.join("\n")}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment