2010-03-23 19:24:02 +01:00
# File: Quotegrabs.pm
2010-03-24 07:47:40 +01:00
# Author: pragma_
2010-03-17 07:36:54 +01:00
#
2015-09-08 20:46:08 +02:00
# Purpose: Allows users to "grab" quotes from message history and store them for later retrieval.
2010-03-17 07:36:54 +01:00
2017-03-05 22:33:31 +01:00
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
2015-09-08 20:42:43 +02:00
package PBot::Plugins::Quotegrabs ;
2010-03-17 07:36:54 +01:00
use warnings ;
use strict ;
2010-03-23 19:24:02 +01:00
use HTML::Entities ;
2011-12-04 02:13:21 +01:00
use Time::Duration ;
use Time::HiRes qw( gettimeofday ) ;
2014-04-30 23:37:28 +02:00
use Getopt::Long qw( GetOptionsFromString ) ;
2010-03-23 19:24:02 +01:00
2015-09-08 20:42:43 +02:00
use PBot::Plugins::Quotegrabs::Quotegrabs_SQLite ; # use SQLite backend for quotegrabs database
#use PBot::Plugins::Quotegrabs::Quotegrabs_Hashtable; # use Perl hashtable backend for quotegrabs database
2017-11-24 00:19:28 +01:00
use PBot::Utils::ValidateString ;
2014-05-06 07:15:27 +02:00
2013-10-11 20:17:07 +02:00
use POSIX qw( strftime ) ;
2010-03-23 19:24:02 +01:00
sub new {
if ( ref ( $ _ [ 1 ] ) eq 'HASH' ) {
Carp:: croak ( "Options to Quotegrabs should be key/value pairs, not hash reference" ) ;
}
my ( $ class , % conf ) = @ _ ;
my $ self = bless { } , $ class ;
$ self - > initialize ( % conf ) ;
return $ self ;
}
sub initialize {
my ( $ self , % conf ) = @ _ ;
2015-09-08 20:42:43 +02:00
$ self - > { pbot } = delete $ conf { pbot } // Carp:: croak ( "Missing pbot reference in Quotegrabs" ) ;
$ self - > { filename } = delete $ conf { quotegrabs_file } ;
$ self - > { export_path } = delete $ conf { export_quotegrabs_path } ;
$ self - > { export_site } = delete $ conf { export_quotegrabs_site } ;
2014-05-06 07:15:27 +02:00
2015-09-09 14:24:16 +02:00
$ self - > { database } = PBot::Plugins::Quotegrabs::Quotegrabs_SQLite - > new ( pbot = > $ self - > { pbot } , filename = > $ self - > { filename } ) ;
#$self->{database} = PBot::Plugins::Quotegrabs::Quotegrabs_Hashtable->new(pbot => $self->{pbot}, filename => $self->{filename});
2014-05-13 12:15:52 +02:00
$ self - > { database } - > begin ( ) ;
2010-03-23 19:24:02 +01:00
2014-05-17 00:11:31 +02:00
$ self - > { pbot } - > { atexit } - > register ( sub { $ self - > { database } - > end ( ) ; return ; } ) ;
2014-05-18 22:09:05 +02:00
$ self - > { pbot } - > { commands } - > register ( sub { $ self - > grab_quotegrab ( @ _ ) } , "grab" , 0 ) ;
$ self - > { pbot } - > { commands } - > register ( sub { $ self - > show_quotegrab ( @ _ ) } , "getq" , 0 ) ;
$ self - > { pbot } - > { commands } - > register ( sub { $ self - > delete_quotegrab ( @ _ ) } , "delq" , 0 ) ;
$ self - > { pbot } - > { commands } - > register ( sub { $ self - > show_random_quotegrab ( @ _ ) } , "rq" , 0 ) ;
2010-03-23 19:24:02 +01:00
}
2013-10-12 13:00:29 +02:00
sub uniq { my % seen ; grep ! $ seen { $ _ } + + , @ _ }
2014-05-06 07:15:27 +02:00
sub export_quotegrabs {
2010-03-23 19:24:02 +01:00
my $ self = shift ;
2015-09-08 20:42:43 +02:00
return "Quotegrabs exporting not enabled." if not defined $ self - > { export_path } ;
2014-05-06 07:15:27 +02:00
2014-05-13 12:15:52 +02:00
my $ quotegrabs = $ self - > { database } - > get_all_quotegrabs ( ) ;
2014-05-06 07:15:27 +02:00
2010-03-23 19:24:02 +01:00
my $ text ;
2013-10-11 20:17:07 +02:00
my $ table_id = 1 ;
2010-03-23 19:24:02 +01:00
my $ had_table = 0 ;
open FILE , "> $self->{export_path}" or return "Could not open export path." ;
my $ time = localtime ;
2013-10-11 20:17:07 +02:00
print FILE "<html>\n<head><link href=\"css/blue.css\" rel=\"stylesheet\" type=\"text/css\">\n" ;
print FILE '<script type="text/javascript" src="js/jquery-latest.js"></script>' . "\n" ;
print FILE '<script type="text/javascript" src="js/jquery.tablesorter.js"></script>' . "\n" ;
2014-03-03 10:24:33 +01:00
print FILE '<script type="text/javascript" src="js/picnet.table.filter.min.js"></script>' . "\n" ;
2013-10-12 15:36:36 +02:00
print FILE "</head>\n<body><i>Generated at $time</i><hr><h2>Candide's Quotegrabs</h2>\n" ;
2010-03-23 19:24:02 +01:00
my $ i = 0 ;
2013-10-13 12:23:20 +02:00
my $ last_channel = "" ;
2014-05-06 07:15:27 +02:00
foreach my $ quotegrab ( sort { $$ a { channel } cmp $$ b { channel } or $$ a { nick } cmp $$ b { nick } } @$ quotegrabs ) {
2013-10-13 12:23:20 +02:00
if ( not $ quotegrab - > { channel } =~ /^$last_channel$/i ) {
2017-11-24 00:19:28 +01:00
print FILE "<a href='#" . encode_entities ( $ quotegrab - > { channel } ) . "'>" . encode_entities ( $ quotegrab - > { channel } ) . "</a><br>\n" ;
2013-10-13 12:23:20 +02:00
$ last_channel = $ quotegrab - > { channel } ;
}
}
$ last_channel = "" ;
2014-05-06 07:15:27 +02:00
foreach my $ quotegrab ( sort { $$ a { channel } cmp $$ b { channel } or lc $$ a { nick } cmp lc $$ b { nick } } @$ quotegrabs ) {
2010-03-23 19:24:02 +01:00
if ( not $ quotegrab - > { channel } =~ /^$last_channel$/i ) {
2013-10-11 20:17:07 +02:00
print FILE "</tbody>\n</table>\n" if $ had_table ;
2017-11-24 00:19:28 +01:00
print FILE "<a name='" . encode_entities ( $ quotegrab - > { channel } ) . "'></a>\n" ;
print FILE "<hr><h3>" . encode_entities ( $ quotegrab - > { channel } ) . "</h3><hr>\n" ;
2013-10-11 20:17:07 +02:00
print FILE "<table border=\"0\" id=\"table$table_id\" class=\"tablesorter\">\n" ;
print FILE "<thead>\n<tr>\n" ;
print FILE "<th>id </th>\n" ;
print FILE "<th>author(s)</th>\n" ;
print FILE "<th>quote</th>\n" ;
print FILE "<th>date</th>\n" ;
print FILE "<th>grabbed by</th>\n" ;
print FILE "</tr>\n</thead>\n<tbody>\n" ;
2010-03-23 19:24:02 +01:00
$ had_table = 1 ;
2013-10-11 20:17:07 +02:00
$ table_id + + ;
2010-03-23 19:24:02 +01:00
}
$ last_channel = $ quotegrab - > { channel } ;
$ i + + ;
if ( $ i % 2 ) {
print FILE "<tr bgcolor=\"#dddddd\">\n" ;
} else {
print FILE "<tr>\n" ;
}
2013-10-11 20:17:07 +02:00
2010-03-23 19:24:02 +01:00
print FILE "<td>" . ( $ quotegrab - > { id } ) . "</td>" ;
2013-10-11 20:17:07 +02:00
my @ nicks = split /\+/ , $ quotegrab - > { nick } ;
2013-10-12 13:00:29 +02:00
$ text = join ', ' , uniq ( @ nicks ) ;
2013-10-11 20:17:07 +02:00
print FILE "<td>" . encode_entities ( $ text ) . "</td>" ;
my $ nick ;
$ text = $ quotegrab - > { text } ;
if ( $ text =~ s/^\/me\s+// ) {
$ nick = "* $nicks[0]" ;
} else {
$ nick = "<$nicks[0]>" ;
}
$ text = "<td><b>" . encode_entities ( $ nick ) . "</b> " . encode_entities ( $ text ) . "</td>\n" ;
2010-03-23 19:24:02 +01:00
print FILE $ text ;
2013-10-11 20:17:07 +02:00
print FILE "<td>" . encode_entities ( strftime "%Y/%m/%d %a %H:%M:%S" , localtime $ quotegrab - > { timestamp } ) . "</td>\n" ;
print FILE "<td>" . encode_entities ( $ quotegrab - > { grabbed_by } ) . "</td>\n" ;
print FILE "</tr>\n" ;
2010-03-23 19:24:02 +01:00
}
2010-03-17 07:36:54 +01:00
2013-10-11 20:17:07 +02:00
print FILE "</tbody>\n</table>\n" if $ had_table ;
print FILE "<script type='text/javascript'>\n" ;
$ table_id - - ;
2013-10-12 06:35:01 +02:00
print FILE '$(document).ready(function() {' . "\n" ;
2013-10-11 20:17:07 +02:00
while ( $ table_id > 0 ) {
2013-10-12 06:35:01 +02:00
print FILE '$("#table' . $ table_id . '").tablesorter();' . "\n" ;
2014-03-03 10:24:33 +01:00
print FILE '$("#table' . $ table_id . '").tableFilter();' . "\n" ;
2013-10-11 20:17:07 +02:00
$ table_id - - ;
}
2013-10-12 06:35:01 +02:00
print FILE "});\n" ;
2013-10-11 20:17:07 +02:00
print FILE "</script>\n" ;
2013-10-12 15:36:36 +02:00
print FILE "</body>\n</html>\n" ;
2010-03-23 19:24:02 +01:00
close ( FILE ) ;
2014-03-03 11:33:34 +01:00
return "$i quotegrabs exported to " . $ self - > { export_site } ;
2010-03-23 19:24:02 +01:00
}
2010-03-17 07:36:54 +01:00
2010-03-23 19:24:02 +01:00
sub grab_quotegrab {
my ( $ self , $ from , $ nick , $ user , $ host , $ arguments ) = @ _ ;
2010-03-17 07:36:54 +01:00
if ( not defined $ from ) {
2014-05-18 22:09:05 +02:00
$ self - > { pbot } - > { logger } - > log ( "Command missing ~from parameter!\n" ) ;
2010-03-17 07:36:54 +01:00
return "" ;
}
2013-07-24 14:34:13 +02:00
if ( not defined $ arguments or not length $ arguments ) {
2014-05-06 07:15:27 +02:00
return "Usage: grab <nick> [history [channel]] [+ <nick> [history [channel]] ...] -- where [history] is an optional argument that is a regex (without whitespace) of the text within the message; e.g., to grab a message containing 'pizza', use `grab nick pizza`; you can chain grabs with + to grab multiple messages" ;
2010-03-17 07:36:54 +01:00
}
2011-01-20 01:15:58 +01:00
$ arguments = lc $ arguments ;
2013-10-04 06:55:45 +02:00
my @ grabs = split /\s\+\s/ , $ arguments ;
2010-03-17 07:36:54 +01:00
2013-10-04 06:55:45 +02:00
my ( $ grab_nick , $ grab_history , $ channel , $ grab_nicks , $ grab_text ) ;
2010-03-17 07:36:54 +01:00
2013-10-04 06:55:45 +02:00
foreach my $ grab ( @ grabs ) {
2014-05-22 03:24:14 +02:00
( $ grab_nick , $ grab_history , $ channel ) = $ self - > { pbot } - > { commands } - > parse_arguments ( $ grab ) ;
2010-03-17 07:36:54 +01:00
2014-05-13 12:15:52 +02:00
$ grab_history = $ nick eq $ grab_nick ? 2 : 1 if not defined $ grab_history ; # skip grab command if grabbing self without arguments
2013-10-04 06:55:45 +02:00
$ channel = $ from if not defined $ channel ;
2011-02-11 03:46:35 +01:00
2013-11-14 07:35:40 +01:00
if ( not $ channel =~ m/^#/ ) {
return "'$channel' is not a valid channel; usage: grab <nick> [[history] channel] (you must specify a history parameter before the channel parameter)" ;
}
2014-05-13 12:15:52 +02:00
my ( $ account , $ found_nick ) = $ self - > { pbot } - > { messagehistory } - > { database } - > find_message_account_by_nick ( $ grab_nick ) ;
2010-03-17 07:36:54 +01:00
2014-05-13 12:15:52 +02:00
if ( not defined $ account ) {
return "I don't know anybody named $grab_nick" ;
2013-10-04 06:55:45 +02:00
}
2012-08-01 11:57:43 +02:00
2015-05-12 06:27:22 +02:00
$ found_nick =~ s/!.*$// ;
2014-05-13 12:15:52 +02:00
$ grab_nick = $ found_nick ; # convert nick to proper casing
2010-03-17 07:36:54 +01:00
2014-05-13 12:15:52 +02:00
my $ message ;
2013-10-04 06:55:45 +02:00
if ( $ grab_history =~ /^\d+$/ ) {
# integral history
2014-05-13 12:15:52 +02:00
my $ max_messages = $ self - > { pbot } - > { messagehistory } - > { database } - > get_max_messages ( $ account , $ channel ) ;
if ( $ grab_history < 1 || $ grab_history > $ max_messages ) {
return "Please choose a history between 1 and $max_messages" ;
2013-10-04 06:55:45 +02:00
}
2014-05-13 12:15:52 +02:00
$ grab_history - - ;
$ message = $ self - > { pbot } - > { messagehistory } - > { database } - > recall_message_by_count ( $ account , $ channel , $ grab_history , 'grab' ) ;
2013-10-04 06:55:45 +02:00
} else {
# regex history
2014-05-13 12:15:52 +02:00
$ message = $ self - > { pbot } - > { messagehistory } - > { database } - > recall_message_by_text ( $ account , $ channel , $ grab_history , 'grab' ) ;
if ( not defined $ message ) {
return "No such message for nick $grab_nick in channel $channel containing text '$grab_history'" ;
2012-08-01 11:57:43 +02:00
}
2013-10-04 06:55:45 +02:00
}
2012-08-01 11:57:43 +02:00
2014-05-18 22:09:05 +02:00
$ self - > { pbot } - > { logger } - > log ( "$nick ($from) grabbed <$grab_nick/$channel> $message->{msg}\n" ) ;
2013-10-04 06:55:45 +02:00
if ( not defined $ grab_nicks ) {
$ grab_nicks = $ grab_nick ;
} else {
$ grab_nicks . = "+$grab_nick" ;
}
2014-05-13 12:15:52 +02:00
my $ text = $ message - > { msg } ;
2013-10-04 06:55:45 +02:00
if ( not defined $ grab_text ) {
$ grab_text = $ text ;
} else {
if ( $ text =~ s/^\/me\s+// ) {
$ grab_text . = " * $grab_nick $text" ;
2012-08-01 11:57:43 +02:00
} else {
2013-10-04 06:55:45 +02:00
$ grab_text . = " <$grab_nick> $text" ;
2012-08-01 11:57:43 +02:00
}
}
}
2010-03-17 07:36:54 +01:00
my $ quotegrab = { } ;
2013-10-04 06:55:45 +02:00
$ quotegrab - > { nick } = $ grab_nicks ;
2010-03-17 07:36:54 +01:00
$ quotegrab - > { channel } = $ channel ;
2013-10-04 06:55:45 +02:00
$ quotegrab - > { timestamp } = gettimeofday ;
$ quotegrab - > { grabbed_by } = "$nick!$user\@$host" ;
2017-11-24 00:19:28 +01:00
$ quotegrab - > { text } = validate_string ( $ grab_text ) ;
2014-05-06 07:15:27 +02:00
$ quotegrab - > { id } = undef ;
2010-03-17 07:36:54 +01:00
2014-05-13 12:15:52 +02:00
$ quotegrab - > { id } = $ self - > { database } - > add_quotegrab ( $ quotegrab ) ;
2014-05-06 07:15:27 +02:00
if ( not defined $ quotegrab - > { id } ) {
return "Failed to grab quote." ;
}
$ self - > export_quotegrabs ( ) ;
2010-03-17 07:36:54 +01:00
2013-06-04 19:09:30 +02:00
my $ text = $ quotegrab - > { text } ;
2013-10-04 06:55:45 +02:00
( $ grab_nick ) = split /\+/ , $ grab_nicks , 2 ;
2013-06-04 19:09:30 +02:00
if ( $ text =~ s/^\/me\s+// ) {
2014-05-06 07:15:27 +02:00
return "Quote grabbed: $quotegrab->{id}: * $grab_nick $text" ;
2013-06-04 19:09:30 +02:00
} else {
2014-05-06 07:15:27 +02:00
return "Quote grabbed: $quotegrab->{id}: <$grab_nick> $text" ;
2013-06-04 19:09:30 +02:00
}
2010-03-17 07:36:54 +01:00
}
sub delete_quotegrab {
2010-03-23 19:24:02 +01:00
my ( $ self , $ from , $ nick , $ user , $ host , $ arguments ) = @ _ ;
2014-05-13 12:15:52 +02:00
my $ quotegrab = $ self - > { database } - > get_quotegrab ( $ arguments ) ;
2010-03-23 19:24:02 +01:00
2014-05-06 07:15:27 +02:00
if ( not defined $ quotegrab ) {
return "/msg $nick No quotegrab matching id $arguments found." ;
}
2013-10-26 04:39:54 +02:00
2014-05-18 22:09:05 +02:00
if ( not $ self - > { pbot } - > { admins } - > loggedin ( $ from , "$nick!$user\@$host" ) and $ quotegrab - > { grabbed_by } ne "$nick!$user\@$host" ) {
2013-10-26 04:39:54 +02:00
return "You are not the grabber of this quote." ;
}
2014-05-13 12:15:52 +02:00
$ self - > { database } - > delete_quotegrab ( $ arguments ) ;
2014-05-06 07:15:27 +02:00
$ self - > export_quotegrabs ( ) ;
2013-06-04 19:09:30 +02:00
my $ text = $ quotegrab - > { text } ;
2013-10-05 00:14:16 +02:00
my ( $ first_nick ) = split /\+/ , $ quotegrab - > { nick } , 2 ;
2013-06-04 19:09:30 +02:00
if ( $ text =~ s/^\/me\s+// ) {
2013-10-05 00:14:16 +02:00
return "Deleted $arguments: * $first_nick $text" ;
2013-06-04 19:09:30 +02:00
} else {
2013-10-05 00:14:16 +02:00
return "Deleted $arguments: <$first_nick> $text" ;
2013-06-04 19:09:30 +02:00
}
2010-03-17 07:36:54 +01:00
}
sub show_quotegrab {
2010-03-23 19:24:02 +01:00
my ( $ self , $ from , $ nick , $ user , $ host , $ arguments ) = @ _ ;
2010-03-17 07:36:54 +01:00
2014-05-13 12:15:52 +02:00
my $ quotegrab = $ self - > { database } - > get_quotegrab ( $ arguments ) ;
2014-05-06 07:15:27 +02:00
if ( not defined $ quotegrab ) {
return "/msg $nick No quotegrab matching id $arguments found." ;
2010-03-17 07:36:54 +01:00
}
2011-12-04 02:13:21 +01:00
my $ timestamp = $ quotegrab - > { timestamp } ;
my $ ago = ago ( gettimeofday - $ timestamp ) ;
2013-06-04 19:09:30 +02:00
my $ text = $ quotegrab - > { text } ;
2013-10-05 00:14:16 +02:00
my ( $ first_nick ) = split /\+/ , $ quotegrab - > { nick } , 2 ;
2013-06-04 19:09:30 +02:00
if ( $ text =~ s/^\/me\s+// ) {
2014-03-15 09:12:52 +01:00
return "$arguments: grabbed by $quotegrab->{grabbed_by} in $quotegrab->{channel} on " . localtime ( $ timestamp ) . " [$ago] * $first_nick $text" ;
2013-06-04 19:09:30 +02:00
} else {
2014-03-15 09:12:52 +01:00
return "$arguments: grabbed by $quotegrab->{grabbed_by} in $quotegrab->{channel} on " . localtime ( $ timestamp ) . " [$ago] <$first_nick> $text" ;
2013-06-04 19:09:30 +02:00
}
2010-03-17 07:36:54 +01:00
}
sub show_random_quotegrab {
2010-03-23 19:24:02 +01:00
my ( $ self , $ from , $ nick , $ user , $ host , $ arguments ) = @ _ ;
2010-03-17 07:36:54 +01:00
my @ quotes = ( ) ;
2014-03-15 09:07:05 +01:00
my ( $ nick_search , $ channel_search , $ text_search ) ;
2010-03-17 07:36:54 +01:00
if ( not defined $ from ) {
2014-05-18 22:09:05 +02:00
$ self - > { pbot } - > { logger } - > log ( "Command missing ~from parameter!\n" ) ;
2010-03-17 07:36:54 +01:00
return "" ;
}
2014-05-14 23:23:59 +02:00
my $ usage = 'Usage: rq [nick [channel [text]]] [-c,--channel <channel>] [-t,--text <text>]' ;
2014-04-30 23:37:28 +02:00
2010-03-17 07:36:54 +01:00
if ( defined $ arguments ) {
2014-04-30 23:37:28 +02:00
my $ getopt_error ;
local $ SIG { __WARN__ } = sub {
$ getopt_error = shift ;
chomp $ getopt_error ;
} ;
2014-03-15 09:07:05 +01:00
2017-08-30 11:12:05 +02:00
$ arguments =~ s/(?<!\\)'/\\'/g ;
2014-04-30 23:37:28 +02:00
my ( $ ret , $ args ) = GetOptionsFromString ( $ arguments ,
'channel|c=s' = > \ $ channel_search ,
'text|t=s' = > \ $ text_search ) ;
2014-03-15 09:07:05 +01:00
2014-04-30 23:37:28 +02:00
return "$getopt_error -- $usage" if defined $ getopt_error ;
2014-03-15 09:07:05 +01:00
2014-04-30 23:37:28 +02:00
$ nick_search = shift @$ args ;
$ channel_search = shift @$ args if not defined $ channel_search ;
$ text_search = shift @$ args if not defined $ text_search ;
2014-03-15 09:07:05 +01:00
2014-04-28 03:52:49 +02:00
if ( $ nick_search =~ m/^#/ ) {
my $ tmp = $ channel_search ;
$ channel_search = $ nick_search ;
$ nick_search = $ tmp ;
}
2010-03-17 07:36:54 +01:00
if ( not defined $ channel_search ) {
$ channel_search = $ from ;
}
2014-05-06 07:15:27 +02:00
}
2010-03-17 07:36:54 +01:00
2014-05-06 07:15:27 +02:00
$ channel_search = undef if defined $ channel_search and $ channel_search !~ /^#/ ;
2010-03-17 07:36:54 +01:00
2014-05-13 12:15:52 +02:00
my $ quotegrab = $ self - > { database } - > get_random_quotegrab ( $ nick_search , $ channel_search , $ text_search ) ;
2010-03-17 07:36:54 +01:00
2014-05-06 07:15:27 +02:00
if ( not defined $ quotegrab ) {
2014-02-10 19:04:05 +01:00
my $ result = "No quotes grabbed " ;
2014-05-06 07:15:27 +02:00
if ( defined $ nick_search ) {
2014-04-28 03:52:49 +02:00
$ result . = "for nick $nick_search " ;
2010-03-17 07:36:54 +01:00
}
2014-02-10 19:07:34 +01:00
2014-05-06 07:15:27 +02:00
if ( defined $ channel_search ) {
2014-04-28 03:52:49 +02:00
$ result . = "in channel $channel_search " ;
2014-02-10 19:07:34 +01:00
}
2014-05-06 07:15:27 +02:00
if ( defined $ text_search ) {
2014-04-28 03:52:49 +02:00
$ result . = "matching text '$text_search' " ;
2014-02-10 19:04:05 +01:00
}
2014-04-30 23:37:28 +02:00
return $ result . "yet ($usage)." ; ;
2010-03-17 07:36:54 +01:00
}
2013-06-04 19:09:30 +02:00
my $ text = $ quotegrab - > { text } ;
2013-10-05 00:14:16 +02:00
my ( $ first_nick ) = split /\+/ , $ quotegrab - > { nick } , 2 ;
2013-06-04 19:09:30 +02:00
if ( $ text =~ s/^\/me\s+// ) {
2014-04-30 23:37:28 +02:00
return "$quotegrab->{id}: " . ( ( $ channel_search eq '.*' or $ quotegrab - > { channel } ne $ from ) ? "[$quotegrab->{channel}] " : "" ) . "* $first_nick $text" ;
2013-06-04 19:09:30 +02:00
} else {
2014-04-30 23:37:28 +02:00
return "$quotegrab->{id}: " . ( ( $ channel_search eq '.*' or $ quotegrab - > { channel } ne $ from ) ? "[$quotegrab->{channel}] " : "" ) . "<$first_nick> $text" ;
2013-06-04 19:09:30 +02:00
}
2010-03-17 07:36:54 +01:00
}
1 ;