Aliases now work in PM's to the bot too.
This commit is contained in:
1 parent
de3e914e3d
commit
bc287589bb
3 files changed
+30
-1
No files matched your search
@@ -22,6 +22,7 @@ In this alpha10 release, we have added:
|
||||
* German translation for FML command help.
|
||||
* German translation for Greet command help.
|
||||
* Werewolf module for the Werewolf party game.
|
||||
* Aliases now work in PM's to the bot too.
|
||||
|
||||
Bug fixes:
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ Auto IRC Bot 3.0: Change Log
|
||||
|
||||
3.0 Indev
|
||||
===============================================================================
|
||||
* Aliases now work in PM's to the bot too.
|
||||
* Added an epic, Werewolf module.
|
||||
* Made slog() saner.
|
||||
* Syntax for mod_init() changed. Package name is no longer required.
|
||||
|
||||
+28
-1
@@ -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)) = @_;
|
||||
|
||||
Reference in new issue
Block a user