Class: ActiveMatrix::Generators::BotGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Defined in:
lib/generators/active_matrix/bot/bot_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_bot_fileObject



14
15
16
# File 'lib/generators/active_matrix/bot/bot_generator.rb', line 14

def create_bot_file
  template 'bot.rb.erb', "app/bots/#{file_name}_bot.rb"
end

#create_bot_specObject



18
19
20
# File 'lib/generators/active_matrix/bot/bot_generator.rb', line 18

def create_bot_spec
  template 'bot_spec.rb.erb', "spec/bots/#{file_name}_bot_spec.rb"
end

#display_usageObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/generators/active_matrix/bot/bot_generator.rb', line 22

def display_usage
  say "\nBot created! To use your bot:\n\n"
  say '1. Create an agent in Rails console:'
  say '   agent = MatrixAgent.create!('
  say "     name: '#{file_name}',"
  say "     homeserver: 'https://matrix.org',"
  say "     username: 'your_bot_username',"
  say "     password: 'your_bot_password',"
  say "     bot_class: '#{class_name}Bot'"
  say '   )'
  say "\n2. Start the agent:"
  say '   ActiveMatrix::AgentManager.instance.start_agent(agent)'
  say "\n"
end