Here are all the domains:
- msg - Private message received
- base - Base level gained
- job - Job level gained
- died - Bot has died
- pvp - Bot has entered a PVP area
- gm - A GM alert
- ingame - Your bot is now in game
- item - Your bot has found an item listed in koreTwitter_items
As for koreTwitter_direct and koreTwitter_reply, they control how tweets are sent. koreTwitter_direct takes priority, so you can't specify the same domain twice (to prevent retweets). These options contain a list of message domains that will be sent in a certain manner, specifically direct messages or @reply-style, respectively. Any domain not in this list will default to a normal tweet, unless of course it's in the ignore list. Below is a sample config that will direct message GM alerts, @reply deaths, base levels, and job levels, ignore the ingame domain, and use regular tweets for everything else.
Code: Select all
koreTwitter 1
koreTwitter_username ausername
koreTwitter_password somepass
koreTwitter_items Clip [1]
koreTwitter_owner sli
koreTwitter_direct gm
koreTwitter_reply died, base, job
koreTwitter_ignore ingame
This plugin sends status updates to Twitter must like koreSnarl/Growl displays notifications. It uses the same events. Handy for keeping track of your bot while you're out of the house. One of these days I'll add support for receiving commands via Twitter. If you use koreSnarl/Growl, I would suggest giving this a try. It maintains a sort of message persistence that you don't get with koreSnarl/Growl in that all information it displays remains accessible on Twitter, unlike koreSnarl/Growl where the information disappears after five seconds or so. If you're botting overnight, you'll miss a lot of information.
To using this plugin, you'll need to install Net::Twitter, which also requires JSON. Cpan handles it no problem (cpan> install Net::Twitter). h4rry84 has checked and Net::Twitter can be installed from PPM if you're using ActiveState.
Sample config:
Code: Select all
koreTwitter 1
koreTwitter_username twitterusername
koreTwitter_password twitterpassword
koreTwitter_items Soldier Skeleton Card, Verit Card
Code: Select all
#########################################
# koreTwitter.pl: Written by sli #
# #
# This plugin lets your bot post status #
# status updates to a Twitter account. #
# #
#########################################
package koreTwitter;
use Plugins;
use Globals qw($char %config %timeout);
use Settings;
use FindBin qw($RealBin);
use Net::Twitter;
Plugins::register('koreTwitter','Allows your bot to post status updates to Twitter.', \&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(
["tweet", "Posts a status update to Twitter.", \&cmdTweet],
);
our $dead = 0;
our $twit;
sub cmdTweet {
my @args = @_;
tweet($args[1]);
}
sub onLoad {
if (defined $config{koreTwitter_username} && defined $config{koreTwitter_password}) {
$twit = Net::Twitter->new(username=>$config{koreTwitter_username}, password=>$config{koreTwitter_password});
}
}
sub onPrivMsg {
my @args = @_;
tweet("From $args[1]{'privMsgUser'} : $args[1]{privMsg}", "msg");
}
sub onLevelUp {
@args = shift;
tweet("$char->{name} has gained a level!", "base") unless ($args{name} ne $char->{name});
}
sub onJLevelUp {
@args = shift;
tweet("$char->{name} has gained a job level!", "job") unless ($args{name} ne $char->{name});
}
sub onDeath {
tweet("$char->{name} has died!", "died") unless ($dead);
$dead = 1;
}
sub onPvpMode {
tweet("WARNING: $char->{name} has entered a PVP area!", "pvp");
}
sub onGm {
my $ucname = uc($char->{name}) unless $ucname;
tweet("WARNING: GM IS NEAR $ucname!", "gm");
}
sub onInGame {
tweet("$char->{name} is now in game.", "ingame");
}
sub onItemFound {
my @args = @_;
if ($config{koreTwitter_items} =~ /$args[1]{item}/i) {
tweet("$char->{name} has found a $args[1]{item}!", "item");
}
}
sub onMapChange {
# Prevents multiple notifications on death.
$dead = 0;
}
sub tweet {
my ($msg, $domain) = @_;
if ($config{koreTwitter} == 1) {
if (defined $config{koreTwitter_owner})
if ($config{koreTwitter_direct} =~ /$domain/i) {
$twit->update("d $config{koreTwitter_owner} $msg");
} elsif ($config{koreTwitter_reply} =~/$domain/i) {
$twit->update("@" . "$config{koreTwitter_owner}" . " $msg");
} else {
$twit->update($msg);
}
} else {
$twit->update($msg);
}
}
}
sub onUnload {
Plugins::delHooks($hooks);
undef $ucname;
}
1;