From ef846df2ca53a4832638f2fe280adb2837ed16f5 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Fri, 3 Jun 2016 23:28:57 +0200 Subject: first simple version works now --- plugin/blinkyfications.pl | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/plugin/blinkyfications.pl b/plugin/blinkyfications.pl index aa068d3..d5d14c4 100644 --- a/plugin/blinkyfications.pl +++ b/plugin/blinkyfications.pl @@ -47,8 +47,8 @@ sub plugin_load { # Signals/Callbacks my $conv_handle = Purple::Conversations::get_handle(); - Purple::Signal::connect($conv_handle, "received-im-msg", $plugin, \&received_msg_cb, $plugin); -# Purple::Signal::connect($conv_handle, "received-chat-msg", $plugin, \&received_msg_cb, $plugin); + Purple::Signal::connect($conv_handle, "received-im-msg", $plugin, \&received_msg_cb, "im"); + Purple::Signal::connect($conv_handle, "received-chat-msg", $plugin, \&received_msg_cb, "chat"); } sub plugin_unload { @@ -68,23 +68,17 @@ sub prefs_info_cb { } sub received_msg_cb { - my ($account, $sender, $message, $conv, $flags, $plugin) = @_; - Purple::Debug::misc("blinkyfications", $account->get_username() . ": $sender says '$message'\n"); + my ($account, $sender, $message, $conv, $flags, $type) = @_; +# Purple::Debug::misc("blinkyfications", $account->get_username() . ": $sender says '$message'\n"); my $device = Purple::Prefs::get_string("/plugins/core/blinkyfications/device"); open(my $fh, '>', $device) or return Purple::Debug::error("blinkyfications", "can't open device: " . $device .": " . $! . "\n"); - print $fh "r"; - close $fh; - Purple::timeout_add($plugin, 0.3, \&timeout_cb, $plugin); - return 0; -} - -sub timeout_cb { - my $plugin = shift; - - my $device = Purple::Prefs::get_string("/plugins/core/blinkyfications/device"); - open(my $fh, '>', $device) or return Purple::Debug::error("blinkyfications", "can't open device: " . $device .": " . $! . "\n"); - print $fh "0"; + if($type eq "im") { + print $fh "."; + } else { + print $fh "R"; + } close $fh; + return 0; } -- cgit v1.2.3