From: Andreas Scherbaum Date: Fri, 25 May 2012 21:41:52 +0000 (+0200) Subject: - identify commands in private messages X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=9c42335263eb11a220853b64adcd712934fa7fb9;p=docbot.git - identify commands in private messages --- diff --git a/docbot.pl b/docbot.pl index a555c36..ac1b3b0 100755 --- a/docbot.pl +++ b/docbot.pl @@ -1145,7 +1145,6 @@ sub find_command { # looks like a command, at least started with a question mark # find out if it really is one - if (is_valid_command($command)) { return ($command, $string); } @@ -1153,7 +1152,7 @@ sub find_command { # try to translate the command # find the channel language my $channel_language = config_get_key3('channels', $channel, 'language'); - # not defined channel language leads to a full search across all languages + # not defined channel language triggers a full search across all languages # this is just fine my $translation = find_translation($channel_language, $command); @@ -1162,6 +1161,26 @@ sub find_command { } } + if (!is_a_channel($channel)) { + # go the extra mile and identify commands in private messages to the bot + if ($msg =~ /^\s*([a-z]+)\s*(.*)/) { + $command = lc($1); + $string = defined($2) ? $2 : ''; + + # find out if it a command + if (is_valid_command($command)) { + return ($command, $string); + } + + # not defined channel language triggers a full search across all languages + # this is just fine + my $translation = find_translation(undef, $command); + if (defined($translation) and is_valid_command($translation)) { + return ($translation, $string); + } + } + } + if ($msg =~ /^\s*\?\?(.+)/) { # a valid search return ('search', $1);