Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # AntiGM
- # Author: otaku
- # License: GNU GPL v3
- #
- # OVERVIEW
- #
- # This is a plugin to avoid some common GM tests on the bRO server.
- # Sometimes the GM will talk to you through the system chat, sometimes through PMs
- # and sometimes he'll just speak through the public chat. Amongst other tests.
- # It identifies the GM and disconnects if he is talking to/testing you.
- #
- # * On the system chat it checks for your name on the message (as it happens on tests)
- #
- # CONFIG
- #
- # You must add to your control/config.txt de lines:
- #
- # antigm_relog <seconds>
- # antigm_warning <boolean>
- # antigm_reaction <option>
- # antigm_alarm <boolean>
- #
- # DETAILS
- #
- # antigm_relog: It will relog for <seconds> seconds if Openkore identifies the GM.
- # If the value of <seconds> is 0 or less, then Openkore will quit instead of relog.
- #
- # antigm_warning: If the value is 1, the bot will try to warn the other bots through
- # the bus system.
- #
- # antigm_reaction: This is the reaction the bot will take when another bot sends it
- # a bus message with a GM warning. The values of <option> can be:
- # 0 (It won't react to the message)
- # 1 (It reacts to the message ONLY if the GM is in the same map as him)
- # 2 (It reacts to the message regardless of the map)
- #
- # antigm_alarm: If set to 1 triggers an alarm sound when Openkore detects a GM.
- package AntiGM;
- use strict;
- use warnings;
- use encoding "utf8";
- use Log qw(warning message error);
- use Globals qw($char $bus $field %config @servers %statusHandle);
- use Misc qw(relog quit);
- use Misc;
- use Commands;
- use Utils::Win32;
- # GM name pattern (this is not related to Openkore's built-in pattern)
- my $gm_pattern = '^(\[GM\]|\[GE\]|\[LU\])';
- use constant {
- PLUGIN_NAME => "antiGM",
- DEFAULT_ENABLE => 1,
- RELOG_TAIME => 1200
- };
- Plugins::register(PLUGIN_NAME,'driblar os GMs do jogo',\&onUnload);
- my $hooks = Plugins::addHooks(
- ['start3', \&checkConfig, undef],
- ['packet/system_chat',\&handleSystemChat],
- ['packet/public_chat',\&handlePublicChat],
- ['packet/private_message',\&handlePrivateMessage],
- ['packet/actor_status_active',\&handleStripEvent],
- ['charNameUpdate',\&handleCharNameUpdate],
- ['initialized',\&setCallback],
- );
- my $debug_cmd = Commands::register(['antigm_emular','emula o avistamento de um GM',\&GMfound]);
- sub checkConfig {
- configModify('antigm_relog', (RELOG_TAIME+int(rand 500)));
- if (!exists($config{antigm_relog})) {
- configModify('antigm_warning', 1) if (!exists($config{antigm_warning}));
- configModify('antigm_reaction', 1) if (!exists($config{antigm_reaction}));
- configModify('antigm_alarm', 0) if (!exists($config{antigm_alarm}));
- configModify('antigm_enabled', 0) if (!$bus);
- } elsif ($config{antigm_enabled} = 0) {
- Plugins::unload(PLUGIN_NAME);
- }
- }
- sub setCallback {
- return unless $config{'antigm_warning'};
- if ($bus) {
- warning "[AntiGM] Registrando callback: handleBusMessage\n";
- $bus->onMessageReceived->add(undef, \&handleBusMessage);
- } else {
- error "[AntiGM] Bus está desativado!\n";
- error "[AntiGM] Não será possível enviar/receber mensagens para outros bots.\n";
- Plugins::unload(PLUGIN_NAME);
- }
- }
- sub onUnload {
- Plugins::delHooks($hooks);
- Commands::unregister($debug_cmd);
- error("[".PLUGIN_NAME."] Unloading plugin...\n");
- message "[".PLUGIN_NAME."] Plugin Unloaded\n";
- }
- sub handleSystemChat {
- my $message = $_[1]->{message};
- my $name = $char->{name};
- if (index($message,$name) != -1) {
- warning "[AntiGM] Situação suspeita encontrada.\n";
- GMfound('Meu nome apareceu na mensagem do sistema',$message);
- }
- }
- sub handlePublicChat {
- my $message = $_[1]->{message};
- if ($message =~ /$gm_pattern/) {
- warning "[AntiGM] Situação suspeita encontrada.\n";
- GMfound('O GM disse alguma coisa no chat publico',$message);
- }
- }
- sub handlePrivateMessage {
- my $nick = $_[1]->{privMsgUser};
- my $message = $_[1]->{privMsg};
- if ($nick =~ /$gm_pattern/) {
- warning "[AntiGM] Situação suspeita encontrada.\n";
- GMfound('O GM me mandou uma PM',$nick.": ".$message);
- }
- }
- sub handleStripEvent {
- my $args = $_[1];
- return if ($field->{name} eq "thor_v01");
- return if ($field->{name} eq "thor_v02");
- return if ($field->{name} eq "ra_san01");
- return if ($field->{name} eq "ra_san02");
- return if ($field->{name} eq "ra_san03");
- return if ($field->{name} eq "ra_san04");
- return if ($field->{name} eq "ra_san05");
- return if ($field->{name} eq "dew_dun02");
- return if ($field->{name} eq "comodo");
- return if ($field->{name} eq "cmd_fild01");
- if (defined($args->{actor}) && $args->{actor}->isa('Actor::You')) {
- my $type = $args->{type};
- my $status = defined $statusHandle{$type} ? $statusHandle{$type} : "UNKNOWN_STATUS_$type";
- if (
- $status eq "EFST_NOEQUIPSHIELD" || $status eq "EFST_NOEQUIPARMOR" || $status eq "EFST_NOEQUIPWEAPON" ||
- $status eq "EFST_NOEQUIPHELM" || $status eq "EFST_STRIPACCESSARY"
- ) {
- warning "[AntiGM] Situação suspeita encontrada.\n";
- GMfound('O GM removeu meus equipamentos');
- }
- }
- }
- sub handleBusMessage {
- my $msg = $_[2];
- if ($msg->{messageID} eq 'antigm' && $msg->{args}{server} eq $servers[$config{server}]{name}) {
- if ($config{antigm_reaction} == 2) {
- warning "[AntiGM] ".$msg->{args}{bot_name}." me avisou que há GMs online.\n";
- GMreaction('Avisado através do Bus pelo o bot '. $msg->{args}{bot_name});
- return;
- }
- if ($config{antigm_reaction} == 1 && $msg->{args}{map_name} eq $field->baseName()) {
- warning "[AntiGM] ".$msg->{args}{bot_name}." me avisou que há GMs nesse mapa.\n";
- GMreaction('Avisado através do Bus pelo o bot '. $msg->{args}{bot_name});
- return;
- }
- warning "[AntiGM] ".$msg->{args}{bot_name}." avistou um GM em ". $msg->{args}{map_name} ." no servidor ". $msg->{args}{server} ."\n";
- }
- }
- sub GMfound {
- return if ($field->{name} eq "moc_para01");
- return if ($field->{name} eq "prontera");
- return if ($field->{name} eq "geffen_in");
- return if ($field->{name} eq "geffen");
- my ($reason,$log) = @_;
- # Warn other bots through the bus system
- if ($config{'antigm_warning'}) {
- if (!$bus) {
- error "[AntiGM] Não foi possível avisar os outros bots.\n";
- error "[AntiGM] O bus está desativado.\n";
- } else {
- warning "[AntiGM] Enviando informação para o bus para avisar outros bots.\n";
- $bus->send('antigm', {
- map_name => $field->baseName(),
- server => $servers[$config{server}]{name},
- bot_name => $char->{name}
- });
- }
- }
- if ($config{antigm_alarm}) {
- my $filepath;
- $filepath = "plugins/antigm.wav" if (-e "plugins/antigm.wav");
- $filepath = "plugins/antigm/antigm.wav" if (-e "plugins/antigm/antigm.wav");
- if ($filepath) {
- Utils::Win32::playSound($filepath);
- } else {
- error "[AntiGM] Sound file not found!\n";
- }
- }
- GMreaction($reason,$log);
- }
- sub handleCharNameUpdate {
- my @gm_ids = (100000, 100040, 103680, 103681, 103682, 103683, 103684, 103685, 103686, 103687, 103688, 103689, 103690, 1909615,
- 1909616, 1909617, 1909619, 1909620, 4616699, 2256720, 2256718, 3114920, 3114931, 3114932, 3114933, 3114934, 3114935, 3114936, 3114937,
- 3114938, 3114939, 3114930, 3117268, 3125310, 3125311, 3125312, 3125313, 3125314, 3125315, 3146303, 3155450, 3155451, 3155452, 3155453,
- 3155454, 3155455, 3178839, 3201057, 3360650, 3360651, 3360652, 3360653, 3360654, 3360655, 3430014, 3586075, 3586076, 3586077, 3586078,
- 3586079, 3586080, 3586081, 3586082, 3586083, 3586084, 3586085, 3656290, 3656291, 3656292, 3656293, 3656294, 3656295, 3665242, 3792576,
- 3905114, 4474231, 4474239, 4474249, 4474299, 4474326, 4474339, 4560441, 799190, 799191, 799192, 799193, 799194, 799195, 799196, 799197,
- 799198, 799199, 799200, 799201, 799202, 799203, 799204, 799205, 4616686, 4616687, 4616688, 4616689, 4616690, 4616691, 4616670, 4616671,
- 4616673, 4616674, 4616675, 4616676, 4616678, 4616720, 4616679, 4616680, 4616681, 4616682, 4616683, 4616684, 3334531, 4655431, 4657513,
- 4657510, 4657511, 4657512, 4657514, 4657515, 4657516, 4657517, 4657518, 4657519, 4657520);
- my $args = $_[1];
- my $targetAccountId = $args->{player}{nameID};
- if($targetAccountId ~~ @gm_ids) {
- warning "[AntiGM] Situação suspeita encontrada.\n";
- GMfound('O GM ('.$args->{player}{nameID}.') '.$args->{player}{name}.' apareceu na tela');
- }
- }
- sub GMreaction {
- my ($reason,$log) = @_;
- open(FH,'>>:utf8',$Settings::logs_folder.'/antigm_log.txt');
- print FH "================================================================\n";
- print FH "Conta: ". $config{username} ."\n";
- print FH "Personagem: ". $char->{name} ."\n";
- print FH "Mapa: ". $field->baseName() ."\t\tData: ". timeFormat() ."\n";
- print FH "Motivo: ". $reason ."\n";
- print FH "Mensagem que disparou a ação: ". $log ."\n" if (defined($log) && $log ne "");
- close(FH);
- if ($config{antigm_relog} > 0) {
- relog($config{antigm_relog});
- } else {
- relog();
- quit();
- }
- }
- sub timeFormat {
- my ($seg,$min,$hora,$dia,$mes,$ano,$resto) = localtime();
- return sprintf("%02d/%02d/%04d %02d:%02d:%02d",$dia,$mes+1,$ano+1900,$hora,$min,$seg);
- }
- 1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement