diff --git a/bin/auto b/bin/auto index 0d534d6..f93f3f3 100755 --- a/bin/auto +++ b/bin/auto @@ -16,23 +16,27 @@ use IO::Select; use Class::Unload; use FindBin qw($Bin); our $Bin = $Bin; -BEGIN { unshift(@INC, "$Bin/../src"); } +BEGIN { + unshift(@INC, "$Bin/../src"); + + # Set version information. + use constant { + NAME => 'Auto IRC Bot', + VER => 3, + SVER => 0, + REV => 0, + RSTAGE => 'd' + }; +} use API::Std qw(conf_get err cmd_add cmd_del); use API::Log qw(println alog dbug); use DB::Flatfile; use Parser::Config; use Parser::Lang; use Parser::IRC; -#use Sys; +use Core::IRC; + -# Set version information. -use constant { - NAME => 'Auto IRC Bot', - VER => 3, - SVER => 0, - REV => 0, - RSTAGE => 'd' -}; our $VERSION = 3.0.0; $0 = NAME; @@ -284,6 +288,9 @@ else { } undef $it; +# Create core hooks. +API::Std::hook_add("on_uprivmsg", "ctcp_version_reply", \&Core::IRC::version_reply); + # Infinite while loop. while (1) { # Timer check. diff --git a/doc/CHANGELOG b/doc/CHANGELOG index fd409ba..0cd4b08 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -3,9 +3,11 @@ Auto IRC Bot 3.0: Change Log 3.0 Indev ================================================================== + * Fixed the NAME,VER,SVER,REV,RSTAGE constants. + * Added a CTCP VERSION reply. + * Created Core::IRC. * Added Bit.ly module - 3.0 Alpha 1 ================================================================== * Added mod_exists() to API::Std. diff --git a/src/Core/IRC.pm b/src/Core/IRC.pm new file mode 100644 index 0000000..258b376 --- /dev/null +++ b/src/Core/IRC.pm @@ -0,0 +1,25 @@ +# 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. + +# Core IRC functionality. +package Core::IRC; +use strict; +use warnings; +use English; +use API::IRC qw(notice usrc); + +sub version_reply +{ + my (($svr, @ex)) = @_; + my %src = usrc(substr($ex[0], 1)); + + if ($ex[3] eq ":\001VERSION\001") { + notice($svr, $src{nick}, "VERSION ".Auto::NAME." ".Auto::VER.".".Auto::SVER.".".Auto::REV.Auto::RSTAGE." ".$OSNAME); + } + + return 1; +} + + +1;