From 10fbddd2a6a0d6f289470ace497d0397697cceb0 Mon Sep 17 00:00:00 2001 From: Elijah Perrault Date: Fri, 4 Mar 2011 20:45:31 -0700 Subject: [PATCH] Our usermodes are now tracked in Proto::IRC::umodes. --- doc/CHANGELOG | 1 + lib/Core/IRC.pm | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/doc/CHANGELOG b/doc/CHANGELOG index 2c3b8dc..031e5c0 100644 --- a/doc/CHANGELOG +++ b/doc/CHANGELOG @@ -3,6 +3,7 @@ Auto IRC Bot 3.0: Change Log 3.0 Indev =============================================================================== + * Our usermodes are now tracked in Proto::IRC::umodes. * Added events on_cmode and on_umode. * Added event on_myinfo for RPL_MYINFO (numeric 004). * Raw hooks now take hook names and support multiple hooks. This changes diff --git a/lib/Core/IRC.pm b/lib/Core/IRC.pm index 6054ee5..5a6fd0e 100644 --- a/lib/Core/IRC.pm +++ b/lib/Core/IRC.pm @@ -204,6 +204,36 @@ hook_add('on_disconnect', 'core.irc.deldata', sub { return 1; }); +# Track our usermodes. +hook_add('on_umode', 'core.irc.state.umode', sub { + my (($svr, $modes)) = @_; + + # Remove anything after a space. + $modes =~ s/(\s.*)//xsm; + + # Split the modes. + my @modes = split //, $modes; + + # Set operator to 1. + my $op = 1; + # Iterate through the modes. + foreach (@modes) { + if ($_ eq '-') { $op = 0 } + elsif ($_ eq '+') { $op = 1 } + else { + # Adjust our modes. + if ($op) { + $Proto::IRC::umodes{$svr} .= $_; + } + else { + $Proto::IRC::umodes{$svr} =~ s/($_)//xsm; + } + } + } + + return 1; +}); + 1; # vim: set ai et sw=4 ts=4: