diff --git a/lib/actions/add_friend.rb b/lib/actions/add_friend.rb index e68e94c..747eda6 100644 --- a/lib/actions/add_friend.rb +++ b/lib/actions/add_friend.rb @@ -2,11 +2,12 @@ module Actions class AddFriend < Obredux::Thunk::Action - attr_reader :tox_client, :public_key + attr_reader :tox_client, :public_key, :text - def initialize(tox_client, public_key) + def initialize(tox_client, public_key, text) self.tox_client = tox_client self.public_key = public_key + self.text = text end def call(dispatch) @@ -25,6 +26,11 @@ module Actions @public_key = value end + def text=(value) + raise TypeError, "expected #text to be a #{String}" unless value.is_a? String + @text = value + end + class Done < Obredux::Action attr_reader :friend diff --git a/lib/main.rb b/lib/main.rb index 9ebf128..1b325b9 100644 --- a/lib/main.rb +++ b/lib/main.rb @@ -87,8 +87,8 @@ private store.dispatch Actions::LoadFriends.new friends end - def on_friend_request(public_key, _text) - store.dispatch Actions::AddFriend.new @tox_client, public_key + def on_friend_request(public_key, text) + store.dispatch Actions::AddFriend.new @tox_client, public_key, text end def on_friend_message(friend, text)