1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
#!/usr/bin/env raku
use v6.d;
use IRC::Client;
use IRC::Client::Plugin;
use Log;
use Log::Level;
use Number::Denominate;
sub MAIN()
{
# Configure Log
$Log::instance = (require ::($*ENV<RAKU_LOG_CLASS> // 'Log::Colored')).new;
$Log::instance.add-output($*OUT, %*ENV<RAKU_LOG_LEVEL> // Log::Level::Debug);
# Start the IRC client
my $bot = IRC::Client.new(
#host => 'chat.freenode.net',
#port => 6697,
#ssl => True,
host => '127.0.0.1',
port => 6667,
ssl => False,
nicks => <tyil_ircbot tyiltest>,
channels => <##t #test>,
plugins => [
class _ is IRC::Client::Plugin {
multi method irc-to-me ($ where * eq 'uptime') {
denominate now - INIT now;
}
multi method irc-to-me ($event where { $_.nickname eq 'tyil' && $_ eq 'prefix' }) {
$event.irc.prefix;
}
multi method irc-to-me ($event where { $_.nickname eq 'tyil' && $_ eq 'chanlist' }) {
$event.irc.channels.join(', ')
}
multi method irc-to-me ($event where { $_.nickname eq 'tyil' && $_.words[0] eq 'join'}) {
my $channel = $event.words[1];
$event.reply("Joining $channel");
$event.irc.join($channel);
}
multi method irc-to-me ($event where { $_.nickname eq 'tyil' && $_.words[0] eq 'part'}) {
my $channel = $event.words[1];
$event.reply("Parting $channel");
$event.irc.part($channel);
}
multi method irc-mentioned ($) {
"Don't take my name in your filthy mouth, peasant"
}
multi method http-get(%payload) {
dd %payload<body>;
%payload<irc>.privmsg('#test', 'hello there');
}
multi method http-post(%payload) {
%payload<irc>.privmsg('#test', %payload<body><this>);
}
},
],
);
$bot.start;
}
|