From 5702360d5bf118789bcbe0d13b8d616642ca3f31 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Fri, 3 Jun 2016 03:30:56 +0200 Subject: first prototype is working --- plugin/blinkyfications.pl | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/plugin/blinkyfications.pl b/plugin/blinkyfications.pl index a4fd2a5..aa068d3 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, "im"); - Purple::Signal::connect($conv_handle, "received-chat-msg", $plugin, \&received_msg_cb, "chat"); + 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); } sub plugin_unload { @@ -68,7 +68,23 @@ sub prefs_info_cb { } sub received_msg_cb { - my ($account, $sender, $message, $conv, $flags, $type) = @_; - Purple::Debug::misc("blinkyfications", "$data (" . $account->get_username() . ", $sender, $message, $flags)\n"); - return 0 + my ($account, $sender, $message, $conv, $flags, $plugin) = @_; + 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"; + close $fh; } -- cgit v1.2.3