-
Notifications
You must be signed in to change notification settings - Fork 3
/
jesselistening.coffee
37 lines (32 loc) · 1.01 KB
/
jesselistening.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# What's Jesse listening to?
# what is Jesse listening to?
# Description:
# Tells you what song Jesse is listening to
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands:
# what's/what is Jesse listening to?
# what song is this?
silly = require '../lib/silly'
pattern = /what( the fuck)?(('s| is) (this shit )?jesse (is )?(listening to|playing)| song is this| is this song)\??/i
module.exports = (robot) ->
robot.hear pattern, (msg) ->
silly msg
respondWithTrackName(msg)
respondWithTrackName = (msg) ->
url = 'http://www.last.fm/user/Synnister/now'
msg.http(url).get() (err,res,body) ->
infoMatch = body.match(/data-page-title.+?>([^<]+)/i)
if infoMatch
if /last played track/.test(infoMatch[1])
msg.send "Jesse doesn't seem to be listening to music right now."
else
info = infoMatch[1].replace(" (now playing) - Last.fm","")
msg.send "Jesse is listening to #{info}"
else
msg.send "I have no idea, I can't read the Last.fm now page."