This commit is contained in:
encrypt 2016-05-10 13:44:11 +00:00
parent 00c666c628
commit 2e6ef10555

View file

@ -1,3 +1,5 @@
require 'cgi'
class Radio
include Cinch::Plugin
@ -6,24 +8,30 @@ class Radio
match /radio help/, :method => :on_help
match /radio info/, :method => :on_info
match /radio next/, :method => :on_next
def on_play(m, link)
if link =~ /http(s):\/\/(?:www\.)?youtu(?:be\.com\/watch\?v=|\.be\/)([\w\-]+)(&(amp;)?[\w\?=]*)?/
File.open('/tmp/radio', 'w') do |f|
f.puts(link)
f.flush
end
open(link).read =~ /<title>(.*?) - YouTube<\/title>/
m.reply "New song \""+$1+"\""
File.open('/tmp/notify-send', 'w') do |f|
f.puts($1)
f.flush
if open(link).read =~ /<title>(.*?) - YouTube<\/title>/
m.reply "New song \""+CGI.unescapeHTML($1)+"\""
File.open('/tmp/notify-send', 'w') do |f|
f.puts($1)
f.flush
end
end
end
end
def on_help(m)
m.reply 'curl "http://soyuz.labr.xyz:8080/" | play -q - 2>/dev/null'
m.reply 'comandi: '
m.reply ' info - ti dice la canzone che stai sentendo'
m.reply ' pialla - cancella la canzone che stai sentendo'
m.reply ' play <linkdiyoutube> - mette una canzone in playlist'
m.reply ' next - ti fa sentire un altra roba'
end
def on_pialla(m)