Compare commits

...

16 commits

Author SHA1 Message Date
1fd9d29fc8 cambio locazione 2017-02-17 09:54:47 +00:00
1181a8640f porcodio la fretta 2017-02-16 16:42:05 +00:00
fa7dcaa753 commito roba non committata 2017-02-16 16:37:22 +00:00
accfff8654 così mi faccio odiare da autistici 2017-02-16 16:35:05 +00:00
accb3c9008 add bookmarks 2016-05-10 13:52:12 +00:00
612e3e22ed add vcn 2016-05-10 13:52:01 +00:00
c82979c749 changes 2016-05-10 13:44:33 +00:00
2e6ef10555 add help 2016-05-10 13:44:11 +00:00
00c666c628 restyle 2016-03-08 18:10:59 +01:00
32c1f74602 add thegamer film roll 2016-02-26 11:31:45 +01:00
154c6dfddc add markov 2016-02-18 15:47:52 +01:00
bff2d6aaa5 plugins! 2016-02-18 15:46:48 +01:00
7fcb4086fa al contadin non far sapere quanto è buono il cacio con le pere 2016-01-23 12:36:25 +01:00
a9bb734759 add SALVINOOOOOOOOOOOOOOOOOOOOOOO 2016-01-22 12:56:21 +01:00
8adbf86efb add js plugin 2016-01-22 10:02:55 +01:00
4e8adf41f5 amici 2016-01-21 10:44:40 +01:00
18 changed files with 296 additions and 24 deletions

View file

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

12
plugins/amici.rb Normal file
View file

@ -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

45
plugins/bookmarks.rb Normal file
View file

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

12
plugins/caffe.rb Normal file
View file

@ -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

10
plugins/encrypt.rb Normal file
View file

@ -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

19
plugins/film.rb Normal file
View file

@ -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 =~ /<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

10
plugins/jops.rb Normal file
View file

@ -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

12
plugins/js.rb Normal file
View file

@ -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

9
plugins/qup.rb Normal file
View file

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

61
plugins/radio.rb Normal file
View file

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

9
plugins/roll.rb Normal file
View file

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

9
plugins/salvino.rb Normal file
View file

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

9
plugins/thegamer.rb Normal file
View file

@ -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

11
plugins/toninegri.rb Normal file
View file

@ -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

10
plugins/tpo.rb Normal file
View file

@ -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

24
plugins/vcn.rb Normal file
View file

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

9
plugins/vergogna.rb Normal file
View file

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

View file

@ -1,37 +1,38 @@
# coding: utf-8
require 'cinch'
require 'marky_markov'
require 'open-uri'
class ToniNegri
include Cinch::Plugin
plugins = [ :Caffe, :ToniNegri, :Amici, :JS, :Salvino, :Jops, :Qup, :Vergogna, :Film, :Thegamer, :Roll, :Encrypt, :Tpo, :Radio, :VCN, :Bookmarks]
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
plugins.each do |plugin|
require './plugins/'+plugin.downcase.to_s
end
logger = File.open("./logs.txt", 'a+')
markov = MarkyMarkov::TemporaryDictionary.new
markov.parse_file './logs.txt'
bot = Cinch::Bot.new do
configure do |c|
c.server = "irc.mufhd0.net"
c.server = "irc.autistici.org"
c.port = 9999
c.ssl.use = true
c.nick = "TubiaBot"
c.channels = ["#indivia"]
c.plugins.plugins = [Caffe, ToniNegri]
c.plugins.plugins = plugins.map { |p| eval(p.to_s) }
end
end
bot.on :message do |m|
nicks = [ "Tubia87", "pippo" ]
if nicks.include? m.user.nick
#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+"\"")
end
end