Class: VideoTitle

Inherits:
Object
  • Object
show all
Includes:
Cinch::Plugin
Defined in:
lib/rateless_bot/plugins/video_title.rb

Instance Method Summary collapse

Instance Method Details

#get_url(message) ⇒ Object



18
19
20
21
# File 'lib/rateless_bot/plugins/video_title.rb', line 18

def get_url(message)
  index = message.index("youtube.com\/watch\?")
  message[index..message.length].split(' ')[0]
end

#get_video_title(video_url) ⇒ Object



23
24
25
26
# File 'lib/rateless_bot/plugins/video_title.rb', line 23

def get_video_title(video_url)
  video = VideoInfo.new(video_url)
  video.title
end

#listen(m) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/rateless_bot/plugins/video_title.rb', line 10

def listen(m)
  if m.message.match(/youtube.com\/watch\?/)
    video_url = get_url(m.message)

    m.reply get_video_title(video_url)
  end
end