Software Freedom Law Center

root/trunk/antimatter/tim/Modules/SFLC/TimeTracker/Output/Question.pm

Revision 53, 2.5 kB (checked in by bkuhn, 10 months ago)
  • Added SFLC's internally developed tim bot released under AGPLv3
Line 
1 # Copyright (C) 2005, 2006   Software Freedom Law Center, Inc.
2 #  Author: Bradley M. Kuhn <bkuhn@softwarefreedom.org>
3 #
4 #  This software gives you freedom; it is licensed to you under version
5 #  3 of the GNU Affero General Public License.
6 #
7 #  This software is distributed WITHOUT ANY WARRANTY, without even the
8 #  implied warranties of MERCHANTABILITY and FITNESS FOR A PARTICULAR
9 #  PURPOSE.  See the GNU Affero General Public License for further
10 #  details.
11 #
12 # You should have received a copy of the GNU Affero General Public
13 # License, version 3 along with this software.  If not, see
14 # <http://www.gnu.org/licenses/>.
15 use strict;
16 use warnings;
17
18 package SFLC::TimeTracker::Output::Question;
19
20 use base qw(SFLC::TimeTracker::Output);
21
22 use Lingua::EN::Inflect qw ( PL);
23 use Date::Manip;
24
25 ###############################################################################
26 sub new {
27   my($class) = shift;
28   my %input = @_;
29   if (defined $input{question}) {
30     $input{object} = $input{question};
31   }
32   my $self =  SFLC::TimeTracker::Output::new($class, %input);
33   return $self;
34 }
35 ###############################################################################
36 sub question {
37   my $self = shift;
38   return $self->get('question');
39 }
40 ###############################################################################
41 sub get {
42   my($self, $field) = @_;
43   if ($field =~ /^(?:question)$/) {
44     return $self->SUPER::get('object');
45   } else {
46     return $self->SUPER::get($field);
47   }
48 }
49 ###############################################################################
50 sub action {
51   my($self, $actionData) = @_;
52
53   my $retVal = undef;
54
55   my $question = $self->get('question');
56
57   $question->setResolutionData($actionData);
58
59   my $resolution = (defined $actionData->{userInput})
60                   ? $question->resolve($actionData->{userInput})
61                   : undef;
62
63   $self->set('status', $resolution);
64   my(%values) = $question->getResolutionData();
65
66   if (defined $resolution and defined $values{answerType}) {
67     $values{edge} = $values{answerType};
68     return \%values;
69   } else {
70     return undef;
71   }
72
73 }
74 ###############################################################################
75 sub prettyPrintIRC ($$) {
76   my($self, $now) = @_;
77
78   my $retStr = "";
79   $retStr .= $self->question->formatResolveString($self->status) . "  "
80     if defined $self->status;
81   $retStr .= $self->question->formatQuestion()
82     if ($retStr eq "" or $self->status eq "INVALID" or $self->status eq "");
83   return $retStr;
84 }
85
86 1;
87 __END__
88
89 #
90 # Local variables:
91 # compile-command: "perl -I ../../../../../Modules -c Question.pm"
92 # End:
Note: See TracBrowser for help on using the browser.

SFLC Main Page

[frdm] Support SFLC