Since version 4.1.0, HTMLEntities removed the decode_entities()
class method and uses a decoder since. Support the new interface as well
as the old one.
Also slightly optimize by moving the conditional outside of the method
definition. Now a rescan is required even if HTMLEntities is loaded at
runtime, but the method should be slightly faster.
Giuseppe Bilotta [Wed, 16 Mar 2011 19:26:14 +0000 (20:26 +0100)]
Add – to known HTML characters
This was affecting the imdb plugin when htmlentities was not available,
because TV series were split at en dashes, which were being converted to
asterisks when our built-in UNESCAPE_TABLE was being used.
Rather than complaining about a missing use_ssl= method, if net/https
fails to load we define a mock use_ssl= method that raises a runtime
error making the LoadError message public. This is not the most
user-friendly message (we would prefer not to expose internals), but
it should be clear enough to help owners that forget to read the log
find what's missing.
Giuseppe Bilotta [Wed, 26 Jan 2011 17:36:55 +0000 (18:36 +0100)]
TokyoCabinet pseudo-environment
Since TokyoCabinet does not provide a DB environment, trying to reopen
the same db multiple times (something that happens with subregistry
mostly, and possibly after rescans) causes the subsequent opens to fail
due to "threading errors".
Fix by implementing some sort of environmentalish database management
(only keeps track of open databases, returns existing ones if reopening
the same db multiple times, closes all of them on exit).
Giuseppe Bilotta [Wed, 12 Jan 2011 20:06:27 +0000 (21:06 +0100)]
Load the 1.9 compatibility code earlier
The compat19 code touches the monitor mixins which are used by the
logger which is started as soon as ircbot.rb is loaded. To make sure the
logger uses the compat code we must load compat19 before ircbot.
Giuseppe Bilotta [Tue, 11 Jan 2011 10:35:59 +0000 (11:35 +0100)]
rss: updated can be nil
An Atom item can reply to updated even though its value is nil, so
check for it actually being valued instead. Also, some malformed Atom
feeds use the nonstandard 'modified' element instead, so check for that
too.
Giuseppe Bilotta [Fri, 31 Dec 2010 09:20:55 +0000 (10:20 +0100)]
fake message: set replied on reply
Although the reply method for fake messages was actually relying on the
original, we still need to set 'replied' to prevent the fake message
from being wrongly delegated to 'unreplied'.
The most obvious bug this commit fixes is the potentially infinite loop
triggered by defining a command reaction triggered by the command name
itself (e.g. reply to ping with cmd:ping).
Giuseppe Bilotta [Sat, 11 Dec 2010 13:42:17 +0000 (14:42 +0100)]
time plugin: check if argument is a nick earlier
When !time <somenick> was being used and the user <somenick> hadn't set
his or her location, the bot would wrongly assume the argument was some
timezone.
Giuseppe Bilotta [Fri, 10 Dec 2010 20:46:40 +0000 (21:46 +0100)]
geoip: blogama is dead, long live ipinfodb
Sadly, the new ipinfodb API requires an API key, and I don't know yet if
I'm allowed to redistributed it (I'm betting on no, but in case I can
it will added with an appropriate patch).
If someone joins after a challengeable W+4, he would be inserted between
the last and first player, and if there is a challenge _his_ cards would
be exposed. So prevent joining in such a situation.
After a successful challenge, the challenged player can choose to
pick&pass instead of playing one of its allowed cards. In such a case,
the must_play array would not get reset, preventing the next player to
be able to play any of its card.
Fix by resetting must_play on next_turn rather than on set_discard.
Since commit a993d1c358e24ab85621568c10411c5496e2dea8, the message
mappers have a more rational way of reporting failures, but the auth
module was not using it, resulting in the wrong permissions being
granted/revoked whenever allow/deny was being used.
Default mIRC colors are 0-15, and some clients don't react too well to a
color > 15, while most wrap or default. Konversation, for example, will
stop the color command parsing and interpret it as color 1, followed by
the literal digit 6.
So use the 'official' (mIRC) value of 0 for white.
Giuseppe Bilotta [Thu, 25 Nov 2010 16:53:57 +0000 (17:53 +0100)]
rss: watch handle case during rename
We allow rss handles to be of any case on creation, even though matching
is case-insentivie. However, when renaming an rss using 'rss change
handle' and only changing the case, two things prevented this from
working correctly:
* since the new downcased handle was equal to the old downcased handle,
the bot would prevent the renaming due to the existence of the new
handle
* the new handle was forcefully downcased, preventing the user
from renaming handle 'case' to 'CaSe'.
Fix by checking for this case explicitly, and handling it separately.
Giuseppe Bilotta [Thu, 25 Nov 2010 12:49:15 +0000 (13:49 +0100)]
remind: fix presence of 'in', 'every' or 'at' in message
if 'in' was present in the message but not part of the time
specification (e.g. because the specification was with 'every' or with
'at'), the parser would fail at the first attempt (look for time after
'in') and fail unnecessarily.
Fix by trying all possibilities and only giving an error if none
succeeds.
Giuseppe Bilotta [Thu, 18 Nov 2010 15:08:19 +0000 (16:08 +0100)]
rss plugin: don't fail when feed.last_success is nil
The first_run check comparing the time delta from last success failed
when feed.last_success was nil. Prevent this from happening by checking
if we are on the first run before the rest of the checks.
Commit a306b2c68eb58c1c88057ff7ee78895401adb6a9 introduced a fix to
prevent a player from playing something like g9r9, but the fix actually
prevented any single-card play. Fix by making the \1 optional.
Giuseppe Bilotta [Mon, 18 Oct 2010 22:39:13 +0000 (00:39 +0200)]
uno plugin: don't allow g9r9 card specification
The regexp should make sure that the second card is equal to the first
specified card, instead of matching the card expression one or two
times. Otherwise, a play like 'pl g9r9' would be accepted when the
player had two r9 cards and could play them.
This is only a aesthetical change because the plays would still be
valid, albeit (1) surprising and (2) mismatching what the user actually
wrote.
Giuseppe Bilotta [Thu, 14 Oct 2010 08:35:26 +0000 (10:35 +0200)]
safe_exec fixes
Some plugins (ri, fortune) wrap safe_exec in begin/rescue blocks that
did not get triggered because the exceptions from the execution were
caught in the popen block (and would never get exposed anyway). Fix this
by raising if $? does not indicate success.
Giuseppe Bilotta [Thu, 14 Oct 2010 08:15:47 +0000 (10:15 +0200)]
dictclient: monkeypatch DICTError
The Ruby/DICT library is so tightly coupled with the rdict client that
its errors exit on initialize, instead of letting the lib user do that.
This makes those errors untrappable from the code.
Fix by monkeypatching DICTError to just act like the other exceptions in
Ruby.
Convert the (optional) first argument to #each*() methods to a string to
ensure the calls work as expected. This fixes a problem with
@registry.each not working as expected, and although it would have been
sufficient to convert the default for the first argument from nil to the
empty string, the approach implemented by this patch is more robust
overall.
Giuseppe Bilotta [Thu, 30 Sep 2010 10:08:34 +0000 (12:08 +0200)]
Revert "markov: removed unnecessary mutexes"
This reverts commit 06485aeb187dde5e81204b06c8e956e7e035c323. The mutex
is necessary because of the concurrent learning and database conversion.
Some other approach should be used instead (e.g. skipping the mutex if
not running a conversion).
Giuseppe Bilotta [Wed, 29 Sep 2010 23:37:05 +0000 (01:37 +0200)]
IRC framework: Server#to_s must always return a String
Having Server#to_s alias the hostname would cause problems when the
hostname was nil (e.g. after a disconnect). Fix by making sure that to_s
always returns a string instead.
Giuseppe Bilotta [Mon, 27 Sep 2010 11:52:14 +0000 (13:52 +0200)]
* wrap BDB::Fatal classes for abstract trapping
When using a DB backend different from BDB, the BDB constant may not be
defined, causing a NameError during error trapping in the main loop. Fix
this by defining our own DBFatal error that maps to BDB::Fatal in the
BDB case and is defined as an (unused) Exception for TokyoCabinet.
Giuseppe Bilotta [Thu, 23 Sep 2010 20:20:57 +0000 (22:20 +0200)]
TokyoCabinet: 0.9.5-to-0.9.9 must use BDB only
When upgrading from 0.9.5 data, write the 0.9.9-style regisitry using
BDB still rather than trying to use TokyoCabinet already. This makes
sure that the next step (0.9.9 to modern times) works correctly.
(Moreover, the existing BDB-to-TC attempt wouldn't have worked anyway
due to wrong var names. I doubt anybody will ever hit this path and
notice though.)
Giuseppe Bilotta [Wed, 15 Sep 2010 12:09:42 +0000 (14:09 +0200)]
tumblr: support reblogging and fix HTML issues
Detect tumblr posts and use the reblogging API to post them. Also
produce HTML-escaped lines for video and photo captions because
the format=markdown specification doesn't seem to apply to them.
When OAuth is missing, some barebone functionality in the twitter plugin
is still available (namely, status reading from public timelines), so
don't fail loading and just warn the users and admins about the reduced
availability.
There was a bug in "twitter pin" functionality where it didn't
check to verify that the PIN entered by the user was valid. As
a result, if the user entered an invalid PIN, the bot would
not respond as to whether or not twitter account binding was
successful. I replaced it with an error message if the PIN
is invalid. I also changed the error message for someone
who tries to enter a PIN without first using "twitter
authorize" to be more clear.
Module now requires twitter.key and twitter.secret config parameters for
write access and private users' statuses. Added twitter authorize,
twitter deauthorize, and twitter pin features, removed twitter identify
feature, as basic authentication is no longer supported.
Atom categories don't have a content attribute, and obviously they don't
have an empty? method. Squash them to their label rather than bombing
out with error during the blank2nil processing.