comparison plugins/fortuneprofile.pl @ 6519:7f0fffa1077b

[gaim-migrate @ 7036] Updated the fortune profile script for the new perl API. It doesn't work yet, but it will once I implement some new functions. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Wed, 20 Aug 2003 09:33:56 +0000
parents e8204ffce9f8
children e4e87ffd9f14
comparison
equal deleted inserted replaced
6518:3f8880ea7856 6519:7f0fffa1077b
18 # Changes: 18 # Changes:
19 # * Modified to work with the changed perl interface of gaim 0.60 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 20 # * Fixed a bug where your info would be set to nothing if you had
21 # no pre and no post message 21 # no pre and no post message
22 # AIM: lbdash 22 # AIM: lbdash
23 #
24 # Updated by Christian Hammond, 20 August 2002
25 # Changes:
26 # * Modified to work with the changed perl interface of gaim 0.68
27 # AIM: ChipX86
23 28
24 # Copyright (C) 2001 Sean Egan 29 # Copyright (C) 2001 Sean Egan
25 30
26 # This program is free software; you can redistribute it and/or modify 31 # 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 32 # it under the terms of the GNU General Public License as published by
35 # 40 #
36 # You should have received a copy of the GNU General Public License 41 # You should have received a copy of the GNU General Public License
37 # along with this program; if not, write to the Free Software 42 # along with this program; if not, write to the Free Software
38 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 43 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
39 44
45 %PLUGIN_INFO = (
46 perl_api_version => 2,
47 name => "Fortune Profile",
48 version => "3.4",
49 summary => "Sets your AIM profile to a fortune (with a header and footer of your choice).",
50 description => "Sets your AIM profile to a fortune (with a header and footer of your choice).",
51 author => "Sean Egan <bj91704\@binghamton.edu>",
52 url => "http://gaim.sf.net/",
40 53
41 $handle = GAIM::register("Fortune Profile", "3.3", "", ""); 54 load => "plugin_load"
55 );
42 56
43 $tab = "&nbsp;"; 57 sub plugin_init {
44 $tab = $tab . $tab . $tab . $tab; 58 return %PLUGIN_INFO;
45 $nl = "<BR>";
46
47 $seconds = 30; # Delay before updating away messages.
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 } 59 }
61 60
62 $command = "fortune -sn " . ($max - $len); # Command to get dynamic message from 61 sub plugin_load {
62 my $plugin = shift;
63
64 $tab = "&nbsp;";
65 $tab = $tab . $tab . $tab . $tab;
66 $nl = "<BR>";
67
68 $seconds = 30; # Delay before updating away messages.
69 $max = 1020; # Max length of an profile. It should be
70 # 1024, but I am being safe
71 $pre_message = ""; # This gets added before the fortune
72
73 $post_message ="";
74
75 $len = 0;
76 if ($pre_message ne "") {
77 $len += length( $pre_message . "---$nl" );
78 }
79 if ($post_message ne "") {
80 $len += length("---$nl" . $post_message);
81 }
82
83 # Command to get dynamic message from
84 $command = "fortune -sn " . ($max - $len);
85
86 # output the first message and start the timers...
87 # This is done as a timeout to prevent attempts to set the
88 # profile before logging in.
89 Gaim::timeout_add($plugin, $seconds, "update_away");
90 }
63 91
64 sub update_away { 92 sub update_away {
65 # The fortunes are expanded into HTML (the tabs and newlines) which 93 # 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 94 # 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). 95 # will loop until it gets a fortune of a good size (after expansion).
68 96
69 do { 97 do {
70 do { #It's a while loop because it doesn't always work for some reason 98 do { #It's a while loop because it doesn't always work for some reason
71 $fortune = `$command`; 99 $fortune = `$command`;
72 if ($? == -1) { 100 if ($? == -1) {
73 return; 101 return;
87 115
88 foreach $id (GAIM::get_info(1)) {GAIM::command("info", $id, $message);} 116 foreach $id (GAIM::get_info(1)) {GAIM::command("info", $id, $message);}
89 GAIM::add_timeout_handler($handle, $seconds, "update_away"); 117 GAIM::add_timeout_handler($handle, $seconds, "update_away");
90 } 118 }
91 119
92 sub description {
93 my($a, $b, $c, $d, $e, $f) = @_;
94 ("Fortune Profile", "3.3", "Sets your AIM profile to a fortune (with a header and footer of your choice).",
95 "Sean Egan <bj91704\@binghamton.edu>", "http://gaim.sf.net/",
96 "/dev/null");
97 }
98 120
99 # output the first message and start the timers...
100 # This is done as a timeout to prevent attempts to set the profile before logging in.
101 GAIM::add_timeout_handler($handle, $seconds, "update_away");