aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Spek <p.spek@tyil.nl>2019-03-28 16:42:59 +0100
committerPatrick Spek <p.spek@tyil.nl>2019-03-28 16:42:59 +0100
commitb1c7b35f75d76dc6f2b2e4f964421982c05bf152 (patch)
tree4a5b71817766655ef6a7a98f56aedf91ba3bf538
parent713bda3e38e292ca4ab9a98d5b6eaaa7ede02ef5 (diff)
downloadApp::CPAN::UploadNotifier::IRC-b1c7b35f75d76dc6f2b2e4f964421982c05bf152.tar.gz
App::CPAN::UploadNotifier::IRC-b1c7b35f75d76dc6f2b2e4f964421982c05bf152.tar.bz2
Update the response on .bots
-rw-r--r--CHANGELOG.md5
-rw-r--r--Dockerfile3
-rw-r--r--lib/App/CPAN/UploadAnnouncer/IRC.pm61
-rw-r--r--lib/App/CPAN/UploadAnnouncer/IRC/Social.pm616
4 files changed, 21 insertions, 4 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 93fe06b..6d3f478 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic
Versioning](http://semver.org/spec/v2.0.0.html).
+## [1.1.0] - [UNRELEASD]
+- The bot's version is now reported on a `.bots` command. Additionally, the
+ date the Docker image containing the bot was build is also included, if
+ available.
+
## [1.0.1] - 2019-03-28
- The bot now reports it's sources based on the `source-url` from `META6.json`.
diff --git a/Dockerfile b/Dockerfile
index 27a07c1..530baef 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -24,4 +24,7 @@ RUN apt update && apt install -y libssl-dev postgresql-client
COPY --from=install /app /app
COPY --from=install /usr/local /usr/local
+RUN mkdir -p /var/docker/meta
+RUN date "+%FT%TZ" > /var/docker/meta/build-date
+
CMD [ "perl6", "bin/bot" ]
diff --git a/lib/App/CPAN/UploadAnnouncer/IRC.pm6 b/lib/App/CPAN/UploadAnnouncer/IRC.pm6
index e9462d4..bc5e5e5 100644
--- a/lib/App/CPAN/UploadAnnouncer/IRC.pm6
+++ b/lib/App/CPAN/UploadAnnouncer/IRC.pm6
@@ -93,6 +93,7 @@ sub MAIN (
@plugins.append: App::CPAN::UploadAnnouncer::IRC::Social.new(
:source-url(%meta<source-url>),
+ :version(%meta<version>),
);
if ($nickserv-user && $nickserv-pass) {
diff --git a/lib/App/CPAN/UploadAnnouncer/IRC/Social.pm6 b/lib/App/CPAN/UploadAnnouncer/IRC/Social.pm6
index 1b48e06..6d0e134 100644
--- a/lib/App/CPAN/UploadAnnouncer/IRC/Social.pm6
+++ b/lib/App/CPAN/UploadAnnouncer/IRC/Social.pm6
@@ -23,6 +23,9 @@ unit class App::CPAN::UploadAnnouncer::IRC::Social does IRC::Client::Plugin;
#| The URL to report on a .bots command.
has $.source-url;
+#| The version number to report on a .bots command.
+has $.version;
+
#| This method gets triggered whenever a message is sent to a channel.
multi method irc-privmsg-channel (
#| The IRC event that triggered the method.
@@ -46,11 +49,16 @@ method !report (
IRC::Client::Message:D $e
) {
my $current-nick = $e.server.current-nick;
+ my $build-date = "/var/docker/meta/build-date".IO;
+ my $text;
+
+ $text ~= ircstyle($current-nick, :green);
+ $text ~= ":" ~ ircstyle($!version, :light_blue);
+ $text ~= " ({DateTime.new($build-date.slurp.trim)})" if $build-date.f;
+ $text ~= " reporting for duty! [Perl 6] ";
+ $text ~= ircstyle($!source-url, :blue, :underline);
- $e.irc.send(
- :where($e.channel),
- :text(ircstyle($current-nick, :green) ~ " reporting for duty! [Perl 6] " ~ ircstyle($!source-url, :blue, :underline)),
- );
+ $e.irc.send(:where($e.channel), :$text);
}
=begin pod