koreSnarl - Snarl notification support (Win32) (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

koreSnarl - Snarl notification support (Win32) (8/26/08)

#1 Post by sli »

UPDATE: Added the notify console command. Now you can trigger notifications from macros!

UPDATE: One bug to fix: if another player near you gains a level or job level, a notification is displayed for your character.

UPDATE: You can now set a timeout (notify in timeouts.txt or koreNotify_timeout in config.txt) to set how long notifications should be displayed. The default is 5 seconds. This timeout will be global for koreSnarl, koreGrowl (OS X), and koreMumbles (Linux). I've also changed config variable names to koreNotify_* to make them global for all notification plugins.

UPDATE: This plugin now requires SVN revision 6464 or higher.

UPDATE: Turns out Win32::Snarl is on CPAN, so go there to get a newer version. You still need to change "use Win32::GUI;" to "use Win32::GUI();" in that version, too. You must use this version to use the updated plugin. Also, koreSnarl now lets you define a list of items to alert on when found. And I added an on/off toggle.
------------------
Installation:
  1. Install Win32::GUI. Check the readme for a super easy install method. Chances are you'll want the 5.8 version as there's no public XSTools.dll for 5.10, yet. (I'd release mine, but it's over 5 megs :oops:)
  2. Install Win32::Snarl. Change "use Win32::GUI;" to "use Win32::GUI();" in this module before you restart OpenKore!
  3. Throw koreSnarl.pl into your plugins dir. (Be sure to check the config help at the bottom of this post as well.)
  4. If you want it, here's the openkore.png I use: Image
Here's koreSnarl.pl:

Code: Select all

####################################
# koreSnarl.pl: Written by sli     #
#                                  #
# This plugin adds support for the #
# Snarl notification system.       #
#                                  #
# Download Snarl from fullphat.net #
####################################


package koreSnarl;

use Plugins;
use Globals qw($char %config %timeout);
use Settings;
use FindBin qw($RealBin);

use Win32::Snarl;

Plugins::register('koreSnarl','Adds support for the Snarl 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],
	['Network::Receive::map_changed', \&onMapChange, undef]
);

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

my $dead = 0;

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

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};
	}
	snarlMessage('koreSnarl registered successfully with Snarl.');
}

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

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

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

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

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

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

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

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

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

sub snarlMessage {
	$msg = shift;
	if ($config{koreNotify} == 1) {
		Win32::Snarl::ShowMessage('OpenKore Notice', $msg, $timeout{notify}{timeout}, "$RealBin/openkore.png");
	}
}

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

1;
Configuration
The new version adds some configuration. But it's pretty simple. Here's mine:

Code: Select all

koreNotify 1
koreNotify_items Whisper Card, Soldier Skeleton Card
koreNotify_timeout 5
The first option is a simple toggle (1 = on, 0 = off). That second option holds a comma-separated list of items you'd like Kore to alert you about when your bot finds one. To disable, simply comment the line out, or don't set it to anything. As for the timeout in timeouts.txt (if you don't want to use koreNotify_timeout):

Code: Select all

notify 5
And that's it.
cs : ee : realist

kong
Noob
Noob
Posts: 4
Joined: 20 Aug 2008, 23:02
Noob?: No

Re: koreSnarl - Snarl notification support (Win32)

#2 Post by kong »

This is cool!

Thanks sli :mrgreen:

---------------
edited:

I have a question: where should I put "openkore.png" file?

---------------
edited again:

Alright, I found a way to do it. Supposed we put "openkore.png" in plugins folder, we have to change the code in koreSnarl.pl a little bit:

Code: Select all

use FindBin qw($RealBin);

sub snarlMessage {
   $msg = shift;
   my $iconPath = "$RealBin/plugins/openkore.png";
   $snarl->show_message('OpenKore Notice', $msg, 5, $iconPath);
}
By the way, the icon image should be a 128x128 PNG file. :)

kali
OpenKore Monk
OpenKore Monk
Posts: 457
Joined: 04 Apr 2008, 10:10

Re: koreSnarl - Snarl notification support (Win32)

#3 Post by kali »

sli, I thought you had SVN write access already? I'd suggest committing your plugin hooks so people using this plugin will find it easier. Besides, I'm thinking that those hooks can be used for other notification programs aside from yours :)
Got your topic trashed by a mod?

Trashing topics is one click, and moving a topic to its proper forum is a lot harder. You expend the least effort in deciding where to post, mods expend the least effort by trashing.

Have a nice day.

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

Re: koreSnarl - Snarl notification support (Win32)

#4 Post by sli »

Vivi bitches too much about new hooks so I don't even bother.

EDIT: Almost forgot, there's a new version coming soon. Adding in the whole... alert on item found thing.
EDIT2: Ok, new version's up.
kong wrote:

Code: Select all

use FindBin qw($RealBin);

sub snarlMessage {
   $msg = shift;
   my $iconPath = "$RealBin/plugins/openkore.png";
   $snarl->show_message('OpenKore Notice', $msg, 5, $iconPath);
}
By the way, the icon image should be a 128x128 PNG file. :)
I fixed this, too, but by default it just looks in Kore's root. That's easy to change. I added the image I use to the first post. Thanks for the code!
cs : ee : realist

iamanoob
Plain Yogurt
Plain Yogurt
Posts: 82
Joined: 04 Apr 2008, 09:49

Re: koreSnarl - Snarl notification support (Win32) (8/26/08)

#5 Post by iamanoob »

sli wrote:This plugin really isn't for the noobs.
sub focusKoreWindow {
if ($conState == 5) {
if ($config{$pos."_focus"}) {
my @windows = FindWindowLike(0,"$char->{name}");
foreach (@windows) {
SetForegroundWindow($_);
}
}
}
return;
}
is KoreSnall something like this?
or it produces a new window pane like Wx?
Image
DARKest Ninja

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

Re: koreSnarl - Snarl notification support (Win32) (8/26/08)

#6 Post by sli »

Neither. It does this using external software (Snarl):
Image

By the way, your sig is almost hypnotic if you take the time to just sit and watch it.
cs : ee : realist

Kilzone2
Noob
Noob
Posts: 6
Joined: 03 Jun 2008, 20:49
Noob?: No

Re: koreSnarl - Snarl notification support (Win32) (8/26/08)

#7 Post by Kilzone2 »

Pwnsome, but does this increase memory usage much? 8-)
Image

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

Re: koreSnarl - Snarl notification support (Win32) (8/26/08)

#8 Post by sli »

The plugin itself doesn't, but Snarl is current using 11.5 megs of memory on my machine (actually 11,444k).
cs : ee : realist

kali
OpenKore Monk
OpenKore Monk
Posts: 457
Joined: 04 Apr 2008, 10:10

Re: koreSnarl - Snarl notification support (Win32) (8/26/08)

#9 Post by kali »

Would you know if Snarl supports audio with the popups?
Got your topic trashed by a mod?

Trashing topics is one click, and moving a topic to its proper forum is a lot harder. You expend the least effort in deciding where to post, mods expend the least effort by trashing.

Have a nice day.

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

Re: koreSnarl - Snarl notification support (Win32) (8/26/08)

#10 Post by sli »

It doesn't. But there's already a plugin for that.
cs : ee : realist

Post Reply