Browse Source

al contadin non far sapere quanto è buono il cacio con le pere

encrypt 8 years ago
parent
commit
7fcb4086fa
1 changed files with 8 additions and 2 deletions
  1. 8 2
      tubiabot.rb

+ 8 - 2
tubiabot.rb

@@ -1,5 +1,6 @@
 # coding: utf-8
 require 'cinch'
+require 'marky_markov'
 
 class ToniNegri
   include Cinch::Plugin
@@ -59,6 +60,10 @@ class Salvino
   end
 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"
@@ -68,12 +73,13 @@ bot = Cinch::Bot.new do
   end
 end
 
-logger = File.open("./logs.txt", 'a+')
-
 bot.on :message do |m|
   if m.user.nick == "Tubia87"
     logger.write(m.message+"\n")
   end
+  if m.message.include?(@bot.nick) and !@bot.user_list.include?("Tubia87")
+    m.reply markov.generate_n_sentences 1
+  end
 end
 
 bot.start