From 690e9e815666ec6d20afdc67a906eda0fa789a65 Mon Sep 17 00:00:00 2001 From: Andrew Walbran Date: Tue, 26 Aug 2008 20:55:38 +1200 Subject: [PATCH] Support for requesting contact handles (users) by name --- twitterpathy.rb | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/twitterpathy.rb b/twitterpathy.rb index 1741a93..3f43054 100755 --- a/twitterpathy.rb +++ b/twitterpathy.rb @@ -154,8 +154,30 @@ class TwitterConnection < DBus::Object end dbus_method :RequestHandles, 'in handle_type:u, in names:as, out handles:au' do |handle_type, names| - # TODO - handles = [] + if handle_type == HANDLE_TYPE_CONTACT + handles = names.map {|name| + # TODO: make this more efficient? + contact_handle = nil + @handles[HANDLE_TYPE_CONTACT].each do |handle, contact| + if contact.name == name + contact_handle = handle + break + end + end + + if contact_handle.nil? + contact = @twitter_client.user(name) # TODO: handle errors + @handles[HANDLE_TYPE_CONTACT][contact.id] = contact + contact_handle = contact.id + end + + contact_handle + } + else + # TODO: other types + handles = [] + end + [handles] end -- 2.11.4.GIT