Changeset 451
- Timestamp:
- 07/09/12 15:40:49 (12 years ago)
- Location:
- server/trunk/web/lib/Sophie/Controller
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
server/trunk/web/lib/Sophie/Controller/Chat.pm
r379 r451 102 102 return $c->go('/chat/cmd/' . $cmd, [ $reqspec, @args ]); 103 103 } else { 104 $c->stash->{xmlrpc} = { 105 error => 'No such command', 106 }; 104 return $c->forward('err_no_cmd', []); 107 105 } 106 } 107 108 =head2 err_no_cmd 109 110 Return the 'no such command error'. 111 112 =cut 113 114 sub err_no_cmd : Private { 115 my ($self, $c ) = @_; 116 return $c->stash->{xmlrpc} = { 117 error => 'No such command', 118 }; 108 119 } 109 120 -
server/trunk/web/lib/Sophie/Controller/Chat/Cmd.pm
r447 r451 18 18 =cut 19 19 20 my %hidden_functions; 21 22 # The given function will not be listed by help anymore 23 24 sub _hidden_functions { 25 my ($func) = @_; 26 27 $hidden_functions{$func} = 1; 28 } 29 30 my @to_list_functions; 31 32 # The given functions will be listed by help 33 34 sub _to_list_functions { 35 my ($func) = @_; 36 37 push(@to_list_functions, $func); 38 } 20 39 21 40 =head2 index … … 69 88 sub _commands { 70 89 my ( $self, $c ) = @_; 71 [ grep { m/^[^_]/ } map { $_->name } $self->get_action_methods() ]; 90 [ 91 sort { $a cmp $b } 92 grep { ! $hidden_functions{$_} } # Command to not list 93 # TODO: not hardcode list here 94 grep { m/^[^_]/ } 95 (map { $_->name } 96 $self->get_action_methods()), @to_list_functions ]; 72 97 } 73 98 … … 1314 1339 } 1315 1340 1341 _to_list_functions('try me'); 1342 1343 =head2 try me 1344 1345 Just try me 1346 1347 =head1 HIDDEN BOT FUNCTION 1348 1349 =cut 1350 1351 _hidden_functions('try'); 1352 1353 sub try : XMLRPC { 1354 my ($self, $c, $reqspec, @args) = @_; 1355 1356 if (($args[0] || '') eq 'me') { 1357 my %tryme = %{ $c->forward('/user/fetchdata', [ 'tryme' ]) || {} }; 1358 my @msgs = @{ $tryme{msgs} || []}; 1359 1360 if (@msgs) { 1361 return $c->stash->{xmlrpc} = { 1362 message => [ $msgs[rand(scalar(@msgs))] ], 1363 }; 1364 } else { 1365 return $c->stash->{xmlrpc} = { 1366 message => [ 'I don\'t know what you mean' ], 1367 }; 1368 } 1369 } else { 1370 return $c->stash->{xmlrpc} = $c->go('/chat/err_no_cmd', []); 1371 } 1372 } 1373 1316 1374 =head1 AUTHOR 1317 1375
Note: See TracChangeset
for help on using the changeset viewer.