forked from beebop-Wiz/nethack-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
discord.pl
49 lines (39 loc) · 1.07 KB
/
discord.pl
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
use lib 'Mojo-Discord/lib';
use Mojo::Discord;
use strict;
my $discord_token = 'NO U';
my $discord_name = 'Rodney';
my $discord_url = "https://localhost";
my $discord_version = '1.0';
my $discord_callbacks = {'on_ready' => \&on_ready,
'on_message_create' => \&on_message_create};
my $discord = Mojo::Discord->new(
'token'=>$discord_token,
'name'=>$discord_name,
'url'=>$discord_url,
'version'=>$discord_version,
'callbacks'=>$discord_callbacks,
'reconnect'=>1,
'verbose'=>1
);
my $botinfo = {};
sub on_ready {
my ($hash) = @_;
$botinfo->{'username'} = $hash->{'user'}{'username'};
$botinfo->{'id'} = $hash->{'user'}{'id'};
$discord->status_update({'game' => 'NetHack 3.6.0'});
print "Connected\n";
}
sub on_message_create {
my ($hash) = @_;
my $msg = $hash->{'content'};
my $channel = $hash->{'channel_id'};
if($channel eq "416422458195705877") {
if($msg =~ /!gt (.)/) {
$discord->start_typing($channel);
$discord->send_message($channel, "Go Team $1!");
}
}
}
$discord->init();
sleep(-1);