mirror of
https://github.com/perlbot/perlbuut
synced 2025-06-09 03:15:41 -04:00
correct channel namespaced commands
This commit is contained in:
parent
eac6bb4e6e
commit
3081e67e38
1 changed files with 11 additions and 4 deletions
|
@ -40,6 +40,10 @@ my %commandhash = (
|
||||||
"substitute"=> \&get_fact_substitute,
|
"substitute"=> \&get_fact_substitute,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
my $commands_re = join '|', keys %commandhash;
|
||||||
|
$commands_re = qr/$commands_re/;
|
||||||
|
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my( $class ) = @_;
|
my( $class ) = @_;
|
||||||
|
|
||||||
|
@ -84,6 +88,7 @@ sub get_conf_for_channel {
|
||||||
|
|
||||||
sub get_namespaced_factoid {
|
sub get_namespaced_factoid {
|
||||||
my ($self, $pm, $body, $said, $forcechan, $forceserver) = @_;
|
my ($self, $pm, $body, $said, $forcechan, $forceserver) = @_;
|
||||||
|
my $command;
|
||||||
|
|
||||||
my ($channel, $server) = @{$said}{qw/channel server/};
|
my ($channel, $server) = @{$said}{qw/channel server/};
|
||||||
$server =~ s/^.*?([^.]+\.(?:com|net|co.uk|org|bot|info))$/$1/; # grab just the domain and tld, will expand to more domains later
|
$server =~ s/^.*?([^.]+\.(?:com|net|co.uk|org|bot|info))$/$1/; # grab just the domain and tld, will expand to more domains later
|
||||||
|
@ -93,6 +98,11 @@ sub get_namespaced_factoid {
|
||||||
|
|
||||||
return $body if $channel eq '*irc_msg' or $channel eq '##NULL';
|
return $body if $channel eq '*irc_msg' or $channel eq '##NULL';
|
||||||
|
|
||||||
|
if ($body =~ /^(?:\s*(?<command>$commands_re)\s+)?(?<body>.*)$/) {
|
||||||
|
#my ($command, $body);
|
||||||
|
($command, $body) = @+{qw/command body/};
|
||||||
|
}
|
||||||
|
|
||||||
open(my $fh, ">/tmp/notwut");
|
open(my $fh, ">/tmp/notwut");
|
||||||
|
|
||||||
print $fh "NAMESPACE: [ $channel , $server ]";
|
print $fh "NAMESPACE: [ $channel , $server ]";
|
||||||
|
@ -106,7 +116,7 @@ sub get_namespaced_factoid {
|
||||||
|
|
||||||
print $fh Dumper($realserver, $realchannel);
|
print $fh Dumper($realserver, $realchannel);
|
||||||
|
|
||||||
my $sepbody = $fsep.join($fsep, ($realserver, $realchannel, $body));
|
my $sepbody = ($command." "//'').$fsep.join($fsep, ($realserver, $realchannel, $body));
|
||||||
|
|
||||||
print $fh $sepbody, "\n";
|
print $fh $sepbody, "\n";
|
||||||
|
|
||||||
|
@ -166,9 +176,6 @@ sub command {
|
||||||
|
|
||||||
my $response; #namespaced factoids have no fallback
|
my $response; #namespaced factoids have no fallback
|
||||||
|
|
||||||
my $commands_re = join '|', keys %commandhash;
|
|
||||||
$commands_re = qr/$commands_re/;
|
|
||||||
|
|
||||||
if ($conf->{namespaced} || $said->{channel} eq '*irc_msg') {
|
if ($conf->{namespaced} || $said->{channel} eq '*irc_msg') {
|
||||||
# Parse body here
|
# Parse body here
|
||||||
my $body = $said->{body};
|
my $body = $said->{body};
|
||||||
|
|
Loading…
Add table
Reference in a new issue