use Gaim;
%PLUGIN_INFO = (
perl_api_version => 2,
name => "Twitter Away Message",
version => "0.1",
summary => "Set Your Away Message To The Latest Twitter Update",
description => "This plugin sets your last Twitter update to your away message.",
author => "Michael Goffin <mgoffin\@gmail.com",
url => "http://www.mjxg.com",
load => "plugin_load",
unload => "plugin_unload"
);
sub plugin_init {
return %PLUGIN_INFO;
}
sub plugin_load {
$plugin = shift;
my $protocol = "prpl-oscar";
# This finds the last Twitter update that you made
# NEED TO ADD CODE FOR ACQUIRING TWITTER UPDATE
# (for now we're setting this statically)
$last_update = "This is the last update";
# This should be changed to the account which you want
# to change the away message
my $account_name = "test";
# This is how we get an account to use in the following tests.
# You should replace the username with an existing user which is set above
$account = Gaim::Accounts::find($account_name, $protocol);
# An away message titled "Twitter" must be created in Gaim
# before it can find it
$status = Gaim::SavedStatus::find("Twitter");
# This sets the away message to your last update
$status -> set_message($last_update);
$status->activate();
# Schedule a timeout for 300 seconds from now (5 minutes)
# (for testing we're setting for 10 seconds)
Gaim::timeout_add($plugin, 10, \&timeout_cb, $plugin);
}
sub timeout_cb {
my $plugin = shift;
Gaim::Debug::info("Twitter Plugin", "Timeout occurred.\n");
# Reschedule timeout (should match what you're scheduling above)
Gaim::timeout_add($plugin, 10, \&timeout_cb, $plugin);
}
sub plugin_unload {
my $plugin = shift;
Gaim::Debug::info("Twitter Plugin", "plugin_unload() - Twitter Plugin Unloaded.\n");
}