aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Plugin/Admin.pm4
-rw-r--r--Plugin/Log.pm12
-rw-r--r--Plugin/Topic.pm44
-rwxr-xr-xidalius.pl16
4 files changed, 74 insertions, 2 deletions
diff --git a/Plugin/Admin.pm b/Plugin/Admin.pm
index ce43424..38d4993 100644
--- a/Plugin/Admin.pm
+++ b/Plugin/Admin.pm
@@ -28,7 +28,7 @@ sub configure {
$cmdref->($self, "part", sub { $self->part(@_); } );
$cmdref->($self, "mode", sub { $self->mode(@_); } );
$cmdref->($self, "kick", sub { $self->kick(@_); } );
- $cmdref->($self, "topic", sub { $self->topic(@_); } );
+ $cmdref->($self, "set topic", sub { $self->topic(@_); } );
$cmdref->($self, "reconnect", sub { $self->reconnect(@_); } );
$cmdref->($self, "ignore", sub { $self->ignore(@_); } );
@@ -168,7 +168,7 @@ sub topic {
my ($self, $irc, $logger, $who, $where, $ided, $rest, $no_reenter, @arguments) = @_;
return unless is_admin($logger, $who, $ided);
- return "Syntax: topic <new topic>" unless @arguments >= 2;
+ return "Syntax: set topic <new topic>" unless @arguments >= 2;
# Strip nick/channel from message
$rest =~ s/^(.*?\s)//;
diff --git a/Plugin/Log.pm b/Plugin/Log.pm
index dd092f5..542873c 100644
--- a/Plugin/Log.pm
+++ b/Plugin/Log.pm
@@ -156,6 +156,18 @@ sub on_ping {
return;
}
+sub on_331_rpl_notopic {
+ my ($self, $logger, $where, $irc) = @_;
+ $logger->("$t{bracket}\[$t{channel}$where$t{bracket}\]$t{info} --- topic is not set$t{reset}");
+ return;
+}
+
+sub on_332_rpl_topic {
+ my ($self, $logger, $where, $topic, $irc) = @_;
+ $logger->("$t{bracket}\[$t{channel}$where$t{bracket}\]$t{info} --- topic is $t{message}$topic$t{reset}");
+ return;
+}
+
sub on_372_motd_content {
my ($self, $logger, $server, $motd, $irc) = @_;
$logger->("$t{info}MOTD: $t{message}$motd$t{reset}");
diff --git a/Plugin/Topic.pm b/Plugin/Topic.pm
new file mode 100644
index 0000000..ce3c782
--- /dev/null
+++ b/Plugin/Topic.pm
@@ -0,0 +1,44 @@
+package Plugin::Topic;
+
+use strict;
+use warnings;
+
+my %channel_topics;
+
+sub configure {
+ my $self = shift;
+ my $cmdref = shift;
+ shift; # run_command
+
+ $cmdref->($self, "topic", sub { $self->topic(@_); } );
+
+ return $self;
+}
+
+sub topic {
+ my ($self, $irc, $logger, $who, $where, $ided, $rest, $no_reenter, @arguments) = @_;
+ $where = $where->[0] if ref($where) eq "ARRAY";
+
+ # use current channel unless one is specified
+ my $channel = @arguments ? $arguments[0] : $where;
+ return "Syntax: topic [channel]" unless $channel =~ m/^#.*$/;
+
+ my $topic = $channel_topics{$channel} || "(no topic)";
+ return "Topic for $channel: $topic";
+}
+
+sub on_topic {
+ my ($self, $logger, $who, $where, $topic, $irc) = @_;
+ $channel_topics{$where} = $topic;
+}
+
+sub on_331_rpl_notopic {
+ my ($self, $logger, $where, $irc) = @_;
+ delete $channel_topics{$where};
+}
+
+sub on_332_rpl_topic {
+ my ($self, $logger, $where, $topic, $irc) = @_;
+ $channel_topics{$where} = $topic;
+}
+1;
diff --git a/idalius.pl b/idalius.pl
index bd727ac..e62f090 100755
--- a/idalius.pl
+++ b/idalius.pl
@@ -64,6 +64,8 @@ POE::Session->create(
irc_254
irc_255
irc_302
+ irc_331
+ irc_332
irc_372
irc_375
irc_376
@@ -388,7 +390,21 @@ sub irc_255 {
return;
}
+# 331 (rpl_notopic)
+# Sent in response to topic query
+sub irc_331 {
+ my ($where) = $_[ARG1];
+ trigger_modules("331_rpl_notopic", undef, $where, [], ($where));
+ return;
+}
+# 332 (rpl_topic)
+# Sent in response to topic query
+sub irc_332 {
+ my ($where, $topic) = @{$_[ARG2]};
+ trigger_modules("332_rpl_topic", undef, undef, [], ($where, $topic));
+ return;
+}
# 372 (MOTD content)
sub irc_372 {