Here's a plugin that will do it for you. Put it in the plugins directory for Gaim, restart Gaim, and then load it via Preferences -> Plugins. When talking to someone, if you send a message in the format of /send /path/to/file the contents of /path/to/file will be sent to them. If you wanted, you could also make the contents display in the IM window for you, but I'll leave that as an exercise to try out yourself.

This plugin uses the new Gaim Perl API, so make sure you have a pretty recent copy (I tested it on 0.74). Be aware that there are message size limits in AIM (and most other protocols) that this plugin does not take into account; you may get "Unable to send message" dialogs if the file contents are too big. If the file doesn't exist, this plugin leaves the message untouched (i.e. the user you're sending it to will see exactly what you typed).

Finally, to learn more about Gaim plugins, check out the examples in the source tree (downloadable from the website) and the API doc (online version is slightly outdated).

#!/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 se +nd 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 th +e # 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 <FH>; close FH; } } }

In reply to Re: Gaim to read from a file using Perl? by The Mad Hatter
in thread Gaim to read from a file using Perl? by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.