68 lines
1.5 KiB
Perl
68 lines
1.5 KiB
Perl
package Bot::BasicBot::Pluggable::Module::Titles;
|
|
|
|
use strict;
|
|
use warnings;
|
|
|
|
use Data::Dumper;
|
|
|
|
use base qw(Bot::BasicBot::Pluggable::Module);
|
|
use POE;
|
|
|
|
sub help {return ""}
|
|
|
|
sub set_fix {
|
|
my $who = shift;
|
|
my $fix = shift;
|
|
my $cont = shift;
|
|
|
|
$cont =~ s/^\s*(.*)\s*$/$1/g;
|
|
$cont =~ s/\x03\d+//g; # irc colors are fucked up, always set to 1, turn them back on later
|
|
$cont =~ s/\$([0-9a-f])/&$1/ig;
|
|
# $cont =~ s/[:^print:]//g;
|
|
|
|
# do we have the padding we need?
|
|
if ($fix eq "pre" && $cont !~ /&[0-9a-f]$/i) {
|
|
$cont .= " ";
|
|
} elsif ($fix eq "suf" && $cont !~ /^&[0-9a-f]/i) {
|
|
$cont = " ". $cont;
|
|
}
|
|
|
|
if ($cont =~ /"/) {
|
|
return "Can't use double quotes in a ${fix}fix";
|
|
}
|
|
|
|
if ($cont =~ /^\s+$/) { # if we're only whitespace, we're clearing it
|
|
$cont = "";
|
|
}
|
|
|
|
my $cmd = qq{pex user $who ${fix}fix "$cont"};
|
|
|
|
POE::Kernel->post( 'bukkitdtach', 'queue_command', $cmd );
|
|
|
|
return "Setting ${fix}fix to $cont"
|
|
}
|
|
|
|
sub told {
|
|
my ($self, $mess) = @_;
|
|
|
|
my $rsspromote = $self->bot()->module("RssPromote");
|
|
my $isdonator = $rsspromote->is_donator($mess->{who});
|
|
|
|
print "<", $mess->{who}, "@", $mess->{channel}, "> ", $mess->{body}, "\n";
|
|
|
|
return unless ($isdonator);
|
|
|
|
if ($mess->{body} =~ /^\s*\?prefix\s*(.*?)\s*$/ && $mess->{channel} eq "#main") {
|
|
my $prefix = $1;
|
|
|
|
return set_fix($mess->{who}, "pre", $prefix);
|
|
} elsif ($mess->{body} =~ /^\s*\?suffix\s*(.*?)\s*$/ && $mess->{channel} eq "#main") {
|
|
my $suffix = $1;
|
|
|
|
return set_fix($mess->{who}, "suf", $suffix);
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
1;
|