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/ignoreoc.pl | |
parent | Initial commit. (diff) | |
download | irssi-scripts-upstream.tar.xz irssi-scripts-upstream.zip |
Adding upstream version 20231031.upstream/20231031upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'scripts/ignoreoc.pl')
-rw-r--r-- | scripts/ignoreoc.pl | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/scripts/ignoreoc.pl b/scripts/ignoreoc.pl new file mode 100644 index 0000000..776b3d7 --- /dev/null +++ b/scripts/ignoreoc.pl @@ -0,0 +1,65 @@ +#!/usr/bin/perl -w +use strict; +use Irssi; +use vars qw($VERSION %IRSSI); +$VERSION = "0.6"; +%IRSSI = ( + authors => "Erkki Seppälä", + contact => "flux\@inside.org", + name => "Ignore-OC", + description => "Ignore messages from people not on your channels." . + "Now people you msg are added to bypass-list.", + license => "Public Domain", + url => "http://www.inside.org/~flux/software/irssi/", + changed => "Mon Jun 16 08:10:45 EEST 2008" +); + +my %bypass = (); + +my $ignoredMessages = 0; + +sub cmd_message_private { + my ($server, $message, $nick, $address) = @_; + my $channel; + +=cut + my ($addressNick) = $address =~ /^([^@]*)/; + + if ($addressNick ne $server->{nick}) { + Irssi::print "Irssi bug? Received a message sent to $address"; + return 1; + } +=cut + + if ($message =~ m/oc:/i || + exists $bypass{$nick}) { + return 1; + } + + foreach $channel ($server->channels()) { + foreach my $other ($channel->nicks()) { + if ($other->{nick} eq $nick) { + return 1; + } + } + } + + ++$ignoredMessages; + $server->command("^NOTICE $nick You're not on any channel I'm on, thus, due to spambots, your message was ignored. Prefix your message with 'OC:' to bypass the ignore."); + Irssi::signal_stop(); +} + +sub cmd_message_own_private { + my ($server, $message, $nick, $address) = @_; + $bypass{$nick} = 1; +} + +sub cmd_ignoreoc { + Irssi::print("You've ignored $ignoredMessages messages since startup."); +} + +Irssi::signal_add_first("message private", "cmd_message_private"); +Irssi::signal_add("message own_private", "cmd_message_own_private"); +Irssi::command_bind("ignoreoc", "cmd_ignoreoc"); + +Irssi::print "IgnoreOC version $VERSION by flux with patches from Exstatica. Try /ignoreoc" |