Last active
August 29, 2015 14:01
-
-
Save eskim/d263dff4f6649fe0732b to your computer and use it in GitHub Desktop.
muninn-receipes
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
q.longStackSupport = true | |
Agent.check = -> | |
url = "http://www.kma.go.kr/wid/queryDFSRSS.jsp?zone=1121585000" | |
q.nfcall(request, url).then (res)=> | |
xml = res[0].body | |
console.log xml | |
$ = cheerio.load(res[0].body) | |
selects = "hour day temp tmx tmn wfEn wfKor pop".split(" ") | |
console.log selects | |
results = [] | |
$('data').each -> | |
results.push _.reduce selects, (memo, key)=> | |
memo[key] = $(@).find(key).text() | |
memo | |
, {} | |
msgs = _.map results, (r)-> | |
{msg: "#{r.hour}시 - #{r.temp}도 (#{r.tmn}/#{r.tmx}) #{r.wfKor} (강수확률:#{r.pop}%)"} | |
@create_event title: 'weather forecast', items: msgs | |
.done() | |
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
# |
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
# {"id":12,"jsonrpc":"2.0","result":[{"playerid":1,"type":"video"}]} | |
# {"id":12,"jsonrpc":"2.0","result":{"item":{"label":"264.540p-iCong.avi","type":"unknown"}}} | |
# | |
jsonrpc = (method, params = [])-> | |
url = "http://eskim2rock.iptime.org:8080/jsonrpc" | |
data = {jsonrpc: "2.0", method: method, params:params, id: 1} | |
q.nsend(request,'post', url, json: data).then (res)-> | |
res[0].body.result | |
Agent.check = -> | |
jsonrpc("Player.GetActivePlayers").then (re)=> | |
if re.length | |
jsonrpc("Player.GetItem", [re[0].playerid]) | |
else | |
@log "no playing" | |
.then (re)=> | |
@create_event re.item | |
.done() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment