aboutsummaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
Diffstat (limited to 'plugin')
-rw-r--r--plugin/antiflood.pm42
-rw-r--r--plugin/map.pm34
-rw-r--r--plugin/timezone.pm40
-rw-r--r--plugin/tittilate.pm37
-rw-r--r--plugin/url_title.pm67
5 files changed, 0 insertions, 220 deletions
diff --git a/plugin/antiflood.pm b/plugin/antiflood.pm
deleted file mode 100644
index a44c07c..0000000
--- a/plugin/antiflood.pm
+++ /dev/null
@@ -1,42 +0,0 @@
-#!/usr/bin/env perl
-
-package plugin::antiflood;
-
-use strict;
-use warnings;
-
-my $message_count = 5;
-my $message_period = 11;
-
-
-my %config;
-my %lastmsg = ();
-
-sub configure {
- my $self = $_[0];
- my $cmdref = $_[1];
- my $cref = $_[2];
- %config = %$cref;
- return $self;
-}
-
-sub message {
- my ($self, $logger, $me, $who, $where, $raw_what, $what, $irc) = @_;
- my $channel = $where->[0];
- my $nick = (split /!/, $who)[0];
-
- return if ($config{antiflood_on} == 0);
-
- my $now = time();
- push @{$lastmsg{$nick}}, $now;
-
- if (@{$lastmsg{$nick}} >= $message_count) {
- @{$lastmsg{$nick}} = splice @{$lastmsg{$nick}}, 1, $message_count - 1;
- my $first = @{$lastmsg{$nick}}[0];
- if ($now - $first <= $message_period) {
- $irc->yield(kick => $channel => $nick => "Flood");
- }
- }
- return;
-}
-1;
diff --git a/plugin/map.pm b/plugin/map.pm
deleted file mode 100644
index f8cb256..0000000
--- a/plugin/map.pm
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/usr/bin/env perl
-
-package plugin::map;
-
-use strict;
-use warnings;
-
-my %config;
-my $run_command;
-
-
-sub configure {
- my $self = shift;
- my $cmdref = shift;
- my $cref = shift;
- %config = %$cref;
- $run_command = shift;
-
- $cmdref->("map", sub { $self->map(@_); } );
-
- return $self;
-}
-
-sub map {
- my ($self, $logger, $who, $where, $rest, @arguments) = @_;
- my ($command, $subjects) = ($rest =~ /^(.+?)\s+(.*)$/);
-
- return "[]" unless $subjects;
-
- my @array = map { $run_command->("$command $_", $who, $where) } (split /,/, $subjects);
-
- return "[" . (join ", ", @array). "]";
-}
-1;
diff --git a/plugin/timezone.pm b/plugin/timezone.pm
deleted file mode 100644
index 8807d54..0000000
--- a/plugin/timezone.pm
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/usr/bin/env perl
-
-package plugin::timezone;
-
-use strict;
-use warnings;
-
-use DateTime;
-
-my %config;
-
-sub configure {
- my $self = $_[0];
- my $cmdref = $_[1];
- my $cref = $_[2];
- %config = %$cref;
-
- $cmdref->("time", sub { $self->time(@_); } );
-
- return $self;
-}
-
-sub time {
- my ($self, $logger, $who, $where, $rest, @arguments) = @_;
-
- my $requester = ( split /!/, $who)[0];
- my @known_zones = (keys %{$config{timezone}});
-
- return "Syntax: time [nick]" unless @arguments == 1;
-
- my $nick = $arguments[0];
- if (grep {$_ eq $nick} @known_zones) {
- my $d = DateTime->now();
- $d->set_time_zone($config{timezone}->{$nick});
- return "$requester: $nick\'s clock reads $d";
- } else {
- return "$requester: I don't know what timezone $nick is in";
- }
-}
-1;
diff --git a/plugin/tittilate.pm b/plugin/tittilate.pm
deleted file mode 100644
index 4df6b07..0000000
--- a/plugin/tittilate.pm
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/usr/bin/env perl
-
-package plugin::tittilate;
-
-use strict;
-use warnings;
-
-my %config;
-
-sub configure {
- my $self = $_[0];
- my $cmdref = $_[1];
- my $cref = $_[2];
- %config = %$cref;
- return $self;
-}
-
-sub message {
- my ($self, $logger, $me, $who, $where, $raw_what, $what, $irc) = @_;
- my $gathered = "";
- my @expressions = (keys %{$config{triggers}});
- my $expression = join '|', @expressions;
- while ($what =~ /($expression)/gi) {
- my $matched = $1;
- my $key;
- # figure out which key matched
- foreach (@expressions) {
- if ($matched =~ /$_/i) {
- $key = $_;
- last;
- }
- }
- $gathered .= $config{triggers}->{$key};
- }
- return $gathered;
-}
-1;
diff --git a/plugin/url_title.pm b/plugin/url_title.pm
deleted file mode 100644
index 32995fd..0000000
--- a/plugin/url_title.pm
+++ /dev/null
@@ -1,67 +0,0 @@
-#!/usr/bin/env perl
-
-package plugin::url_title;
-
-use strict;
-use warnings;
-use HTTP::Tiny;
-use HTML::HeadParser;
-use utf8;
-
-my %config;
-
-sub configure {
- my $self = $_[0];
- my $cmdref = $_[1];
- my $cref = $_[2];
- %config = %$cref;
- return $self;
-}
-
-sub message
-{
- my ($self, $logger, $me, $who, $where, $raw_what, $what, $irc) = @_;
- my $url;
-
- return if ($config{url_on} == 0);
-
- if ($what =~ /(https?:\/\/[^ ]+)/i) {
- $url = $1;
- }
- return unless $url;
-
- my $http = HTTP::Tiny->new((default_headers => {'Range' => "bytes=0-65536", 'Accept' => 'text/html'}, timeout => 3));
-
- my $response = $http->get($url);
-
- if (!$response->{success}) {
- $logger->("Something broke: $response->{reason}");
- return;
- }
-
- if (!($response->{headers}->{"content-type"} =~ m,text/html ?,)) {
- $logger->("Not html, giving up now");
- return;
- }
-
- my $html = $response->{content};
-
- my $parser = HTML::HeadParser->new;
- $parser->parse($html);
-
- # get title and unpack from utf8 (assumption)
- my $title = $parser->header("title");
- utf8::upgrade($title);
- return unless $title;
-
- my $shorturl = $url;
- $shorturl = (substr $url, 0, $config{url_len}) . "…" if length ($url) > $config{url_len};
-
- # remove http(s):// to avoid triggering other poorly configured bots
- $shorturl =~ s,^https?://,,g;
- $shorturl =~ s,/$,,g;
-
- my $composed_title = "$title ($shorturl)";
- return $composed_title;
-}
-1;