From 344ce60f00a55e3f3657c398bc03bf917045fc2d Mon Sep 17 00:00:00 2001 From: Matthew Barksdale Date: Mon, 14 Mar 2011 20:38:22 -0400 Subject: [PATCH] Added a module to get information on packages in AUR. --- doc/CHANGELOG | 1 + lib/Lib/Install.pm | 2 +- modules/AUR.pm | 114 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 modules/AUR.pm diff --git a/doc/CHANGELOG b/doc/CHANGELOG index 46d7d23..836a9dd 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -7,6 +7,7 @@ Auto IRC Bot 3.0: Change Log 3.0 Alpha 7 =============================================================================== + * Added an AUR module. * Fixed a bug in UNO where rehashing during a game caused a crash. * Proto::IRC::umodes renamed to Proto::IRC::botinfo{svr}{modes}. * Fixed a bug where incoming PART's from ourselves were not parsed. diff --git a/lib/Lib/Install.pm b/lib/Lib/Install.pm index 5c6f283..3d855b9 100644 --- a/lib/Lib/Install.pm +++ b/lib/Lib/Install.pm @@ -123,7 +123,7 @@ sub installmods chomp $response; if (lc $response eq 'y') { println 'What modules would you like to install? (separate by commas)'; - println 'Available modules: Badwords, Bitly, BotStats, Calc, ChanTopics, Dictionary, EightBall, Eval, FML, Greet, HelloChan, IsItUp, LinkTitle, Oper, QDB, SASLAuth, UNO, Weather'; + println 'Available modules: AUR, Badwords, Bitly, BotStats, Calc, ChanTopics, Dictionary, EightBall, Eval, FML, Greet, HelloChan, IsItUp, LinkTitle, Oper, QDB, SASLAuth, UNO, Weather'; print '> '; my $modules = ; chomp $modules; $modules =~ s/ //g; diff --git a/modules/AUR.pm b/modules/AUR.pm new file mode 100644 index 0000000..cb1bf55 --- /dev/null +++ b/modules/AUR.pm @@ -0,0 +1,114 @@ +# Module: AUR. See below for documentation. +# Copyright (C) 2010-2011 Xelhua Development Group, et al. +# This program is free software; rights to this code are stated in doc/LICENSE. +package M::AUR; +use strict; +use warnings; +use WWW::AUR; +use API::Std qw(cmd_add cmd_del trans); +use API::IRC qw(notice privmsg); + +# Initialization subroutine. +sub _init +{ + # Create the AUR command. + cmd_add('AUR', 0, 0, \%M::AUR::HELP_AUR, \&M::AUR::cmd_aur) or return; + # Success. + return 1; +} + +# Void subroutine. +sub _void +{ + # Delete the AUR command. + cmd_del('AUR') or return; + + # Success. + return 1; +} + + +# Help hash for AUR. Spanish, French and German translations needed. +our %HELP_AUR = ( + 'en' => "This command allows you to lookup a module in the Arch Linux AUR. \002Syntax:\002 AUR ", +); + +# Callback for AUR command. +sub cmd_aur +{ + my ($src, ($mod)) = @_; + + # Check for needed parameters. + if (!defined $mod) { + notice($src->{svr}, $src->{nick}, trans('Not enough parameters').q{.}); + return; + } + + # Create an instance of WWW::AUR. + my $aur = WWW::AUR->new; + # Create an instance of WWW::AUR::Package. + my $pkg = $aur->find($mod); + + # Check if there was a result. + if (defined $pkg) { + # Return the results. + privmsg($src->{svr}, $src->{chan}, "Results for \2$mod\2:"); + privmsg($src->{svr}, $src->{chan}, "ID: ".$pkg->id." Name: ".$pkg->name." Version: ".$pkg->version); + my $man = $pkg->maintainer; + privmsg($src->{svr}, $src->{chan}, "Maintainer: ".$man->name); + privmsg($src->{svr}, $src->{chan}, "URL: https://aur.archlinux.org/packages.php?ID=".$pkg->id); + } + else { + # Else return no results. + privmsg($src->{svr}, $src->{chan}, "No results for \2$mod\2."); + } + + return 1; +} + +# Start initialization. +API::Std::mod_init('AUR', 'Xelhua', '1.00', '3.0.0a7', __PACKAGE__); +# build: cpan=WWW::AUR perl=5.010000 + +__END__ + +=head1 NAME + +AUR - AUR package information module. + +=head1 VERSION + +1.00 + +=head1 SYNOPSIS + + !aur google-chrome + Results for google-chrome: + ID: 37469 Name: google-chrome Version: 10.0.648.133-1 + Maintainer: t3ddy + URL: https://aur.archlinux.org/packages.php?ID=37469 + +=head1 DESCRIPTION + +This module adds a command to allow getting information on a package +in AUR. + +=head1 INSTALL + +Before using this module, you will need to get WWW::AUR from cpan. + +=head1 AUTHOR + +This module was written by Matthew Barksdale. + +This module is maintained by Xelhua Development Group. + +=head1 LICENSE AND COPYRIGHT + +This module is Copyright 2010-2011 Xelhua Development Group. + +Released under the same licensing terms as Auto itself. + +=cut + +# vim: set ai et sw=4 ts=4: