-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #126 from bayashi/chatgpt-user
To detect ChatGPT-User
- Loading branch information
Showing
3 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package Duadua::Parser::Bot::ChatGPTUser; | ||
use strict; | ||
use warnings; | ||
|
||
sub try { | ||
my ($class, $d) = @_; | ||
|
||
if ( index($d->ua, 'ChatGPT-User/') > -1 | ||
&& index($d->ua, '+https://openai.com/bot') > -1 | ||
&& index($d->ua, 'Mozilla/') == 0 ) { | ||
my $h = _set_property($d, 'ChatGPT-User'); | ||
|
||
if ($d->opt_version) { | ||
my ($version) = ($d->ua =~ m!ChatGPT-User/([\d.]+)!); | ||
$h->{version} = $version if $version; | ||
} | ||
|
||
return $h; | ||
} | ||
} | ||
|
||
sub _set_property { | ||
my ($d, $name) = @_; | ||
|
||
my $h = { | ||
name => $name, | ||
is_bot => 1, | ||
}; | ||
|
||
return $h; | ||
} | ||
|
||
1; | ||
|
||
__END__ | ||
=encoding UTF-8 | ||
=head1 METHODS | ||
=head2 try | ||
Do parse | ||
=head1 AUTHOR | ||
Dai Okabayashi E<lt>[email protected]E<gt> | ||
=head1 LICENSE | ||
C<Duadua> is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0. (Note that, unlike the Artistic License 1.0, version 2.0 is GPL compatible by itself, hence there is no benefit to having an Artistic 2.0 / GPL disjunction.) See the file LICENSE for details. | ||
=cut |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# https://platform.openai.com/docs/plugins/bot | ||
- ua: 'Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko); compatible; ChatGPT-User/1.0; +https://openai.com/bot' | ||
name: ChatGPT-User | ||
is_bot: true | ||
is_ios: false | ||
is_android: false | ||
is_linux: false | ||
is_windows: false | ||
is_chromeos: false | ||
version: '1.0' |