File Coverage

blib/lib/Duadua/Parser/Bot/ChatGPTUser.pm
Criterion Covered Total %
statement 16 16 100.0
branch 4 6 66.6
condition 4 6 66.6
subroutine 4 4 100.0
pod 1 1 100.0
total 29 33 87.8


line stmt bran cond sub pod time code
1             package Duadua::Parser::Bot::ChatGPTUser;
2 11     11   66 use strict;
  11         21  
  11         465  
3 11     11   50 use warnings;
  11         20  
  11         3229  
4              
5             sub try {
6 323     323 1 719 my ($class, $d) = @_;
7              
8 323 50 66     849 if ( $d->_contain('ChatGPT-User/')
      66        
9             && $d->_contain('+https://openai.com/bot')
10             && $d->_contain_mozilla_top ) {
11 2         8 my $h = _set_property($d, 'ChatGPT-User');
12              
13 2 100       6 if ($d->opt_version) {
14 1         4 my ($version) = ($d->ua =~ m!ChatGPT-User/([\d.]+)!);
15 1 50       6 $h->{version} = $version if $version;
16             }
17              
18 2         43 return $h;
19             }
20             }
21              
22             sub _set_property {
23 2     2   7 my ($d, $name) = @_;
24              
25 2         8 my $h = {
26             name => $name,
27             is_bot => 1,
28             };
29              
30 2         7 return $h;
31             }
32              
33             1;
34              
35             __END__