TubiaBot/tubiabot.rb

40 lines
934 B
Ruby
Raw Permalink Normal View History

2016-01-20 16:23:41 +01:00
# coding: utf-8
require 'cinch'
require 'marky_markov'
2016-02-26 11:31:45 +01:00
require 'open-uri'
2016-01-20 16:23:41 +01:00
2016-05-10 15:44:33 +02:00
plugins = [ :Caffe, :ToniNegri, :Amici, :JS, :Salvino, :Jops, :Qup, :Vergogna, :Film, :Thegamer, :Roll, :Encrypt, :Tpo, :Radio, :VCN, :Bookmarks]
2016-01-20 16:23:41 +01:00
2016-03-08 18:10:59 +01:00
plugins.each do |plugin|
require './plugins/'+plugin.downcase.to_s
2016-01-22 10:02:55 +01:00
end
2016-01-20 16:23:41 +01:00
logger = File.open("./logs.txt", 'a+')
markov = MarkyMarkov::TemporaryDictionary.new
markov.parse_file './logs.txt'
2016-01-20 16:23:41 +01:00
bot = Cinch::Bot.new do
configure do |c|
2017-02-16 17:35:05 +01:00
c.server = "irc.autistici.org"
2017-02-16 17:42:05 +01:00
c.port = 9999
2017-02-16 17:35:05 +01:00
c.ssl.use = true
2016-01-20 16:23:41 +01:00
c.nick = "TubiaBot"
c.channels = ["#indivia"]
2016-03-08 18:10:59 +01:00
c.plugins.plugins = plugins.map { |p| eval(p.to_s) }
2016-01-22 12:56:21 +01:00
end
end
bot.on :message do |m|
2016-05-10 15:44:33 +02:00
nicks = [ "Tubia87", "pippo" ]
if nicks.include? m.user.nick
#logger.write(m.message+"\n")
2016-01-20 16:23:41 +01:00
end
2016-02-18 15:46:48 +01:00
if m.message.include?(@bot.nick)
2017-02-16 17:35:05 +01:00
rp = markov.generate_n_sentences 1
m.reply rp
#system("espeak -v italian \""+rp+"\"")
end
2016-01-20 16:23:41 +01:00
end
bot.start