Last change
on this file since 72 was
72,
checked in by nanardon, 14 years ago
|
- always add user's config in Chat query
|
File size:
1.6 KB
|
Line | |
---|
1 | package Sophie::Controller::Chat; |
---|
2 | use Moose; |
---|
3 | use namespace::autoclean; |
---|
4 | use Getopt::Long; |
---|
5 | use Text::ParseWords; |
---|
6 | |
---|
7 | BEGIN {extends 'Catalyst::Controller'; } |
---|
8 | |
---|
9 | =head1 NAME |
---|
10 | |
---|
11 | Sophie::Controller::Chat - Catalyst Controller |
---|
12 | |
---|
13 | =head1 DESCRIPTION |
---|
14 | |
---|
15 | Catalyst Controller. |
---|
16 | |
---|
17 | =head1 METHODS |
---|
18 | |
---|
19 | =cut |
---|
20 | |
---|
21 | |
---|
22 | =head2 index |
---|
23 | |
---|
24 | =cut |
---|
25 | |
---|
26 | sub index :Path :Args(0) { |
---|
27 | my ( $self, $c ) = @_; |
---|
28 | |
---|
29 | |
---|
30 | } |
---|
31 | |
---|
32 | sub message : XMLRPC { |
---|
33 | my ($self, $c, $contexts, $message, @msgargs) = @_; |
---|
34 | |
---|
35 | my $reqspec = {}; |
---|
36 | my @contexts = grep { $_ } ( |
---|
37 | $c->user_exists |
---|
38 | ? ( 'default', |
---|
39 | (ref $contexts |
---|
40 | ? (@$contexts) |
---|
41 | : ($contexts) |
---|
42 | ), |
---|
43 | ) |
---|
44 | : () |
---|
45 | ); |
---|
46 | |
---|
47 | foreach my $co (@contexts) { |
---|
48 | if (ref($co) eq 'HASH') { |
---|
49 | foreach (keys %$co) { |
---|
50 | $reqspec->{$_} = $co->{$_}; |
---|
51 | } |
---|
52 | } else { |
---|
53 | if (my $coo = $c->forward('/user/fetchdata', [ $co ])) { |
---|
54 | foreach (keys %$coo) { |
---|
55 | $reqspec->{$_} = $coo->{$_}; |
---|
56 | } |
---|
57 | } |
---|
58 | } |
---|
59 | } |
---|
60 | |
---|
61 | my ($cmd, @args) = @msgargs |
---|
62 | ? ($message, @msgargs) |
---|
63 | : Text::ParseWords::shellwords($message); |
---|
64 | |
---|
65 | if ($c->get_action( $cmd, '/chat/cmd' )) { |
---|
66 | return $c->go('/chat/cmd/' . $cmd, [ $reqspec, @args ]); |
---|
67 | } else { |
---|
68 | $c->stash->{xmlrpc} = { |
---|
69 | error => 'No such command', |
---|
70 | }; |
---|
71 | } |
---|
72 | } |
---|
73 | |
---|
74 | =head1 AUTHOR |
---|
75 | |
---|
76 | Olivier Thauvin |
---|
77 | |
---|
78 | =head1 LICENSE |
---|
79 | |
---|
80 | This library is free software. You can redistribute it and/or modify |
---|
81 | it under the same terms as Perl itself. |
---|
82 | |
---|
83 | =cut |
---|
84 | |
---|
85 | __PACKAGE__->meta->make_immutable; |
---|
86 | |
---|
87 | 1; |
---|
Note: See
TracBrowser
for help on using the repository browser.