diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 20:19:02 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 20:19:02 +0000 |
commit | 03929dac2a29664878d2c971648a4fe1fb698462 (patch) | |
tree | 02c5e2b3e006234aa29545f7a93a1ce01b291a8b /scripts/query-connection-notifier.pl | |
parent | Initial commit. (diff) | |
download | irssi-scripts-03929dac2a29664878d2c971648a4fe1fb698462.tar.xz irssi-scripts-03929dac2a29664878d2c971648a4fe1fb698462.zip |
Adding upstream version 20231031.upstream/20231031upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'scripts/query-connection-notifier.pl')
-rw-r--r-- | scripts/query-connection-notifier.pl | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/scripts/query-connection-notifier.pl b/scripts/query-connection-notifier.pl new file mode 100644 index 0000000..450512f --- /dev/null +++ b/scripts/query-connection-notifier.pl @@ -0,0 +1,67 @@ +use Irssi; +use Irssi::UI; +use Irssi::TextUI; +use vars qw($VERSION %IRSSI); + +$VERSION = '0.1'; +%IRSSI = ( + author => 'meh', + contact => 'meh@schizofreni.co', + name => 'Query connection notification', + description => 'Notify in the query window when the nick connects', + license => 'WTFPL', +); + +Irssi::theme_register([ + 'connect', '{channick_hilight $0} {chanhost_hilight $1} has connected' +]); + +my %quit; + +Irssi::signal_add 'message join' => sub { + my ($server, $channel, $nick, $address) = @_; + + if ($quit{"$server->{tag}:$nick"}) { + delete $quit{"$server->{tag}:$nick"}; + + foreach $query (Irssi::queries()) { + if ($query->{server_tag} eq $server->{tag} && $query->{name} eq $nick) { + $query->printformat(MSGLEVEL_JOINS, 'connect', $nick, $address); + + break; + } + } + } +}; + +Irssi::signal_add 'message quit' => sub { + my ($server, $nick, $address, $reason) = @_; + + $quit{"$server->{tag}:$nick"} = 1; +}; + +Irssi::signal_add 'query created' => sub { + my ($query, $automatic) = @_; + + foreach $channel ($query->{server}->channels) { + foreach $nick ($channel->nicks) { + if ($nick eq $query->{name}) { + return; + } + } + } + + $quit{"$query->{server}->{tag}:$query->{name}"} = 1; +}; + +Irssi::signal_add 'query destroyed' => sub { + my ($query) = @_; + + delete $quit{"$query->{server}->{tag}:$query->{name}"}; +}; + +Irssi::signal_add 'message private' => sub { + my ($server, $msg, $nick, $address) = @_; + + delete $quit{"$server->{tag}:$nick"}; +}; |