mangle

From OpenKore Wiki
Revision as of 23:24, 17 February 2013 by KeplerBR (talk | contribs) (Created page with '== About the mangle == Mangle is the system of hooks, used in plugin, in packages that sends and receives by OpenKore. Check whether the message with the specified message ID…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

About the mangle

Mangle is the system of hooks, used in plugin, in packages that sends and receives by OpenKore. Check whether the message with the specified message ID will be mangled. If the bot is running in XKore mode, then messages that will be mangled will not be sent to the RO client.

Hooks

By default, a message will never be mangled. Plugins can register mangling procedures though. This is done by using the following hooks:

Command Description Example
Network::Receive/willMangle This hook has arguments 'messageID' (Bytes) and 'name' (String).

'name' is a human-readable description of the message, and may be undef. Plugins should set the 'return' argument to 1 if they want willMangle() to return 1.

Plugins::addHook("Network::Receive/willMangle", \&willMangle);
sub willMangle {
   my (undef, $args) = @_;
   if ($args->{messageID} eq '008A') {
       $args->{willMangle} = 1;
   }
}
Network::Receive/mangle This hook has arguments 'messageArgs' and 'messageName' (the latter may be undef).
Plugins::addHook("Network::Receive/mangle", \&mangle);
sub mangle {
    my (undef, $args) = @_;
    my $message_args = $args->{messageArgs};
    if ($message_args->{switch} eq '008A') {
        ...Modify $message_args as necessary....
    }
}

You can also mangle packets by defining $args->{mangle} in other plugin hooks. The options avalable are:

Options Description
0 No mangle
1 Mangle (change packet and reconstruct)
2 Drop

The following example will drop all public chat messages:

Plugins::addHook("packet_pre/public_chat", \&mangleChat);

sub mangleChat {
       my(undef, $args) = @_;
       $args->{mangle} = 2;
}