koreGrowl - Growl notification support (Mac OS X) (8/26/08)

Other plugins for extending OpenKore's functionality. This forum is only for posting new plugins and commenting on existing plugins. For support, use the Support forum.

Moderator: Moderators

Message
Author
sli
Perl Monk
Perl Monk
Posts: 810
Joined: 04 Apr 2008, 17:26
Noob?: No

koreGrowl - Growl notification support (Mac OS X) (8/26/08)

#1 Post by sli »

UPDATE: This plugin now requires SVN revision 6464 or higher. So far there's no support for timeouts in Mac::Growl (that I know of), but for future ease the timeout setting is handled, anyway.

You need to install Mac::Growl for this plugin. (This plugin is also 100% untested! :roll:) See the koreSnarl thread for installation instructions and more information. (simply ignore the parts about Win32::Snarl.)

Code: Select all

####################################
# koreGrowl.pl: Written by sli     #
#                                  #
# This plugin adds support for the #
# Growl notification system.       #
####################################


package koreGrowl;

use Plugins;
use Globals;

use Mac::Growl ':all';
use utf8;

Plugins::register('koreGrowl','Adds support for the Growl notification system.', \&onUnload);
my $hooks = Plugins::addHooks(
	['start3', \&onLoad, undef],
	['packet_privMsg', \&onPrivMsg, undef],
	['base_level', \&onLevelUp, undef],
	['self_died', \&onDeath, undef],
	['job_level', \&onJLevelUp, undef],
	['pvp_mode', \&onPvpMode, undef],
	['avoidGM_near', \&onGm, undef],
	['avoidGM_talk', \&onGm, undef],
	['in_game', \&onInGame, undef],
	['item_gathered', \&onItemFound, undef],
	['map_loaded', \&onMapLoaded, undef]
);

my $cmd = Commands::register(
	["notify", "Triggers a Growl notification", \&cmdNotify],
);

my $dead = 0;
my @notifications = ("OpenKore Notice", "OpenKore Warning");

sub cmdNotify {
	my @args = @_;
	growlMessage($args[1], 0);
}

sub onLoad {
	if (!$timeout{notify}{timeout} && !$config{koreNotify_timeout}) {
		$timeout{notify}{timeout} = 5;
	} elsif (!$timeout{notify}{timeout} && $config{koreNotify_timeout}) {
		$timeout{notify}{timeout} = $config{koreNotify_timeout};
	}
	RegisterNotifications("OpenKore", \@notifications, \@notifications);
	growlMessage("koreGrowl loaded!", 0);
}

sub onPrivMsg {
	my @args = @_;
	growlMessage("From $args[1]{'privMsgUser'} : $args[1]{privMsg}", 1);
}

sub onLevelUp {
	@args = shift;
	growlMessage("$char->{name} has gained a level!", 0) unless ($args{name} ne $char->{name});
}

sub onJLevelUp {
	@args = shift;
	growlMessage("$char->{name} has gained a job level!", 0) unless ($args{name} ne $char->{name});
}

sub onDeath {
	growlMessage("$char->{name} has died!", 0) unless ($dead);
	$dead = 1;
}

sub onPvpMode {
	growlMessage("WARNING: $char->{name} has entered a PVP area!", 1);
}

sub onGm {
	my $ucname = uc($char->{name}) unless $ucname;
	growlMessage("WARNING: GM IS NEAR $ucname!", 1);
}

sub onInGame {
	growlMessage("$char->{name} is now in game.", 0);
}

sub onItemFound {
	my @args = @_;
	if ($config{koreNotify_items} =~ /$args[1]{item}/i) {
		growlMessage("$char->{name} has found a $args[1]{item}!", 0);
	}
}

sub onMapLoaded {
	# Prevents multiple notifications on death.
	$dead = 0;
}

sub growlMessage {
	$msg = shift;
	$type = shift;

	if ($config{koreNotify} == 1) {
		utf8::encode($msg);
		PostNotification("OpenKore", $notifications[$type], $notifications[$type], $msg, 0, 1, "openkore.png");
	}
}

sub onUnload {
	Plugins::delHooks($hooks);
	undef $ucname;
}

1;
cs : ee : realist

Alexander
Noob
Noob
Posts: 11
Joined: 29 May 2008, 12:00
Noob?: Yes

Re: koreGrowl - Growl notification support (Mac OS X) (8/26/08)

#2 Post by Alexander »

$notifications{$type} => $notifications[$type]

Works great other then that :D

sli
Perl Monk
Perl Monk
Posts: 810
Joined: 04 Apr 2008, 17:26
Noob?: No

Re: koreGrowl - Growl notification support (Mac OS X) (8/26/08)

#3 Post by sli »

Bump for bug fix.
cs : ee : realist

sli
Perl Monk
Perl Monk
Posts: 810
Joined: 04 Apr 2008, 17:26
Noob?: No

Re: koreGrowl - Growl notification support (Mac OS X) (8/26/08)

#4 Post by sli »

Whoops, death bug was even more broken. Fixed it for real this time.
cs : ee : realist

sli
Perl Monk
Perl Monk
Posts: 810
Joined: 04 Apr 2008, 17:26
Noob?: No

Re: koreGrowl - Growl notification support (Mac OS X) (8/26/08)

#5 Post by sli »

Bump, added the notify console command.
cs : ee : realist

Technology
Super Moderators
Super Moderators
Posts: 801
Joined: 06 May 2008, 12:47
Noob?: No

Re: koreGrowl - Growl notification support (Mac OS X) (8/26/08)

#6 Post by Technology »

One ST0 to rule them all? One PE viewer to find them!
One ST_kRO to bring them all and in the darkness bind them...

Mount Doom awaits us, fellowship of OpenKore!

MegaMangos
Noob
Noob
Posts: 1
Joined: 08 Sep 2017, 02:46
Noob?: Yes

Re: koreGrowl - Growl notification support (Mac OS X) (8/26/08)

#7 Post by MegaMangos »

I hate to bump this extremely old thread, but would anyone be able to help me get this working?
I have followed all the steps and installed Mac::Growl but it doesn't seem to work. I don't even get the RegisterNotifications onLoad after starting Openkore. Thank you.

Edit: Nevermind, I got it to work using Applescripts. Thank you for the great plugin!

Post Reply