From 03e0857713a61254becc51590bc04ccfc97930bb Mon Sep 17 00:00:00 2001 From: Elijah Perrault Date: Wed, 19 Jan 2011 15:40:40 -0700 Subject: [PATCH] Begin on API::IRC. --- doc/CHANGELOG | 1 + src/API/IRC.pm | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 src/API/IRC.pm 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"); + } +}