Skip to content

Instantly share code, notes, and snippets.

@paigeadelethompson
Last active January 8, 2026 00:05
Show Gist options
  • Select an option

  • Save paigeadelethompson/278b70ae75fdb13598999a861091199a to your computer and use it in GitHub Desktop.

Select an option

Save paigeadelethompson/278b70ae75fdb13598999a861091199a to your computer and use it in GitHub Desktop.
use strict;
use Irssi;
use Irssi::Irc;
use vars qw($VERSION %IRSSI);
$VERSION = "1.4";
%IRSSI = (
authors => "Grok",
name => "mass_highlighter",
description => "Mass highlight commands: /masshl (single message), /masshl_each (one message per user)",
license => "Public Domain",
);
########################################
# /masshl — one message with all nicks
########################################
sub cmd_masshl {
my ($data, $server, $witem) = @_;
return unless $witem && $witem->{type} eq "CHANNEL";
my @parts = split(/\s+/, $data);
my %exclude;
my @message_parts;
my $collecting_excludes = 1;
foreach my $part (@parts) {
if ($part =~ /^-(.+)/) {
$exclude{lc($1)} = 1;
} else {
$collecting_excludes = 0;
}
push @message_parts, $part unless $collecting_excludes;
}
my $channel = $witem->{name};
my $rec = $server->channel_find($channel) or return;
my @nicks;
foreach my $nickrec ($rec->nicks()) {
my $nick = $nickrec->{nick};
next if $exclude{lc($nick)};
push @nicks, $nick;
}
return unless @nicks;
my $message = join(" ", @message_parts);
my $full_msg = join(" ", @nicks) . " " . $message;
$witem->command("MSG $channel $full_msg");
Irssi::print("masshl: sent to " . scalar(@nicks) . " users");
}
########################################
# /masshl_each — one message per user
########################################
sub cmd_masshl_each {
my ($data, $server, $witem) = @_;
return unless $witem && $witem->{type} eq "CHANNEL";
my @parts = split(/\s+/, $data);
my %exclude;
my @message_parts;
my $collecting_excludes = 1;
foreach my $part (@parts) {
if ($part =~ /^-(.+)/) {
$exclude{lc($1)} = 1;
} else {
$collecting_excludes = 0;
}
push @message_parts, $part unless $collecting_excludes;
}
# Always exclude yourself
$exclude{lc($server->{nick})} = 1;
my $channel = $witem->{name};
my $rec = $server->channel_find($channel) or return;
my @nicks;
foreach my $nickrec ($rec->nicks()) {
my $nick = $nickrec->{nick};
next if $exclude{lc($nick)};
push @nicks, $nick;
}
return unless @nicks;
my $message = join(" ", @message_parts);
Irssi::print("masshl_each: sending to " . scalar(@nicks) . " users");
foreach my $nick (@nicks) {
$witem->command("MSG $channel $nick: $message");
}
}
########################################
# Command bindings
########################################
Irssi::command_bind('masshl', 'cmd_masshl');
Irssi::command_bind('masshl_each', 'cmd_masshl_each');
Irssi::print("mass_highlighter v$VERSION loaded: /masshl, /masshl_each");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment