Skip to content

Instantly share code, notes, and snippets.

@poppyschmo
Created July 16, 2018 06:49
Show Gist options
  • Save poppyschmo/977f422f8a52d05eb535aabc5ff7e290 to your computer and use it in GitHub Desktop.
Save poppyschmo/977f422f8a52d05eb535aabc5ff7e290 to your computer and use it in GitHub Desktop.
Request znc.in/self-message capability in irssi
use strict;
use Irssi;
use vars qw($VERSION %IRSSI);
# Derived from: cap_sasl.pl and server_time.pl
# See also: https://irssi.org/NEWS/#v0-8-18
$VERSION = '0.1';
%IRSSI = (
authors => 'poppyschmo',
contact => 'poppyschmo@users.noreply.github.com',
name => 'cap_znc_self_message',
description => 'Requests znc.in/self-message, implemented since 0.8.18',
license => 'MIT',
url => 'http://defs.ircdocs.horse/info/selfmessages.html',
);
sub event_cap {
my ($server, $args, $nick, $address) = @_;
if ($args !~ /^\S+ (\S+) :(.*)$/) {
return;
} elsif ($1 eq 'LS'
&& !$server->{connected}
&& grep($_ eq 'znc.in/self-message', split(/\s+/, $2))) {
$server->send_raw_now('CAP REQ :znc.in/self-message');
}
# According to <https://ircv3.github.io/specs/core/
# capability-negotiation-3.1.html#the-cap-nak-subcommand>,
# separate NAK rejections are issued per offending REQ
elsif ($1 eq 'NAK' && $2 eq 'znc.in/self-message') {
my $msg ="\x02warning\x02 server rejected 'znc.in/self-message'";
$server->print('', $msg);
}
}
Irssi::signal_add('event cap', \&event_cap);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment