add small delay between forcejoins

slows time til sendq and doesn't make the client freeze up on large floods
This commit is contained in:
wowaname 2016-10-02 02:21:49 +00:00
parent 3407bebaff
commit 68d62d32b7

View File

@ -49,24 +49,32 @@ my %OPTIONS = (
furry => ['Channel prefix (include # or &)', '&HYE']
);
sub fuckyou
{
my $buffer = shift;
my $nig = md5_hex($$ * time);
weechat::command($buffer, "/quote $FORCEJOIN $nick ${FURRY}_$nig");
return weechat::WEECHAT_RC_OK;
}
sub cmd_fuckyou
{
my (undef, $buffer, $data) = @_;
my $server = weechat::buffer_get_string($buffer, 'localvar_server');
my ($nick, $amt_end) = split(/ +/, $data);
my $FORCEJOIN = weechat::config_get_plugin('forcejoin');
my $FURRY = weechat::config_get_plugin('furry');
unless($nick && $amt_end)
{
our $nick; my $amt_end;
($nick, $amt_end) = split / +/, $data;
our ($FORCEJOIN, $FURRY) = (weechat::config_get_plugin('forcejoin'),
weechat::config_get_plugin('furry'));
unless ($nick and $amt_end) {
weechat::print($buffer, '/fuckyou <nick> <amt>');
return weechat::WEECHAT_RC_OK;
}
for(1 .. $amt_end)
{
my $nig = md5_hex($$ * time * $_);
weechat::command('', "/quote $FORCEJOIN $nick ${FURRY}_$nig");
}
weechat::hook_timer(50, 0, $amt_end, 'fuckyou', $buffer);
return weechat::WEECHAT_RC_OK;
}
@ -77,12 +85,13 @@ sub cmd_unfuckyou
weechat::buffer_get_string($buffer, 'localvar_server'),
weechat::buffer_get_string($buffer, 'localvar_channel')
);
unless ($data) {
weechat::print($buffer, '/unfuckyou user user2 user3');
return weechat::WEECHAT_RC_OK;
}
foreach my $dick (split(/ +/, $data))
{
foreach my $dick (split / +/, $data) {
weechat::hook_hsignal_send(
'irc_redirect_command',
{
@ -96,6 +105,7 @@ sub cmd_unfuckyou
"$server;;1;;/whois $dick"
);
}
return weechat::WEECHAT_RC_OK;
}
@ -114,7 +124,7 @@ sub event_whois_channels
$channels =~ s/ +$//;
my @niggers = split(/ +/, $channels);
my @niggers = split / +/, $channels;
foreach (@niggers)
{
s/^[@%+]([&#])/$1/;
@ -126,8 +136,10 @@ sub event_whois_channels
}
}
}
weechat::print('', "Forceparted $nick from $counter channels")
if $counter;
return weechat::WEECHAT_RC_OK;
}