Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update MTA script

- Fix how it's accesing the info
- Handle more states (delayed, planned work)
- Add when the info was updated.
  • Loading branch information...
commit 8e2fbd15939d7929b453542c67f4a75822b8b4f8 1 parent 81a31cf
@kitop kitop authored
Showing with 14 additions and 9 deletions.
  1. +14 −9 src/scripts/mta.coffee
View
23 src/scripts/mta.coffee
@@ -30,14 +30,19 @@ mtaMe = (msg) ->
throw err
re = new RegExp(msg.match[1], 'gi')
if msg.match[1].length is 1 or msg.match[1].toUpperCase() is 'SIR'
- for k in res.service.subway[0].line
- str = k.name[0]
+ for k in res.service.subway.line
+ str = k.name
if str.match(re)
- if k.status[0] == 'GOOD SERVICE'
- msg.send 'the ' + str + ' train is ok!'
- else if k.status[0] == 'PLANNED WORK'
- msg.send 'heads up, the ' + str + ' train has planned work.'
- else
- msg.send 'the ' + str + ' train is all kinds of messed up'
+ switch k.status
+ when "GOOD SERVICE"
+ msg.send "the #{str} train is ok!"
+ when "PLANNED WORK"
+ msg.send "heads up, the #{str} train has planned work (updated #{k.Time})"
+ when "SERVICE CHANGE"
+ msg.send "the #{str} train has service changes (updated #{k.Time})"
+ when "DELAYS"
+ msg.send "the #{str} train is delayed (updated #{k.Time})"
+ else
+ msg.send "the #{str} train status is #{k.status}"
else
- msg.send 'thats not a valid subway line!'
+ msg.send "that's not a valid subway line!"
Please sign in to comment.
Something went wrong with that request. Please try again.