Net::Akismet(3pm)

πŸ“¦
version 0.05 Β· 3 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Net::Akismet πŸ’–

okay bestie, so this is Net::Akismet β€” a Perl interface to Akismet, aka the comment and trackback spam fighter. it's a Perl module, so it lives in section 3pm of the manual (User Contributed Perl Documentation, to be exact), and it's genuinely SO useful if you run anything where strangers can leave comments. spam is the enemy and this is the sword. πŸ—‘οΈβœ¨


🌸 SYNOPSIS 🌸

here's the whole vibe, look:

        my $akismet = Net::Akismet->new(
                        KEY => 'secret-baba-API-key',
                        URL => 'http://example.blog.net/',
                ) or die('Key verification failure!');

        my $verdict = $akismet->check(
                        USER_IP                         => '10.10.10.11',
                        COMMENT_USER_AGENT      => 'Mozilla/5.0',
                        COMMENT_CONTENT         => 'Run, Lola, Run, the spam will catch you!',
                        COMMENT_AUTHOR          => 'dosser',
                        COMMENT_AUTHOR_EMAIL    => 'dosser@subway.de',
                        REFERRER                => 'http://lola.home/',
                ) or die('Is the server here?');

        if ('true' eq $verdict) {

                print "I found spam. I am a spam-founder!\n";
        }

like the or die(...) calls? not me being dramatic about error handling, but fr fr, that's just what good code does. πŸ’…


✨ METHODS ✨

πŸŽ€ new()

        Net::Akismet->new(PARAM => ...);

these are the parameters it'll accept, no more no less:

  • KEY β€” the API key that's being verified for use with the API. πŸ”‘
  • URL β€” the front page or home URL of the instance making the request. for a blog or a wiki, this would be the front page.
  • USER_AGENT β€” if you supply it, the value gets prepended to this module's identification string, which makes it turn into something like:
        your-killer-app/0.042 Perl-Net-Akismet/0.01 libwww-perl/5.8

otherwise, just Akismet Perl's user agent string gets sent. simple as that.

  • SERVICE_HOST β€” if supplied, it's the host of the service API. the default is rest.akismet.com
  • SERVICE_VERSION β€” if supplied, it's the API version. the default is 1.1
⚠️ heads up bestie: if the verification of the key was unsuccessful, new() returns undef. so like, check for that, okay? don't let it slide. 🫢

πŸ¦‹ check()

        $akismet->check(USER_IP => ..., COMMENT_CONTENT => ..., ...)

to be or not to be... check is literally there to tell you which one it is. 😭 give it enough details about the comment and it'll hand you back 'true', 'false', or undef.

  • 'true' means spam
  • 'false' means not spam
  • undef gets returned when there's an error in the submission of the comment

and here are the acceptable comment characteristics β€” read them, they matter:

  • USER_IP β€” Required. represents the IP address of the comment submitter.
  • COMMENT_USER_AGENT β€” Required. the user agent string from the comment submitter's request.
  • COMMENT_CONTENT β€” the comment text.
  • REFERRER β€” the HTTP "Referer" header.
  • PERMALINK β€” a permanent link to the subject of the comment.
  • COMMENT_TYPE β€” may be blank, 'comment', 'trackback', 'pingback', or a made up value like 'registration'. yes really, go feral, make one up. πŸ™ˆ
  • COMMENT_AUTHOR β€” name of the submitter.
  • COMMENT_AUTHOR_EMAIL β€” submitter e-mail.
  • COMMENT_AUTHOR_URL β€” submitter's web page.

🌈 spam()

reports a certain comment as spam. it accepts the same arguments as check().

in the case of a failed submission it returns undef; otherwise you get a perl-known truth. periodt.

πŸ“ ham()

this call is meant for marking false positives β€” the things that were incorrectly marked as spam, bless their hearts. it takes identical arguments as check() and spam().

in the case of a failed submission it returns undef; otherwise, again, a perl-known truth. πŸ‘‘


πŸ’€ NOTES πŸ’€

so technically almost all of the comment characteristics are optional, BUT β€” and this is the important part β€” performance can drop dramatically if you exclude certain elements. so please, girlypop, supply as much comment detail as you possibly can. more info = better vibes. 🌸


🌟 SEE ALSO 🌟


πŸ‘‘ AUTHOR πŸ‘‘

Nikolay Bachiyski <nb@nikolay.bg>

πŸ’œ Help, modifications and bugfixes from:

  • Peter Pentchev
  • John Belmonte

Copyright (C) 2006, 2007, 2008 by Nikolay Bachiyski

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.7 or, at your option, any later version of Perl 5 you may have available.

        $Id: Akismet.pm 38 2008-06-05 17:15:12Z humperdink $

okay that's the whole page bestie, mwah πŸ’– this was perl v5.36.0, dated 2022-10-13, and it's the Net::Akismet(3pm) page from User Contributed Perl Documentation. go forth and obliterate some spam. slay. πŸ’…βœ¨πŸ¦‹

πŸ“¦ where this page comes from