diff --git a/doc/CHANGELOG b/doc/CHANGELOG index 483ffdd..d628b8c 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -3,6 +3,7 @@ Auto IRC Bot 3.0: Change Log 3.0 Indev ================================================================== + * Begin on API::IRC. * Parse PING and Numeric:001. * Begin on the IRC parser. * Added sockets, support for multiple asynchronous sockets. diff --git a/src/API/IRC.pm b/src/API/IRC.pm new file mode 100644 index 0000000..14b21c1 --- /dev/null +++ b/src/API/IRC.pm @@ -0,0 +1,32 @@ +# 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. + +# IRC API subroutines. +package API::IRC; +use strict; +use warnings; +use Exporter; + +our @ISA = qw(Exporter); +our @EXPORT_OK = qw(cjoin cpart); + + +# Join a channel. +sub cjoin { + my ($svr, $chan) = @_; + + Auto::socksnd($svr, "JOIN $chan"); +} + +# Part a channel. +sub cpart { + my ($svr, $chan, $reason) = @_; + + if (defined $reason) { + Auto::socksnd($svr, "PART $chan :$reason"); + } + else { + Auto::socksnd($svr, "PART $chan :Leaving"); + } +}