Skip to content

Commit

Permalink
Misc fixes as wiring proceeds.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bantik committed Jul 27, 2014
1 parent a1a18fd commit a9a7eeb
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 18 deletions.
1 change: 1 addition & 0 deletions .pryrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Pry.config.editor = 'vim'
4 changes: 3 additions & 1 deletion alice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
Mongoid.load!("config/mongoid.yml")

require_all 'alice'

module Alice

def self.start
Expand All @@ -29,3 +28,6 @@ def self.bot
config.app_id = ENV['YUMMLY_APP_ID']
config.app_key = ENV['YUMMLY_APP_KEY']
end

I18n.enforce_available_locales = false

2 changes: 1 addition & 1 deletion alice/behavior/has_inventory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module HasInventory

def inventory
message = inventory_of_items
message << " " + inventory_of_beverages + "."
message << " " + inventory_of_beverages.to_s + "."
message ||= "has no possessions."
message
end
Expand Down
23 changes: 18 additions & 5 deletions alice/handlers/dungeon.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'pry'

module Handlers

class Dungeon
Expand All @@ -19,11 +21,22 @@ def move
end

def look
if Place.current.has_exit?(direction)
room = Place.current.neighbors.select{|r| r[:direction] == direction}.first[:room]
response = room.view
response = ""
if direction
if Place.current.has_exit?(direction)
room = Place.current.neighbors.select{|r| r[:direction] == direction}.first[:room]
response = room.view
else direction
response = "A lovely wall you've found there."
end
elsif command_string.subject.length > 0 && subject = command_string.subject
if obj = (User.from(subject) || Item.from(subject) || Beverage.from(subject) || Machine.from(subject))
response = obj.describe
else
response = "I don't see that here."
end
else
response = "A lovely wall you've found there."
response = Place.current.describe
end
message.set_response(response)
end
Expand All @@ -46,7 +59,7 @@ def gazebo
private

def direction
@direction ||= ::Dungeon.direction_from(message.trigger)
@direction ||= ::Dungeon.direction_from(command_string.subject)
end

def reset_maze
Expand Down
8 changes: 4 additions & 4 deletions alice/processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ def react
end

def respond
Alice::Util::Mediator.send_raw(Response.from(self.message).response)
track_sender
Alice::Util::Mediator.reply_with(Response.from(self.message).response)
end

def greet_on_join
track_sender
Response.greeting(message)
Alice::Util::Mediator.emote(Response.greeting(self.message).response)
end

def track_nick_change
track_sender
user = User.find_or_create(message.sender_nick)
user.update_nick(message.sender_nick)
Response.name_change(message)
Alice::Util::Mediator.emote(Response.name_change(self.message))
end

private
Expand Down
13 changes: 6 additions & 7 deletions alice/util/mediator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def self.default_user
end

def self.user_nicks
channel.user_list.map(&:nick).map(&:downcase)
user_list.map(&:nick).map(&:downcase)
end

def self.op_nicks
Expand All @@ -52,20 +52,19 @@ def self.send_raw(message)
end

def self.user_from(channel_user)
User.with_nick_like(channel_user.user.nick)
User.from(channel_user)
end

def self.reply_to(channel_user, message)
def self.reply_with(message)
text = Alice::Util::Sanitizer.process(message)
text = Alice::Util::Sanitizer.initial_upcase(text)
text = user_from(channel_user).apply_filters(text)
channel_user.reply(text)
Alice.bot.bot.channels.first.msg(text)
end

def self.emote_to(channel_user, message)
def self.emote(message)
text = Alice::Util::Sanitizer.process(message)
text = Alice::Util::Sanitizer.initial_downcase(text)
channel_user.action_reply(text)
Alice.bot.bot.channels.first.action(text)
end

end
Expand Down

0 comments on commit a9a7eeb

Please sign in to comment.