summaryrefslogtreecommitdiff
path: root/boha.raku
diff options
context:
space:
mode:
Diffstat (limited to 'boha.raku')
-rw-r--r--boha.raku57
1 files changed, 11 insertions, 46 deletions
diff --git a/boha.raku b/boha.raku
index 20172c0..40ceb6b 100644
--- a/boha.raku
+++ b/boha.raku
@@ -2,65 +2,30 @@
use v6.d;
use Config::TOML;
use lib $?FILE.IO.sibling('lib').Str;
+use lib $?FILE.IO.parent(2).child('Red/lib').Str;
use Boha::TrackOps;
+use Boha::Karma;
use IRC::Client;
+use Red:api<2>;
my $config = from-toml(
file => (%*ENV<BOHA_CONFIG_FILE> // $?FILE.IO.sibling('boha.toml').Str)
);
-class TrackOps does IRC::Client::Plugin {
- has %!is-op;
+my $*RED-DEBUG=True;
- multi method is-op(
- Str() $server, Str() $channel, Str() $nick --> Bool
- ) {
- return %!is-op{$server}{$channel}{$nick}.so;
- }
- multi method is-op(IRC::Client::Message $e --> Bool) {
- fail 'not a channel message' unless $e.?channel;
- return self.is-op($e.server,$e.channel,$e.nick);
- }
-
- method !set-user-mode(
- Str() $server, Str() $channel, Str() $nick, Bool $mode
- ) {
- %!is-op{$server}{$channel}{$nick} = $mode;
- }
+red-defaults :boha['SQLite', :default];
- # response to /NAMES
- method irc-n353(IRC::Client::Message $e) {
- my $server = $e.server;
- my ($my-nick,$equal,$channel,$names) = $e.args();
+# if-not-exists?
+schema(Boha::KarmaEvent).create;
- for $names.split(/\s+/) -> $name-str {
- my $user = $name-str ~~ / ^ $<sigil> = [ '@' | '+' ]? $<nick> = [ .+ ] $ /;
+Boha::KarmaEvent.new-karma('dakkar',$_) for (1,-1,1,1);
+Boha::KarmaEvent.new-karma('boha',$_) for (-1,-1,-1,-1);
- self!set-user-mode(
- $server, $channel,
- $user<nick>,
- $user<sigil> eq '@'
- );
- }
+say Boha::KarmaEvent.current-karma();
- return $.NEXT;
- }
- method irc-mode-channel($e) {
- my ($server, $channel) = $e.server, $e.channel;
- my $new-mode = (
- $e.mode eq '+o' ?? True !!
- $e.mode eq '-o' ?? False !!
- return $.NEXT
- );
-
- for $e.nicks() -> $nick {
- self!set-user-mode($server,$channel,$nick,$new-mode);
- }
-
- return $.NEXT;
- }
-}
+=finish
class Boha1 does IRC::Client::Plugin {
has Boha::TrackOps $.ops handles <is-op>;