]> git.99rst.org Git - irssi-scripts.irssi.org.git/commitdiff
Add smartfilter.pl
authorChristian Brassat <redacted>
Thu, 26 Jun 2014 16:46:20 +0000 (18:46 +0200)
committerChristian Brassat <redacted>
Thu, 26 Jun 2014 16:46:20 +0000 (18:46 +0200)
_data/scripts.yaml
scripts/smartfilter.pl [new file with mode: 0644]

index afbfb9eb5a4acd82c5f5103ccfa1d6233b414446..feb6ebd3dd8cf9cea5573e11a52f093b5c2b450b 100644 (file)
   name: "XQF"
   url: "none"
   version: "0.14"
+
+- authors: "crshd"
+  changed: "2012-10-02"
+  contact: "christian.brassat@gmail.com"
+  description: "Filters join/part messages if user hasn't been active in a while."
+  filename: "smartfilter.pl"
+  modified: "2012-10-02 21:05:40"
+  license: "BSD"
+  name: "smartfilter"
+  url: "none"
+  version: "0.1"
diff --git a/scripts/smartfilter.pl b/scripts/smartfilter.pl
new file mode 100644 (file)
index 0000000..f82ebb1
--- /dev/null
@@ -0,0 +1,36 @@
+use strict;
+use Irssi;
+use vars qw($VERSION %IRSSI);
+
+$VERSION = "0.1";
+
+%IRSSI = (
+    authors     => 'Christian Brassat',
+    contact     => 'crshd@mail.com',
+    name        => 'smartfilter.pl',
+    description => 'This script hides join/part messages.',
+    license     => 'BSD',
+    url         => 'http://crshd.github.io',
+    changed     => '2012-10-02',
+);
+
+our $lastmsg = {};
+
+sub smartfilter {
+    my ($channel, $nick, $address, $reason) = @_;
+    if ($lastmsg->{$nick} <= time() - Irssi::settings_get_int('smartfilter_delay')) {
+        Irssi::signal_stop();
+    }
+};
+
+sub log {
+    my ($server, $msg, $nick, $address, $target) = @_;
+    $lastmsg->{$nick} = time();
+}
+
+Irssi::signal_add('message public', 'log');
+Irssi::signal_add('message join', 'smartfilter');
+Irssi::signal_add('message part', 'smartfilter');
+Irssi::signal_add('message quit', 'smartfilter');
+
+Irssi::settings_add_int('smartfilter', 'smartfilter_delay', 300);
git clone https://git.99rst.org/PROJECT