translator: connect to sites only when necessary
authorYaohan Chen <yaohan.chen@gmail.com>
Fri, 21 May 2010 19:59:29 +0000 (15:59 -0400)
committerYaohan Chen <yaohan.chen@gmail.com>
Fri, 21 May 2010 20:10:31 +0000 (16:10 -0400)
commit027b6965f5abf5d05a95d4dc627f19a71b7a7076
tree2fa7911bba8b32e82c3bc39b970bd2b4d9617cfd
parent43fe51c5e5bfc40a6db95f3d4ee93958ed1081a2
translator: connect to sites only when necessary

Previously the translation services in the plugin would connect to their
respective websites on initialize. Now they will only do this when the first
time they are used. WorldLingo still connects on initialialize in order to list
the supported language pairs, but the Mechanize object is not saved here, so
the connection should be closed after initialize, and only reopened if
translation by WorldLingo is requested later.

Previously the services are assumed to fail if they raise any Exception in
initialize, and in that case the service is disabled, and its command as well
as the help translate [failed] commands state this. Now this exception catch is
done for any do_translate method call.
data/rbot/plugins/translator.rb