From 00c666c628f518bc1999e8ad2f44ade879446929 Mon Sep 17 00:00:00 2001 From: encrypt Date: Tue, 8 Mar 2016 18:10:59 +0100 Subject: [PATCH] restyle --- plugins/amici.rb | 12 ++++ plugins/caffe.rb | 12 ++++ plugins/encrypt.rb | 10 ++++ plugins/film.rb | 19 +++++++ plugins/jops.rb | 10 ++++ plugins/js.rb | 12 ++++ plugins/qup.rb | 9 +++ plugins/radio.rb | 46 +++++++++++++++ plugins/roll.rb | 9 +++ plugins/salvino.rb | 9 +++ plugins/thegamer.rb | 9 +++ plugins/toninegri.rb | 11 ++++ plugins/tpo.rb | 10 ++++ plugins/vergogna.rb | 9 +++ tubiabot.rb | 132 +++---------------------------------------- 15 files changed, 195 insertions(+), 124 deletions(-) create mode 100644 plugins/amici.rb create mode 100644 plugins/caffe.rb create mode 100644 plugins/encrypt.rb create mode 100644 plugins/film.rb create mode 100644 plugins/jops.rb create mode 100644 plugins/js.rb create mode 100644 plugins/qup.rb create mode 100644 plugins/radio.rb create mode 100644 plugins/roll.rb create mode 100644 plugins/salvino.rb create mode 100644 plugins/thegamer.rb create mode 100644 plugins/toninegri.rb create mode 100644 plugins/tpo.rb create mode 100644 plugins/vergogna.rb diff --git a/plugins/amici.rb b/plugins/amici.rb new file mode 100644 index 0000000..47cef2d --- /dev/null +++ b/plugins/amici.rb @@ -0,0 +1,12 @@ +# coding: utf-8 +class Amici + include Cinch::Plugin + + #match /lavor(o|are|atori)/ + match /#{["dio","madonna"].join('|')}/ + def execute(m) + users = [ "qup", "imega", "gresci", "jigen", "lgine", "encrypt", "thegamer" ] + requests = [ "oggi non ho voglia di fare un cazzo", "caffè?", "andiamo al bar?" ] + m.reply users.sample+" "+users.sample+" "+requests.sample + end +end diff --git a/plugins/caffe.rb b/plugins/caffe.rb new file mode 100644 index 0000000..a9e68be --- /dev/null +++ b/plugins/caffe.rb @@ -0,0 +1,12 @@ +# coding: utf-8 +class Caffe + include Cinch::Plugin + + match /caff(è|e)/ + + def execute(m) + users = [ "qup", "imega", "gresci" ] + requests = [ "andiamo al bar?", "caffè?", "bar?" ] + m.reply users.sample+": "+requests.sample + end +end diff --git a/plugins/encrypt.rb b/plugins/encrypt.rb new file mode 100644 index 0000000..1393a56 --- /dev/null +++ b/plugins/encrypt.rb @@ -0,0 +1,10 @@ +# coding: utf-8 +class Encrypt + include Cinch::Plugin + + match /encrypt/ + + def execute(m) + m.reply ["encrypt, non vedo l'ora che arrivi il tempo del nostro prossimo incontro","soccia encrypt quanto sei troll","encrypt, sei malvagio","encrypt, guardare la nebbia","ahahah encrypt esatto","il nostro encrypt","encrypt, è il JSON marxista leninista","encrypt, magari","encrypt...","ciao encrypt","encrypt è impazzito","encrypt, se vuoi puoi parlare con me ","ma sei pazzo encrypt?","questa è per encrypt","encrypt, conosciamo la tua religione","Ciao encrypt","in particolare encrypt che usa la sua capacità per il Male "].sample + end +end diff --git a/plugins/film.rb b/plugins/film.rb new file mode 100644 index 0000000..bf9be8d --- /dev/null +++ b/plugins/film.rb @@ -0,0 +1,19 @@ +class Film + include Cinch::Plugin + + match /film/ + + def execute(m) + loop do + if open("http://www.imdb.com/random/title").read =~ /(.*?) (\(.*?\)) - IMDb<\/title>/ + title = $1.gsub(""","\"").split + if title.count > 1 + #title[title.count - 1] = "Tubia" + title[rand(0...title.count)] = "Tubia" + m.reply title.join(' ') + break + end + end + end + end +end diff --git a/plugins/jops.rb b/plugins/jops.rb new file mode 100644 index 0000000..058948b --- /dev/null +++ b/plugins/jops.rb @@ -0,0 +1,10 @@ +class Jops + include Cinch::Plugin + + match /jops/ + + def execute(m) + cibo = ["tigelle", "crescentine"] + m.reply "jops: andiamo a mangiare le "+cibo.sample+" ?" + end +end diff --git a/plugins/js.rb b/plugins/js.rb new file mode 100644 index 0000000..5fc3b8e --- /dev/null +++ b/plugins/js.rb @@ -0,0 +1,12 @@ +# coding: utf-8 +class JS + include Cinch::Plugin + + match /js/ + + def execute(m) + frameworks = ["Angular", "React", "Ember", "Meteor"] + loves = ["è una figata", "è bellissimo"] + m.reply frameworks.sample+" "+loves.sample + end +end diff --git a/plugins/qup.rb b/plugins/qup.rb new file mode 100644 index 0000000..dde45bd --- /dev/null +++ b/plugins/qup.rb @@ -0,0 +1,9 @@ +class Qup + include Cinch::Plugin + + match /qup/ + + def execute(m) + m.reply "qup, ora ti vengo a menare" + end +end diff --git a/plugins/radio.rb b/plugins/radio.rb new file mode 100644 index 0000000..3718c7d --- /dev/null +++ b/plugins/radio.rb @@ -0,0 +1,46 @@ +class Radio + include Cinch::Plugin + + match /radio play (.*)$/, :method => :on_play + match /radio pialla/, :method => :on_pialla + 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 + end + end + end + + def on_help(m) + m.reply 'curl "http://soyuz.labr.xyz:8080/" | play -q - 2>/dev/null' + end + + def on_pialla(m) + File.open('/tmp/notify-send', 'w') do |f| + f.puts("Sto piallando") + f.flush + end + system("mpc del $(mpc -f %position% | head -n 1)") + end + + def on_info(m) + title = `mpc | head -n 1 | cut -d '#' -f 2 | base64 -d` + title.gsub("\n","") + m.reply CGI.unescapeHTML(title) + end + + def on_next(m) + `mpc next` + end +end diff --git a/plugins/roll.rb b/plugins/roll.rb new file mode 100644 index 0000000..b4cd331 --- /dev/null +++ b/plugins/roll.rb @@ -0,0 +1,9 @@ +class Roll + include Cinch::Plugin + + match /roll/ + + def execute(m) + m.reply rand(1..6) + end +end diff --git a/plugins/salvino.rb b/plugins/salvino.rb new file mode 100644 index 0000000..177337c --- /dev/null +++ b/plugins/salvino.rb @@ -0,0 +1,9 @@ +class Salvino + include Cinch::Plugin + + match /salvino/ + + def execute(m) + m.reply "FORZA SALVINO"+("O"*rand(3...10)) + end +end diff --git a/plugins/thegamer.rb b/plugins/thegamer.rb new file mode 100644 index 0000000..0b692c2 --- /dev/null +++ b/plugins/thegamer.rb @@ -0,0 +1,9 @@ +class Thegamer + include Cinch::Plugin + + match /thegamer/ + + def execute(m) + m.reply ["ahahahahahaha", "sistemistahahahahah", "Al centro della mia vita metto la coerenza"].sample + end +end diff --git a/plugins/toninegri.rb b/plugins/toninegri.rb new file mode 100644 index 0000000..375cb94 --- /dev/null +++ b/plugins/toninegri.rb @@ -0,0 +1,11 @@ +class ToniNegri + include Cinch::Plugin + + match "toninegri" + + def execute(m) + @bot.nick = "toninegri" + m.reply "swasp: sono tuo padre" + @bot.nick = "TubiaBot" + end +end diff --git a/plugins/tpo.rb b/plugins/tpo.rb new file mode 100644 index 0000000..ecb8c0c --- /dev/null +++ b/plugins/tpo.rb @@ -0,0 +1,10 @@ +# coding: utf-8 +class Tpo + include Cinch::Plugin + + match /(P|p)olitic(a|he|i)/ + + def execute(m) + m.reply ["ahahahahahaha", "Swasps democrazia! 'Con 1589 votanti si sono concluse le primarie di CoalizioneCivica'","Swasps hashtag per tutti: LaCittàDelBuonVivere #CoalizioneCivica #Bologna LoSportDiCittadinanza tra #benessere e #integrazione", "VIGILI URBANI: UN BUON SINDACO NON DISPREZZA I PROPRI LAVORATORI - Il Sindaco di Bologna... http://fb.me/1XmvjJ2nc" ].sample + end +end diff --git a/plugins/vergogna.rb b/plugins/vergogna.rb new file mode 100644 index 0000000..fe528ab --- /dev/null +++ b/plugins/vergogna.rb @@ -0,0 +1,9 @@ +class Vergogna + include Cinch::Plugin + + match /vergogna/ + + def execute(m) + m.reply "vergogna vergogna settimo reparto" + end +end diff --git a/tubiabot.rb b/tubiabot.rb index cc6a6ff..c164494 100644 --- a/tubiabot.rb +++ b/tubiabot.rb @@ -2,135 +2,16 @@ require 'cinch' require 'marky_markov' require 'open-uri' +require 'cgi' -class ToniNegri - include Cinch::Plugin +plugins = [ :Caffe, :ToniNegri, :Amici, :JS, :Salvino, :Jops, :Qup, :Vergogna, :Film, :Thegamer, :Roll, :Encrypt, :Tpo, :Radio] - match "toninegri" - - def execute(m) - @bot.nick = "toninegri" - m.reply "swasp: sono tuo padre" - @bot.nick = "TubiaBot" - end +plugins.each do |plugin| + require './plugins/'+plugin.downcase.to_s end -class Caffe - include Cinch::Plugin - match /caff(è|e)/ - def execute(m) - users = [ "qup", "imega", "gresci" ] - requests = [ "andiamo al bar?", "caffè?", "bar?" ] - m.reply users.sample+": "+requests.sample - end -end - -class Amici - include Cinch::Plugin - - match /lavor(o|are|atori)/ - - def execute(m) - users = [ "qup", "imega", "gresci", "jigen", "lgine", "encrypt", "thegamer" ] - requests = [ "oggi non ho voglia di fare un cazzo", "caffè?", "andiamo al bar?" ] - m.reply users.sample+" "+users.sample+" "+requests.sample - end -end - -class JS - include Cinch::Plugin - - match /js/ - - def execute(m) - frameworks = ["Angular", "React", "Ember", "Meteor"] - loves = ["è una figata", "è bellissimo"] - m.reply frameworks.sample+" "+loves.sample - end -end - -class Salvino - include Cinch::Plugin - - match /salvino/ - - def execute(m) - m.reply "FORZA SALVINO"+("O"*rand(3...10)) - end -end - -class Jops - include Cinch::Plugin - - match /jops/ - - def execute(m) - cibo = ["tigelle", "crescentine"] - m.reply "jops: andiamo a mangiare le "+cibo.sample+" ?" - end -end - -class Qup - include Cinch::Plugin - - match /qup/ - - def execute(m) - m.reply "qup, ora ti vengo a menare" - end -end - -class Vergogna - include Cinch::Plugin - - match /vergogna/ - - def execute(m) - m.reply "vergogna vergogna settimo reparto" - end -end - -class Film - include Cinch::Plugin - - match /film/ - - def execute(m) - loop do - if open("http://www.imdb.com/random/title").read =~ /<title>(.*?) (\(.*?\)) - IMDb<\/title>/ - title = $1.gsub(""","\"").split - if title.count > 1 - #title[title.count - 1] = "Tubia" - title[rand(0...title.count)] = "Tubia" - m.reply title.join(' ') - break - end - end - end - end -end - -class Thegamer - include Cinch::Plugin - - match /thegamer/ - - def execute(m) - m.reply ["ahahahahahaha", "sistemistahahahahah"].sample - end -end - -class Roll - include Cinch::Plugin - - match /roll/ - - def execute(m) - m.reply rand(1..6) - end -end logger = File.open("./logs.txt", 'a+') markov = MarkyMarkov::TemporaryDictionary.new @@ -141,7 +22,7 @@ bot = Cinch::Bot.new do c.server = "irc.mufhd0.net" c.nick = "TubiaBot" c.channels = ["#indivia"] - c.plugins.plugins = [Caffe, ToniNegri, Amici, JS, Salvino, Jops, Qup, Vergogna, Film, Thegamer, Roll] + c.plugins.plugins = plugins.map { |p| eval(p.to_s) } end end @@ -152,6 +33,9 @@ bot.on :message do |m| if m.message.include?(@bot.nick) m.reply markov.generate_n_sentences 1 end + if m.message.include?("jops") + m.reply "jops: aggiorna lattuga" + end if m.message.include?("encrypt") File.open('/tmp/lucine', 'w') do |f| f.puts('blink 3 0.3')