Created
May 7, 2014 10:46
-
-
Save eskim/6b10224e213414ff2797 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 = | |
"0006": "gd" | |
"0013": "jncamp" | |
"0012": "jara" | |
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) | |
q.all(qs).then => | |
@memory(memKey, remains).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