]> git.donarmstrong.com Git - infobot.git/blob - src/Modules/DebianBugs.pm
* Missed DebianBugs.pl in the previous merge
[infobot.git] / src / Modules / DebianBugs.pm
1 # This module is a plugin for WWW::Scraper, and allows one to search
2 # google, and is released under the terms of the GPL version 2, or any
3 # later version. See the file README and COPYING for more
4 # information. Copyright 2002 by Don Armstrong <don@donarmstrong.com>.
5
6 # $Id:  $
7
8 package DebianBugs;
9
10 use warnings;
11 use strict;
12
13 use vars qw($VERSION $DEBUG);
14
15 use SOAP::Lite;
16
17 $VERSION = q($Rev: $);
18 $DEBUG ||= 0;
19
20 sub bug_info {
21     my ($bug_num,$options) = @_;
22
23     $options || = {};
24
25     if ( not $bug_num =~ /^\#?\d+$/ ) {
26         warn "Bug is not a number!" and return undef
27           if not $options->{return_warnings};
28         return "Bug is not a number!";
29     }
30     $bug_num =~ s/^\#//;
31     my $soap = SOAP::Lite->url->('Debbugs/SOAP/1')->
32         proxy('http://bugs.debian.org/cgi-bin/soap.cgi');
33     $soap->transport->env_proxy();
34     my $result = $soap->get_status(bug => $bug_num)->result();
35     if (not defined $result) {
36         return "No such bug (or some kind of error)";
37     }
38     my $bug = {};
39     $bug->{num} = $result->{bug_num};
40     $bug->{title} = $result->{subject};
41     $bug->{severity} = $result->{severity};    #Default severity is normal
42     # Just leave the leter instead of the whole thing.
43     $bug->{severity} =~ s/^(.).+$/$1/;
44     $bug->{package} = $result->{package};
45     $bug->{reporter} = $result->{submitter};
46     $bug->{date} = $result->{date};
47     $bug->{tags} = $result->{keywords};
48     $bug->{done} = defined $result->{done} and length $result->{done};
49     $bug->{merged_with} = $result->{mergedwith};
50     # report bug
51
52     my $report = '';
53     $report .= 'DONE:' if defined $bug->{done} and $bug->{done};
54     $report .= '#'
55       . $bug->{num} . ':'
56       . uc( $bug->{severity} ) . '['
57       . $bug->{package} . '] '
58       . $bug->{title};
59     $report .= ' (' . $bug->{tags} . ')' if defined $bug->{tags};
60     $report .= '; ' . $bug->{date};
61
62     # Avoid reporting so many merged bugs.
63     $report .= ' ['
64       . join( ',', splice( @{ [ split( /,/, $bug->{merged_with} ) ] }, 0, 3 ) )
65       . ']'
66       if defined $bug->{merged_with};
67     return $report;
68 }
69
70 sub package_bugs($) {
71
72 }
73
74 1;
75
76
77 __END__
78
79 # vim:ts=4:sw=4:expandtab:tw=80