Yaohan Chen [Fri, 21 May 2010 19:59:29 +0000 (15:59 -0400)]
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.
Giuseppe Bilotta [Wed, 12 May 2010 10:57:40 +0000 (12:57 +0200)]
Survive active_support idiocy
Somebody should hang the ActiveSupport developers by their balls
with barbed wire. Their MissingSourceFile extension to LoadError
_expects_ a second argument, breaking the usual Exception interface
(instead, the smart thing to do would have been to make the second
parameter optional and run the code in the from_message method if
it was missing).
translator: additional help for google translate auto-detect failure
When translate command is used without source language, "auto" as source
language is assumed. It means that google translator is used and we let
google figure out what the source language is.
Problem is that the google translator will fail if the system that the
bot is running on does not have the json gem installed. This commit
addresses that problem by showing more informative error message instead
of a weird "none of the translators supports auto to en translation".
Giuseppe Bilotta [Tue, 16 Mar 2010 14:16:20 +0000 (15:16 +0100)]
seen: use corret 'where' in 'before' case
For the 'before' part of the reply, make sure we use the where
from the correct Saw. Otherwise, for example, a public message
preceeding a quit would show a dangling 'in ' at the end of the reply.
The new Freenode ircd returns multiple RPL_WHOISCHANNELS lines (split
based on length), and they must be merged, otherwise only the last ends
up as the list of channels that the bot is in.
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
Giuseppe Bilotta [Mon, 25 Jan 2010 22:11:43 +0000 (23:11 +0100)]
markov: unify should_talk
Unify probability check for addressed and non-addressed case by
passing the message as a parameter to should_talk and picking the
probability accordingly.
Yaohan Chen [Mon, 30 Nov 2009 19:19:55 +0000 (14:19 -0500)]
Simplify support for using "auto" to detect source language
When "auto" is used as source language, Google Translate detects the
source language. However there is no need to hardcode Google Translate
as the only translator supporting "auto". If another translator supports
language detection, we can add "auto" to its supported source languages.
If no translator in default_list supports translating from "auto", the
existing code already responds with a message saying so.
Giuseppe Bilotta [Tue, 20 Oct 2009 18:22:22 +0000 (20:22 +0200)]
Loop until connected in reconnect()
Untrapped connect() failures would raise up to the mainloop, causing a
burst of reconnect attempts without delay. Fix by rescuing in
reconnect() and retrying after waiting.
Not only the patch was missing an essential part, but Nokogiri is not
compatible enough with Hpricot anyway. Incompatibilities include
doc/"style|script" raising an "Undefined namespace prefix" error and the
non-existence of Hpricot::Elements.
If we want to support Nokogiri we'll need to write code for it on
purpose or redesign the Hpricot code so that it only uses the subset
supported by Nokogiri.
Giuseppe Bilotta [Fri, 28 Aug 2009 22:56:22 +0000 (00:56 +0200)]
search plugin: enhance 'lucky' output
'lucky' search only selects the first hit, so set hit to 1 and
enable 'single' mode. Also rework the results output, and make a custom
'title -- url' for lucky mode.
Giuseppe Bilotta [Thu, 27 Aug 2009 19:35:06 +0000 (21:35 +0200)]
url plugin: only chop non-word characters on 404
Chopping everything causes long delays for non-existing pages with
long paths. Since the purpose of the retry-with-chop is to get the
right URL when punctuation is added after it, the solution is to
only chop non-word characters. This has to be done on the
unescaped URL because otherwise non-word characters like " that
expand to %22 will not be chopped.