antifuck.pl: fix crash when closing an already-closed buffer
This commit is contained in:
parent
73fdde2c61
commit
e00dfa8492
@ -19,7 +19,7 @@ my %OPTIONS = (
|
||||
forward => ['Whether to allow channel forwards (+f on freenode)', '1'],
|
||||
);
|
||||
|
||||
my (%channels, %part, @partbuf, $fuckbuf, $timeout_cb);
|
||||
my (%channels, %part, %partbuf, $fuckbuf, $timeout_cb);
|
||||
|
||||
if (weechat::register($SCRIPT_NAME, $SCRIPT_AUTHOR, $SCRIPT_VERSION,
|
||||
$SCRIPT_LICENCE, $SCRIPT_DESC, '', '')) {
|
||||
@ -37,6 +37,7 @@ HELP
|
||||
weechat::hook_signal('irc_server_connected', 'irc_connect', '');
|
||||
weechat::hook_signal('irc_server_disconnected', 'irc_disconnect', '');
|
||||
weechat::hook_signal('irc_channel_opened', 'buffer_opened', '');
|
||||
weechat::hook_signal('buffer_closed', 'buffer_closed', '');
|
||||
weechat::hook_signal('*,irc_out1_join', 'client_join', '');
|
||||
weechat::hook_signal('*,irc_out1_part', 'client_part', '');
|
||||
weechat::hook_modifier('irc_in_366', 'irc_366', '');
|
||||
@ -76,6 +77,8 @@ sub cmd_antifuck {
|
||||
# fewest PARTs possible, a la irc_join_delay
|
||||
weechat::buffer_close($fuckbuf);
|
||||
}
|
||||
|
||||
return weechat::WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
sub fuckbuf_input {
|
||||
@ -84,8 +87,8 @@ sub fuckbuf_input {
|
||||
|
||||
sub fuckbuf_close {
|
||||
$fuckbuf = '';
|
||||
weechat::buffer_close($_) for (@partbuf);
|
||||
@partbuf = ();
|
||||
weechat::buffer_close($_) for (keys %partbuf);
|
||||
%partbuf = ();
|
||||
return weechat::WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
@ -107,8 +110,6 @@ sub irc_disconnect {
|
||||
|
||||
sub buffer_opened {
|
||||
my $buffer = pop;
|
||||
return weechat::WEECHAT_RC_OK
|
||||
if weechat::buffer_get_string($buffer, 'localvar_plugin') ne 'irc';
|
||||
|
||||
my ($server, $channel) = servchan($buffer);
|
||||
return weechat::WEECHAT_RC_OK if exists $channels{$server}{$channel};
|
||||
@ -122,9 +123,16 @@ sub buffer_opened {
|
||||
) unless $fuckbuf;
|
||||
|
||||
weechat::buffer_merge($buffer, $fuckbuf);
|
||||
return weechat::WEECHAT_RC_OK unless weechat::config_get_plugin('autopart');
|
||||
#return weechat::WEECHAT_RC_OK unless weechat::config_get_plugin('autopart');
|
||||
|
||||
push @partbuf, $buffer;
|
||||
$partbuf{$buffer} = 1;
|
||||
return weechat::WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
sub buffer_closed {
|
||||
my $buffer = pop;
|
||||
|
||||
delete $partbuf{$buffer};
|
||||
return weechat::WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user