Aliases now work in PM's to the bot too.

This commit is contained in:
Elijah Perrault committed 2011-04-07 14:54:30 -06:00
1 parent de3e914e3d
commit bc287589bb
3 files changed
+30 -1

No files matched your search

+28 -1
View File
@@ -26,7 +26,7 @@ hook_add("on_uprivmsg", "ctcp_version_reply", sub {
return 1;
});
# Command alias parsing.
# Command alias parsing for channel messages.
hook_add('on_cprivmsg', 'irc.commands.aliases', sub {
my (($src, $chan, ($cmd, @args))) = @_;
@@ -61,6 +61,33 @@ hook_add('on_cprivmsg', 'irc.commands.aliases', sub {
return 1;
});
# Command alias parsing for private messages.
hook_add('on_uprivmsg', 'irc.commands.aliases', sub {
my (($src, ($cmd, @args))) = @_;
# Check for an alias.
if (defined $API::Std::ALIASES{uc $cmd}) {
# Get aliased command.
my @actual;
if ($API::Std::ALIASES{uc $cmd} =~ m/ /xsm) { @actual = split /\s/xsm, $API::Std::ALIASES{uc $cmd} }
else { @actual = ($API::Std::ALIASES{uc $cmd}) }
# Prepare data.
my @msg = (
q{:}.$src->{nick}.q{!}.$src->{user}.q{@}.$src->{host},
'PRIVMSG',
$State::IRC::botinfo{$src->{svr}}{nick},
q{:}.$actual[0],
);
# Rest of the data.
if (scalar @actual > 1) { for (1..$#actual) { push @msg, $actual[$_] } }
if (defined $args[0]) { foreach (@args) { push @msg, $_ } }
# Simulate a PRIVMSG.
Proto::IRC::privmsg($src->{svr}, @msg);
}
return 1;
});
# QUIT hook; delete user from chanusers.
hook_add("on_quit", "quit_update_chanusers", sub {
my (($src, undef)) = @_;