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.
Simon Hafner [Wed, 21 Jan 2009 15:49:31 +0000 (16:49 +0100)]
+ (reply) config option to force reply to query
+ (reply) symbol to bypass the config option
* (plugins) fixed url according to the patch
The symbols are:
:to => :public force the message to be replied in channel (if any)
:to => :private force the message to be replied in private
:to => :auto takes core.private_replies (default)
Simon Hafner [Wed, 21 Jan 2009 14:53:01 +0000 (15:53 +0100)]
+ (reply) add new option to control nick prefixing
Message#reply() now accepts a :reply option
:nick => false don't prefix nick
:nick => true prefix nick
:nick => :auto take core.reply_with_nick (default)
Giuseppe Bilotta [Thu, 15 Jan 2009 19:30:06 +0000 (20:30 +0100)]
ircbot: fix reconnect() waiting
The refactored reconnect() method would only wait when the socket was
connected at the time it got called. In case where the socket would have
closed earlier (e.g. because of a network I/O error) it would reconnect
directly, which would for example fail to prevent fast reconnections.
Fix by fencing the wait code with a check for @last_rec (checked before the
optional disconnect) rather than keeping it with the socket connect check,
and always initializing @last_rec on socket connect.
A side effect of this strategy is that reconnect() will only wait if the bot
was previously connect, or if it got disconnected by anything but the
disconnect() method. Callers of disconnect() should take care of waiting
themselves if they plan to reconnect.
An empty String is not false in Ruby, so check for it properly. Also,
find_fortune needs a message passed to it, to be used when it discovers
the correct path.
Sometimes the bot may receive incomplete or malformed mode lines. This
can be seen for example by kicking repeatedly and at very short
intervals the bot from a channel with +l set to some numbers (at least
on freenode).
We (don't) handle these malformed modelines by skipping them rather than
crashing.
Giuseppe Bilotta [Tue, 16 Dec 2008 00:55:44 +0000 (01:55 +0100)]
utils.rb: Utils.age_string to replace distance_of_time_in_words
We define a new age_string function which is a cleaner version of
distance_of_time_in_words. The latter gets removed as its only
in-tree usage was from timeago (which is the UI version that should
be used by plugins anyway).
Utils.timeago gets a revamp too, exploiting the new age_string function.
Giuseppe Bilotta [Thu, 20 Nov 2008 14:17:27 +0000 (15:17 +0100)]
rss plugin: prevent double UTF-8 deconding
The rss parser looks at the encoding specified into the XML file and
converts everything to UTF-8. Since we do the UTF-8 conversion
ourselves, monkey-patch the XML 'encoding' declaration to claim it's
UTF-8 already (as it actually is).
Giuseppe Bilotta [Mon, 17 Nov 2008 15:37:57 +0000 (16:37 +0100)]
azgame plugin: support autoadding words to wordlist
When the game is started with a wordlist it's possible to specify a
language to use for existence of words. When a word is not found in the
wordlist, it's checked against the given language check function, and if
present it's added to a specific file (autoadd-#{language}), which is
also used on load to choose the word to pick.