From 0ed6da503e54353848574a3dced711ec91c67df0 Mon Sep 17 00:00:00 2001 From: Elijah Perrault Date: Mon, 3 Jan 2011 13:03:11 -0700 Subject: [PATCH] Renamed API/Standard to API/API and added API::conf_get() --- src/API/API.pm | 44 ++++++++++++++++++++++++++++++++++++++++++++ src/API/Standard.pm | 8 -------- 2 files changed, 44 insertions(+), 8 deletions(-) create mode 100644 src/API/API.pm delete mode 100644 src/API/Standard.pm diff --git a/src/API/API.pm b/src/API/API.pm new file mode 100644 index 0000000..e9e4aff --- /dev/null +++ b/src/API/API.pm @@ -0,0 +1,44 @@ +# Auto IRC Bot. An advanced, lightweight and powerful IRC bot. +# Copyright (C) 2010-2011 Xelhua Development Team (doc/CREDITS) +# This program is free software; rights to this code are stated in doc/LICENSE. +use strict; +use warnings; + +# Standard API subroutines. +package API; + +# Configuration value getter. +sub conf_get +{ + my ($value) = @_; + + # Create an array out of the value. + my @val; + if ($value =~ m/:/) { + @val = split(':', $value); + } + else { + @val = ($value); + } + # Undefine this as it's unnecessary now. + undef $value; + + # Get the count of elements in the array. + my $count = scalar(@val); + + # Return the requested configuration value(s). + if ($count == 1) { + return $Auto::SETTINGS{c}{$val[0]}; + } + elsif ($count == 2) { + return $Auto::SETTINGS{c}{$val[0]}{$val[1]}; + } + elsif ($count == 3) { + return $Auto::SETTINGS{c}{$val[0]}{$val[1]}{$val[2]}; + } + else { + return 0; + } +} + +1; diff --git a/src/API/Standard.pm b/src/API/Standard.pm deleted file mode 100644 index a6c59c7..0000000 --- a/src/API/Standard.pm +++ /dev/null @@ -1,8 +0,0 @@ -# Auto IRC Bot. An advanced, lightweight and powerful IRC bot. -# Copyright (C) 2010-2011 Xelhua Development Team (doc/CREDITS) -# This program is free software; rights to this code are stated in doc/LICENSE. -use strict; -use warnings; - -# Standard API. -package API;