From: Andres S. <di...@us...> - 2005-04-05 19:53:09
|
Update of /cvsroot/tuxaator/tuxaator/Plugins/Talk In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16969/Plugins/Talk Modified Files: Plugin.pm Log Message: 1. restrict !say and !emote to level 3; 2. implemented randompath and ${user} for !plan Index: Plugin.pm =================================================================== RCS file: /cvsroot/tuxaator/tuxaator/Plugins/Talk/Plugin.pm,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Plugin.pm 30 Mar 2004 20:37:06 -0000 1.8 --- Plugin.pm 5 Apr 2005 19:52:59 -0000 1.9 *************** *** 5,8 **** --- 5,18 ---- use Data::Dumper; + sub random_of (@) { + $_[int rand @_] + } + + sub random_path ($) { + my ($set) = @_; + while ($set =~ s/\{([^{}]*\|[^{}]*)\}/random_of split m[\|], $1/ge) {} + return $set; + } + sub new { my $class = shift; *************** *** 38,42 **** {"action" => "do_say", "restricted" => 1, ! "level" => 2}, "!plan" => {"action" => "do_plan", --- 48,52 ---- {"action" => "do_say", "restricted" => 1, ! "level" => 3}, "!plan" => {"action" => "do_plan", *************** *** 46,50 **** {"action" => "do_emote", "restricted" => 1, ! "level" => 2}, ); --- 56,60 ---- {"action" => "do_emote", "restricted" => 1, ! "level" => 3}, ); *************** *** 100,107 **** my @lines = <F>; close F; ! my $index = rand @lines; ! my $plan = $lines[$index]; ! $plan =~ s/\${msg}/$msg/; ! $res .= "3) " . $plan; # answer goes to the channel, otherwise it doesnt make too much sense $event->to(@{$event->to}[0]); --- 110,118 ---- my @lines = <F>; close F; ! chomp for @lines; ! my $plan = random_path random_of @lines; ! $plan =~ s/\${msg}/$msg/g; ! $plan =~ s/\${user}/$event->nick/ge; ! $res .= "3) $plan\n"; # answer goes to the channel, otherwise it doesnt make too much sense $event->to(@{$event->to}[0]); |