class SkypeMarkov::Bot

Attributes

chat[RW]
dictionary[RW]
user[RW]

Public Class Methods

new(user, chat = nil, dict = nil) click to toggle source
# File lib/skype_markov.rb, line 26
def initialize(user, chat = nil, dict = nil)
  @user = user
  @chat = chat
  @dictionary = dict
  @chat = SkypeMarkov.chat if chat.nil?
  generate_dictionary if dict.nil? && !File.exist?('#{SkypeMarkov.config[:user_path]}#{@user}.mmd')
end

Public Instance Methods

generate_dictionary() click to toggle source
# File lib/skype_markov.rb, line 34
def generate_dictionary
  @dictionary = MarkyMarkov::Dictionary.new(SkypeMarkov.config[:user_path] + @user)
  @chat.messages.select { |m| m.user == @user }.each do |m|
    @dictionary.parse_string(m.body)
  end
  @dictionary.save_dictionary!
end
post(num_sentences) click to toggle source
# File lib/skype_markov.rb, line 42
def post(num_sentences)
  @chat.post(@dictionary.generate_n_sentences(num_sentences))
end