From 2e6ef10555cd0cb3d0c7d4b1366d0384e12b08ac Mon Sep 17 00:00:00 2001 From: encrypt Date: Tue, 10 May 2016 13:44:11 +0000 Subject: [PATCH] add help --- plugins/radio.rb | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/plugins/radio.rb b/plugins/radio.rb index 3718c7d..09939c5 100644 --- a/plugins/radio.rb +++ b/plugins/radio.rb @@ -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 =~ /(.*?) - 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)