Giuseppe Bilotta [Tue, 24 Feb 2009 20:48:34 +0000 (21:48 +0100)]
lastfm: catch all errors when connecting
Since httputil.get_response() can raise exceptions, catch them into an
appropriate block. Turn a missing response body into a runtime error to
handle this error conditions consistently with other exceptions.
Giuseppe Bilotta [Sat, 21 Feb 2009 19:03:53 +0000 (20:03 +0100)]
markov: try harder when generating strings
generate_strings() is now able to work with a single word. Additionally,
when the given lookup is not found in the database, it will try
lookups that start, and failing that include, the given one.
Giuseppe Bilotta [Sat, 21 Feb 2009 23:25:35 +0000 (00:25 +0100)]
registry: spare useless I/O
The each_key()/each_value() methods of the accessor relied on the each()
method of the database, wasting I/O bandwidth and time by loading
unnecessary data (particularly when running each_key() on databases with
ridiculously enormous values such as in the markov plugin case).
Giuseppe Bilotta [Mon, 16 Feb 2009 22:57:10 +0000 (23:57 +0100)]
factoids: pass proper parameter from unreplied()
When passing on the Array of split words from unreplied() to facts()
make sure that the passed argument behaves like an Array/String from
the MessageMapper.
Giuseppe Bilotta [Mon, 16 Feb 2009 20:14:32 +0000 (21:14 +0100)]
lastfm: limits to user data output
Define configuration keys for maximum and default number of user data
items output, with a separate value for shouts (which are usually much
more verbose and therefore would have a much lower maximum and default).
Each command also allow the specification of the number of entries
actually output (different than the default, clipped at the configured
maximum.
This way user data has the same rate limiting as events.
Internally, the switches for the user data are also made more uniform to
select, where it makes sense, different sentences depending on how many
entries are being displayed (none, all, some).
Giuseppe Bilotta [Sun, 15 Feb 2009 00:30:51 +0000 (01:30 +0100)]
+ @bot.path and datafile methods
We provide two methods that make it more simple and elegant for
botmodules to define paths relative to the bot's own directory
(botclass) and to the BotModule's (assumed) non-registry directory.
The first method is Irc::Bot#path(), which joins its arguments with the
botclass. This method can be used to access datafiles in the bot
directory with a much cleaner syntax; and since it uses File.join, the
resulting paths are also properly formatted on each platform, which
doesn't hurt.
Each BotModule now also carries a dirname() method that should return the
directory under botclass that holds the BotModule's datafiles. dirname()
defaults to the BotModule's name(), but it can be overridden, e.g. for
backwards compatibility (see the patch for the quotes plugin), or
for BotModules that share their datafiles.
Datafiles can be accessed using the BotModule#datafile() method that
joins the botclass, the dirname() and whatever other argument is passed.
Giuseppe Bilotta [Sat, 14 Feb 2009 22:56:49 +0000 (23:56 +0100)]
ircbot: refactor and clean up botclass dir handling
Use File.join across the board, and refactor some botclass directory
handling. Most important changes:
* failure to create the registry and safe_save directory is now fatal;
* failure to create the local plugin directory prevents it from being
added to the plugin path (with a warning);
* botclass directory update from templates is now a standalone routine
called during init, making it possible to use it in other cases too.
Giuseppe Bilotta [Wed, 11 Feb 2009 22:34:16 +0000 (23:34 +0100)]
ircbot: sendmsg filtering
We allow a filter to manipulate the arguments of sendmsg() by running
them through the filters of the :sendmsg group. The DataStream passed to
the filters has four keys:
:text => the message text
:type => the message type (typically, PRIVSMG or NOTICE)
:dest => the destination (typically, a Channel or User)
:options => options passed to sendmsg, merged with the default ones
Giuseppe Bilotta [Tue, 10 Feb 2009 00:19:03 +0000 (01:19 +0100)]
geoip: make the GeoIP module a standalone
The geoip plugin defines and makes use of a GeoIP module to handle the
actual geoip data retrieval. The module used to be defined in the same
namespace as the plugin, and therefore in a barely accessible anonymous
module.
Move the GeoIP module to the outermost namespace to allow it to be
accessible from scripts and plugins too.
Move the whitelist and badwords check in the message() method instead of
triggering on listen(). This is more correct and more efficient, and it
ensures that the whitelist protects mass-highlighters too.
Simon Hafner [Sun, 1 Feb 2009 19:08:25 +0000 (20:08 +0100)]
+ (bans) added masshl ban option
When a masshl ban is added, the bot will ban (or kick or whatever)
anybody that calls more than a given fixed number of users or a
percentage of in-channel users.
The real confessions are in the 'main' div, so rather than
second-guessing their true location (and getting it wrong every time the
site changes layout), just skip to the 'main' div before looking for
content.
rss plugin: don't abort if errors were found but rss is defined
If we always abort, a failing first parser will cause a failure even though a
subsequently tried parser succeeded in getting the feed right. So only
return nil if rss was nil when the error list wasn't empty.
Giuseppe Bilotta [Sat, 31 Jan 2009 10:49:18 +0000 (11:49 +0100)]
rss plugin: fix return/error handling in parseRss
Commit 36f1f28e668919dfab75c8fc4d1020abad351bd1 borked error handling as
it assumed that a false or nil rss implied a nonempty errors, and it
failed to return early.
Fix by removing the early check for a missing rss and wrapping the
report_problem (and the previously missing 'return nil') in the check
for a nonempty errors array.
Giuseppe Bilotta [Fri, 30 Jan 2009 22:41:14 +0000 (23:41 +0100)]
launch_here: be more compatible with git < 1.5.x
People living in the stone age (e.g. those stuck using Debian stable)
still have git 1.4.4.4, which doesn't support git log --pretty=format.
So we parse the git log --pretty=raw format instead, which should be
available even on such older systems.
For the same reason, parse git diff-index --stat instead of git diff
--shortstat.
Giuseppe Bilotta [Fri, 30 Jan 2009 17:24:34 +0000 (18:24 +0100)]
rss plugin: try all RSS parsers
Some feeds fail when parsed by some parsers, but work correctly with
others (e.g. http://www.blueman.com/community/rss fails with xmlparser
but not with REXML). So try all of them and only abort if none works
rather than failing because the default parser fails.
Giuseppe Bilotta [Fri, 30 Jan 2009 14:35:03 +0000 (15:35 +0100)]
quotes plugin: 'other channel' commands must be mapped earlier
Due to the way mapping work, quote commands whose first parameter is a
channel must be mapped before the ones that implicitly refer to the
current channel.
This has the upside that they really work, and the downside that
commands that refer to the current channel must specify the channel if
their argument begins wit something that looks like a channel spec.
However, this last case is extremely rare, so we're fine.
Giuseppe Bilotta [Wed, 28 Jan 2009 20:36:38 +0000 (21:36 +0100)]
ircbot: irc.ignore_channels config option
In some circumstances the user might want to turn the bot into a pure
logbot for some channels. This can now be achieved by adding that
channel to the irc.ignore_channels config key, that makes the bot ignore
all PRIVMSG to that channel (note that notices and service messages such
as joins and parts are still acted on, just like for irc.ignore_users).
Giuseppe Bilotta [Wed, 28 Jan 2009 17:11:18 +0000 (18:11 +0100)]
rss plugin: don't warn on rewatch
There is no need to warn when calling watchRss on a watched feed; in
fact, since watchRss() is called every time a watcher is added, it just
spam the channels with a useless message that also provides unnecessary
information. So just return.
Giuseppe Bilotta [Wed, 28 Jan 2009 17:01:55 +0000 (18:01 +0100)]
rss plugin: compact list of rss feeds
When lots of rss feeds are defined, the bot will flood the channel on
rss list. Fix by showing a compact list when the number of feeds is
higher than the maximum output lines.
Giuseppe Bilotta [Wed, 28 Jan 2009 13:51:21 +0000 (14:51 +0100)]
ircbot: the reconnect must be protected
The reconnect() call in the main loop must be protected in the
begin/rescue blocks. Most of the rescue blocks can be fall-through,
because the begin/end is wrapped in a loop. The only exception is the
ServerError block that issues a retry lest too_fast is reset to false
even when it should be true.
Giuseppe Bilotta [Tue, 27 Jan 2009 01:14:33 +0000 (02:14 +0100)]
url plugin: urls info should work regardless of config
The 'urls info' command to manually query for link information should
always work, regardless of the setting of the url.only_on_channels
config setting.
Fix by making the channels list for handle_urls() into an option
(defaulting to url.only_on_channels) and passing an empty list from
info().
Giuseppe Bilotta [Sun, 25 Jan 2009 23:47:04 +0000 (00:47 +0100)]
rss plugin: parseRss returns the number of found items
Change the parseRss routine to return the number of found items, or nil
in case of error. This helps clearly differentiate between empty feeds
(which are still legit) and b0rked feeds.
This change in logic does not alter the fact that a feed update with no
items will not wipe existing old feed items.
Giuseppe Bilotta [Fri, 23 Jan 2009 01:34:23 +0000 (02:34 +0100)]
launch_here: rewrite git revision retrieval
Use low-level ('plumbing') git commands to retrieve the current
commit/revision/work tree status when we're being launched from a git
tree. This is faster (less shell escapes) and should work equally well
with all git versions (past, present and future).
Giuseppe Bilotta [Thu, 22 Jan 2009 22:29:50 +0000 (23:29 +0100)]
launch_here: add commit subject rather than svn id to revision
There are no git-svn-ids in our repository, so don't look for them.
Instead, put the last commit subject next to the revision to ease
identification of the commit.