diff --git a/compose.yaml b/compose.yaml index 2bd78f2..898c72c 100644 --- a/compose.yaml +++ b/compose.yaml @@ -328,6 +328,21 @@ services: limits: memory: 1.5G + huggable: + image: postmodern.alexdaniel.org/whateverable:latest + command: ake start:huggable + volumes: + - /home/whateverable/data/huggable:/srv/data/huggable + secrets: + - config + networks: + - caddy + deploy: + replicas: 1 + resources: + limits: + memory: 1.5G + sourceable: image: postmodern.alexdaniel.org/whateverable:latest command: ake start:sourceable diff --git a/xbin/Huggable.p6 b/xbin/Huggable.p6 new file mode 100755 index 0000000..cc58c0d --- /dev/null +++ b/xbin/Huggable.p6 @@ -0,0 +1,30 @@ +use Whateverable; +use IRC::Client; + +unit class Huggable does Whateverable + +#| .hug +#| .hug ... +#| hugs the sender if no nick is provided +method irc-privmsg-channel ($msg where / [\s|^] '.hug' [\s|$] /) { + my $idx = $msg.text.index('.hug') + 4; + my $nicks = $msg.text.substr($idx).trim || $msg.nick; + $.irc.send: :where($msg.channel), :text("hugs " ~ $nicks); +} + +#| huggable6: hug +#| huggable6: hug ... +#| hugs the sender if no nick is provided +multi method irc-to-me($msg where / [\s|^] 'hug' [\s|$] /) { + my $idx = $msg.text.index('hug') + 3; + my $nicks = $msg.text.substr($idx).trim || $msg.nick; + $.irc.send: :where($msg.channel), :text("hugs " ~ $nicks); +} + +#| huggable6: ... +multi method irc-to-me($msg) { + $.irc.send: :where($msg.channel), :text("hugs " ~ $msg.text); +} + +Huggable.new.selfrun: 'huggable6', [/ huggable6? /, +fuzzy-nick('huggable6', 2)] diff --git a/xt/huggable.t b/xt/huggable.t new file mode 100644 index 0000000..93c63e9 --- /dev/null +++ b/xt/huggable.t @@ -0,0 +1,52 @@ +#!/usr/bin/env perl6 + +BEGIN %*ENV = 1; +%*ENV = 1; + +use lib ; +use Test; +use Testable; +use IRC::Client; + +my $t = Huggable.new: bot => 'Huggable'; + +$t.common-tests: help => 'Like this: .hug '; + +#| .hug +#| .hug +$t.test('.hug', + 'hug', + "hugs {$t.our-nick}"); + +$t.test('.hug ', + '.hug sibl', + 'hugs sibl'); + +$t.test('.hug ', + '.hug everyone', + 'hugs everyone'); + +$t.test(' .hug ', + ' .hug ande', + "hugs ande"); + +#| huggable6: hug +#| huggable6: hug +$t.test('huggable6: hug', + "{$t.bot-nick}: hug", + "hugs {$t.our-nick}" + ); +$t.test('huggable6: hug everyone', + "{$t.bot-nick}: hug everyone", + 'hugs everyone' + ); + +#| huggable6: ... +$t.test('huggable6: sibl ande', + "{$t.bot-nick}: sibl ande", + 'hugs sibl ande' + ); + +$t.last-test; +done-testing; +END $t.end;