Compare commits

..

3 commits

Author SHA1 Message Date
28cec47545 ok politica 2016-03-01 16:57:34 +01:00
16fb535772 aggiunto politica 2016-03-01 15:45:12 +01:00
282c012774 amici 2016-01-21 10:18:47 +01:00
18 changed files with 160 additions and 285 deletions

View file

@ -7,6 +7,6 @@ Usage
-----
```
gem install cinch marky_markov
gem install cinch
ruby tubiabot.rb
```

View file

@ -1,12 +0,0 @@
# 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

View file

@ -1,45 +0,0 @@
require 'net/https'
require 'cgi'
require 'uri'
class Bookmarks
include Cinch::Plugin
match /b help$/, :method => :on_help
match /b (.*)$/
def execute(m, link)
unless link =~ URI.regexp
return
end
title = link
if open(link).read =~ /<title>(.*?)<\/title>/
title = CGI.unescapeHTML($1)
end
base_uri = "https://link.autistici.org/"
uri = URI.parse(base_uri)
client = Net::HTTP.new(uri.host, uri.port)
client.use_ssl = uri.scheme == 'https'
login_request = Net::HTTP::Post.new(uri.request_uri+"/login.php")
login_request.set_form_data({"username" => ENV["LINK_USER"], "password" => ENV["LINK_PASS"], "keeppass" => "yes", "query" => "", "submitted" => "Log+in"})
cookie = client.request(login_request).response['set-cookie'].split('; ')[0]
bookmark_request = Net::HTTP::Post.new(uri.request_uri+"/bookmarks.php/tubiabot", {
'Cookie' => cookie
})
bookmark_request.set_form_data({"title" => title,
"address" => link,
"status" => "0",
"tags" => "",
"description" => "",
"submitted" => "Add+Bookmark"})
client.request(bookmark_request)
if title != link
m.reply "Bookmark add \""+title+"\""
end
end
def on_help(m)
m.reply "usage: !b https://www.youtube.com/watch?v=dQw4w9WgXcQ"
m.reply "i link stanno su https://link.autistici.org/bookmarks.php/tubiabot"
end
end

View file

@ -1,12 +0,0 @@
# 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

View file

@ -1,10 +0,0 @@
# 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

View file

@ -1,19 +0,0 @@
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("&quot;","\"").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

View file

@ -1,10 +0,0 @@
class Jops
include Cinch::Plugin
match /jops/
def execute(m)
cibo = ["tigelle", "crescentine"]
m.reply "jops: andiamo a mangiare le "+cibo.sample+" ?"
end
end

View file

@ -1,12 +0,0 @@
# 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

View file

@ -1,9 +0,0 @@
class Qup
include Cinch::Plugin
match /qup/
def execute(m)
m.reply "qup, ora ti vengo a menare"
end
end

View file

@ -1,61 +0,0 @@
require 'cgi'
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
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://utvghefxggihh5ts.onion/listen" | play -q - 2>/dev/null'
m.reply 'http://soyuz.labr.xyz:8000 - qua sta l\'interfaccia webbosa - poi ritorna'
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)
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)
info = `mpc`.split("\n")
return if info.empty? || info.count <3
title = Base64.decode64(info[0].split('#').last).chomp
songs,time = "0"
if info[1] =~ /.* #[0-9]+\/([0-9]+)\s(.*)/
songs = $1
time = $2.strip
end
m.reply CGI.unescapeHTML(title)+" ["+time+"] "+songs+" songs in playlist"
end
def on_next(m)
`mpc next`
end
end

View file

@ -1,9 +0,0 @@
class Roll
include Cinch::Plugin
match /roll/
def execute(m)
m.reply rand(1..6)
end
end

View file

@ -1,9 +0,0 @@
class Salvino
include Cinch::Plugin
match /salvino/
def execute(m)
m.reply "FORZA SALVINO"+("O"*rand(3...10))
end
end

View file

@ -1,9 +0,0 @@
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

View file

@ -1,11 +0,0 @@
class ToniNegri
include Cinch::Plugin
match "toninegri"
def execute(m)
@bot.nick = "toninegri"
m.reply "swasp: sono tuo padre"
@bot.nick = "TubiaBot"
end
end

View file

@ -1,10 +0,0 @@
# 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

View file

@ -1,24 +0,0 @@
require 'net/https'
require 'uri'
class VCN
include Cinch::Plugin
match "vcn"
def execute(m)
base_uri = "https://webmail.ventuordici.org/toolz/token"
uri = URI.parse(base_uri+"/generate")
Net::HTTP.start(uri.host, uri.port,
:use_ssl => uri.scheme == 'https',
:verify_mode => OpenSSL::SSL::VERIFY_NONE) do |https|
request = Net::HTTP::Post.new(uri.request_uri)
request.set_form_data({"email" => ENV["ORTICHE_MAIL"], "password" => ENV["ORTICHE_PASS"], "type" => "vcn"})
response = https.request(request)
if response.body =~ /<span id='token'>(.*?)<\/span>/
m.reply base_uri+"/check/"+$1
end
end
end
end

View file

@ -1,9 +0,0 @@
class Vergogna
include Cinch::Plugin
match /vergogna/
def execute(m)
m.reply "vergogna vergogna settimo reparto"
end
end

View file

@ -3,10 +3,155 @@ require 'cinch'
require 'marky_markov'
require 'open-uri'
plugins = [ :Caffe, :ToniNegri, :Amici, :JS, :Salvino, :Jops, :Qup, :Vergogna, :Film, :Thegamer, :Roll, :Encrypt, :Tpo, :Radio, :VCN, :Bookmarks]
class ToniNegri
include Cinch::Plugin
plugins.each do |plugin|
require './plugins/'+plugin.downcase.to_s
match "toninegri"
def execute(m)
@bot.nick = "toninegri"
m.reply "swasp: sono tuo padre"
@bot.nick = "TubiaBot"
end
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("&quot;","\"").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 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
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
class Roll
include Cinch::Plugin
match /roll/
def execute(m)
m.reply rand(1..6)
end
end
logger = File.open("./logs.txt", 'a+')
@ -15,24 +160,25 @@ markov.parse_file './logs.txt'
bot = Cinch::Bot.new do
configure do |c|
c.server = "irc.autistici.org"
c.port = 9999
c.ssl.use = true
c.server = "irc.mufhd0.net"
c.nick = "TubiaBot"
c.channels = ["#indivia"]
c.plugins.plugins = plugins.map { |p| eval(p.to_s) }
c.plugins.plugins = [Caffe, ToniNegri, Amici, JS, Salvino, Jops, Qup, Vergogna, Film, Thegamer, Roll, Tpo, Encrypt]
end
end
bot.on :message do |m|
nicks = [ "Tubia87", "pippo" ]
if nicks.include? m.user.nick
#logger.write(m.message+"\n")
if m.user.nick == "Tubia87"
logger.write(m.message+"\n")
end
if m.message.include?(@bot.nick)
rp = markov.generate_n_sentences 1
m.reply rp
#system("espeak -v italian \""+rp+"\"")
m.reply markov.generate_n_sentences 1
end
if m.message.include?("encrypt")
File.open('/tmp/lucine', 'w') do |f|
f.puts('blink 3 0.3')
f.flush
end
end
end