Browse Source

Mute and deafen the bot upon joining

This functionality was removed in f5c75f415da87a783c889a2fceed78a06ad2e0be
but the experimental audio feature isn't yet ready for use
Oliver Youle 2 years ago
parent
commit
a3cef01f4f
1 changed files with 40 additions and 0 deletions
  1. 40 0
      lib/MumbleBot/Event/Handler/MuteAndDeafenOnConnect.pm

+ 40 - 0
lib/MumbleBot/Event/Handler/MuteAndDeafenOnConnect.pm

@@ -0,0 +1,40 @@
+package MumbleBot::Event::Handler::MuteAndDeafenOnConnect;
+
+use Modern::Perl;
+
+use Moo;
+
+use MumbleBot::Event::Priority;
+
+with 'MumbleBot::Event::Handler';
+
+around BUILDARGS => sub {
+    my ($orig, $class, %args) = @_;
+
+    $args{event_type} = 'ServerSyncEvent';
+    $args{priority}   = MumbleBot::Event::Priority::LOW;
+
+    return $class->$orig(%args);
+};
+
+sub on_event {
+    my ($self, $event) = @_;
+
+    my $bot = MumbleBot->instance;
+
+    my $user = $bot->state->bot_user;
+    $user->is_deaf(1);
+    $user->is_mute(1);
+
+    $bot->client->send(
+        MumbleBot::Client::Packet->new(
+            type => MumbleBot::Client::Packet::Type::USER_STATE,
+            payload => {
+                self_mute => 1,
+                self_deaf => 1,
+            },
+        )
+    );
+}
+
+1;