3706
|
1 # FORTUNE PROFILE
|
|
2 #
|
|
3 # Sets your AIM profile to a fortune (with a header and footer of your
|
|
4 # choice).
|
|
5 #
|
|
6
|
|
7 # By Sean Egan
|
|
8 # bj91704@binghamton.edu
|
|
9 # AIM: SeanEgn
|
|
10 #
|
|
11 # Updated by Nathan Conrad, 31 January 2002
|
|
12 # Changes:
|
|
13 # * Fortunes have HTML tabs and newlines
|
|
14 # AIM: t98502
|
|
15 # ICQ: 16106363
|
|
16 #
|
|
17 # Updated by Mark Doliner, 15 October 2002
|
|
18 # Changes:
|
|
19 # * Modified to work with the changed perl interface of gaim 0.60
|
|
20 # * Fixed a bug where your info would be set to nothing if you had
|
|
21 # no pre and no post message
|
|
22 # AIM: lbdash
|
|
23
|
|
24 # Copyright (C) 2001 Sean Egan
|
|
25
|
|
26 # This program is free software; you can redistribute it and/or modify
|
|
27 # it under the terms of the GNU General Public License as published by
|
|
28 # the Free Software Foundation; either version 2 of the License, or
|
|
29 # (at your option) any later version.
|
|
30 #
|
|
31 # This program is distributed in the hope that it will be useful,
|
|
32 # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
33 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
34 # GNU General Public License for more details.
|
|
35 #
|
|
36 # You should have received a copy of the GNU General Public License
|
|
37 # along with this program; if not, write to the Free Software
|
|
38 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
39
|
|
40
|
|
41 $handle = GAIM::register("Fortune Profile", "3.2", "", "");
|
|
42
|
|
43 $tab = " ";
|
|
44 $tab = $tab . $tab . $tab . $tab;
|
|
45 $nl = "<BR>";
|
|
46
|
4603
|
47 $seconds = 30; # Delay before updating away messages.
|
3706
|
48 $max = 1020; # Max length of an profile. It should be
|
|
49 # 1024, but I am being safe
|
|
50 $pre_message = ""; # This gets added before the fortune
|
|
51
|
|
52 $post_message ="";
|
|
53
|
|
54 $len = 0;
|
|
55 if ($pre_message ne "") {
|
|
56 $len += length( $pre_message . "---$nl" );
|
|
57 }
|
|
58 if ($post_message ne "") {
|
|
59 $len += length("---$nl" . $post_message);
|
|
60 }
|
|
61
|
|
62 $command = "fortune -sn " . ($max - $len); # Command to get dynamic message from
|
|
63
|
|
64 sub update_away {
|
|
65 # The fortunes are expanded into HTML (the tabs and newlines) which
|
|
66 # causes the -s option of fortune to be a little bit meaningless. This
|
|
67 # will loop until it gets a fortune of a good size (after expansion).
|
|
68
|
|
69 do {
|
|
70 do { #It's a while loop because it doesn't always work for some reason
|
|
71 $fortune = `$command`;
|
|
72 } while ($fortune eq "");
|
|
73 $fortune =~ s/\n/$nl/g;
|
|
74 $fortune =~ s/\t/$tab/g;
|
|
75 } while ((length($fortune) + $len ) > $max);
|
|
76
|
|
77 $message = $fortune;
|
|
78 if ($pre_message ne "") {
|
|
79 $message = $pre_message . "---$nl" . $message;
|
|
80 }
|
|
81 if ($post_message ne "") {
|
|
82 $message = $message . "---$nl" . $post_message ;
|
|
83 }
|
|
84
|
|
85 foreach $id (GAIM::get_info(1)) {GAIM::command("info", $id, $message);}
|
|
86 GAIM::add_timeout_handler($handle, $seconds, "update_away");
|
|
87 }
|
|
88
|
|
89 sub description {
|
|
90 my($a, $b, $c, $d, $e, $f) = @_;
|
|
91 ("Fortune Profile", "3.2", "Sets your AIM profile to a fortune (with a header and footer of your choice).",
|
|
92 "Sean Egan <bj91704\@binghamton.edu>", "http://gaim.sf.net/",
|
|
93 "/dev/null");
|
|
94 }
|
|
95
|
|
96 # output the first message and start the timers...
|
|
97 update_away();
|