Changeset b120bd3


Ignore:
Timestamp:
Sep 25, 2010, 5:58:38 PM (14 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, release-1.10, release-1.7, release-1.8, release-1.9
Children:
c8d9f84
Parents:
118c919
git-author:
Kevin Riggle <kevinr@free-dissociation.com> (09/21/10 00:33:56)
git-committer:
Nelson Elhage <nelhage@mit.edu> (09/25/10 17:58:38)
Message:
add a random zsig function
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • perl/lib/BarnOwl.pm

    r675a998 rb120bd3  
    561561}
    562562
     563=head3 random_zephyr_signature
     564
     565Retrieve a random line from ~/.zsigs (except those beginning with '#')
     566and use it as the zephyr signature.
     567
     568=cut
     569
     570sub random_zephyr_signature
     571{
     572    my $zsigfile = "$ENV{'HOME'}/.zsigs";
     573    open my $file, '<', $zsigfile or die "Error opening file $zsigfile: $!";
     574    my @lines = grep !(/^#/ || /^\s*$/), <$file>;
     575    close $file;
     576    return '' if !@lines;
     577    my $zsig = "$lines[int(rand(scalar @lines))]";
     578    chomp $zsig;
     579    return $zsig;
     580}
     581
    563582# Stub for owl::startup / BarnOwl::startup, so it isn't bound to the
    564583# startup command. This may be redefined in a user's configfile.
  • variable.c

    re488ec5 rb120bd3  
    214214                 "Called every time you start a zephyrgram without an\n"
    215215                 "explicit zsig.  The default setting implements the policy\n"
    216                  "described in the documentation for the 'zsig' variable.\n"),
     216                 "described in the documentation for the 'zsig' variable.\n"
     217                 "See also BarnOwl::random_zephyr_signature().\n"),
    217218
    218219  OWLVAR_STRING( "zsig" /* %OwlVarStub */, "",
Note: See TracChangeset for help on using the changeset viewer.