#!/usr/bin/perl use strict; use warnings; use Gaim; my $plugin; our %PLUGIN_INFO = ( perl_api_version => 2, name => "Send File", version => "0.1", summary => "Sends a file to a person in an IM.", description => "Sends a file to a person in an IM.\n\nJust send an IM to someone like: /send /some/filename", author => "Thomas Sibley", url => "http://trs.perlmonk.org/", load => "plugin_load", unload => "plugin_unload", ); sub plugin_init { return %PLUGIN_INFO; } sub plugin_load { $plugin = shift; # Set signal handlers # # This handler is called before the message is actually sent to the # receiver, but after the user has entered a message to send # Gaim::signal_connect(Gaim::Conversations::handle, "sending-im-msg", $plugin, \&message_handler, 0); return 1; } sub plugin_unload { return 1; } sub message_handler { # $_[2] is the message... modify it to change the message # strip HTML off very crudely $_[2] =~ s|]+>||g; if ($_[2] =~ m|^/send (.+)|) { if (open FH, '<', $1) { $_[2] = ""; # reset message text $_[2] .= $_ while ; close FH; } } }