fuckyou.pl: support for multiple forcejoins in one command

as well as support for custom whois command
This commit is contained in:
wowaname 2017-01-24 06:01:27 +00:00
parent 04d736bbcf
commit ca9b58ea7b

View File

@ -37,7 +37,7 @@ use Digest::MD5 qw(md5_hex);
my $SCRIPT_NAME = 'fuckyou';
my $SCRIPT_AUTHOR = 'Goat-See <mrtheplague@gmail.com>';
my $SCRIPT_VERSION = '2.2';
my $SCRIPT_VERSION = '2.3';
my $SCRIPT_LICENCE = 'urmom';
my $SCRIPT_DESC = '/fuckyou NICK numberchannels';
@ -46,15 +46,20 @@ my %OPTIONS = (
'forcejoin'],
forcepart => ['Command to forcepart. ratbox uses forcepart, unreal sapart',
'forcepart'],
furry => ['Channel prefix (include # or &)', '&HYE']
furry => ['Channel prefix (include # or &)', '&HYE'],
parallel => ['Number of channels to send per forcejoin command', 1],
whois_cmd => ['Prefix to whois user (e.g. for ratbox operspy, "/whois !")',
'/whois '],
);
sub fuckyou
{
my $buffer = shift;
my $nig = md5_hex($$ * time);
my $nig = $$ * time;
my @jews;
push @jews, "${FURRY}_".md5_hex($nig + $_) for (1..$PARALLEL);
weechat::command($buffer, "/quote $FORCEJOIN $target ${FURRY}_$nig");
weechat::command($buffer, "/quote $FORCEJOIN $target ".join(',', @jews));
return weechat::WEECHAT_RC_OK;
}
@ -65,13 +70,18 @@ sub cmd_fuckyou
my $server = weechat::buffer_get_string($buffer, 'localvar_server');
my $amt_end;
($target, $amt_end) = split / +/, $data;
our ($FORCEJOIN, $FURRY) = (weechat::config_get_plugin('forcejoin'),
weechat::config_get_plugin('furry'));
our ($FORCEJOIN, $FURRY, $PARALLEL) = (
weechat::config_get_plugin('forcejoin'),
weechat::config_get_plugin('furry'),
weechat::config_get_plugin('parallel'));
unless ($target and $amt_end) {
weechat::print($buffer, '/fuckyou <nick> <amt>');
unless ($target) {
weechat::print($buffer, 'Stopping any current /fuckyou');
weechat::unhook($signal) if $signal;
weechat::unhook($timer) if $timer;
return weechat::WEECHAT_RC_OK;
}
$amt_end //= 0;
$signal = weechat::hook_signal("$server,irc_raw_in_402", 'irc_402', '');
$timer = weechat::hook_timer(50, 0, $amt_end, 'fuckyou', $buffer);
@ -86,6 +96,7 @@ sub cmd_unfuckyou
weechat::buffer_get_string($buffer, 'localvar_server'),
weechat::buffer_get_string($buffer, 'localvar_channel')
);
my $WHOIS = weechat::config_get_plugin('whois_cmd');
unless ($data) {
weechat::print($buffer, '/unfuckyou user user2 user3');
@ -103,7 +114,7 @@ sub cmd_unfuckyou
weechat::hook_signal_send(
'irc_input_send',
weechat::WEECHAT_HOOK_SIGNAL_STRING,
"$server;;1;;/whois $dick"
"$server;;1;;$WHOIS$dick"
);
}
@ -128,7 +139,7 @@ sub event_whois_channels
my @niggers = split / +/, $channels;
foreach (@niggers)
{
s/^[@%+]([&#])/$1/;
s/^[!@%+]*([&#])/$1/;
if(/${FURRY}_[a-f0-9]+/i)
{
#Irssi::print("Forceparting $nick from $_");
@ -157,8 +168,11 @@ sub irc_402 {
if (weechat::register($SCRIPT_NAME, $SCRIPT_AUTHOR, $SCRIPT_VERSION,
$SCRIPT_LICENCE, $SCRIPT_DESC, '', '')) {
weechat::hook_command('fuckyou', '', '<nick> <amt>', '', '',
'cmd_fuckyou', '');
weechat::hook_command('fuckyou', '', '[<nick> [<amt>]]',
"if nick is not given, stops current fuckyou, if any is running\n\n".
"amt is 0 by default - user will be fuckyoud until they disconnect\n".
"or you stop it manually\n",
'', 'cmd_fuckyou', '');
weechat::hook_command('unfuckyou', '', '<nick> [nick...]', '', '',
'cmd_unfuckyou', '');
weechat::hook_hsignal('irc_redirection_sigwhois_whois',