summaryrefslogtreecommitdiff
path: root/lib/rbot
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rbot')
-rw-r--r--lib/rbot/irc.rb20
1 files changed, 11 insertions, 9 deletions
diff --git a/lib/rbot/irc.rb b/lib/rbot/irc.rb
index 0be26a00..4ad57d99 100644
--- a/lib/rbot/irc.rb
+++ b/lib/rbot/irc.rb
@@ -1102,6 +1102,16 @@ module Irc
end
+ # Hash of modes. Subclass of Hash that defines any? and all?
+ # to check if boolean modes (Type D) are set
+ class ModeHash < Hash
+ def any?(*ar)
+ !!ar.find { |m| s = m.to_sym ; self[s] && self[s].set? }
+ end
+ def all?(*ar)
+ !ar.find { |m| s = m.to_sym ; !(self[s] && self[s].set?) }
+ end
+ end
# Channel modes of type A manipulate lists
#
@@ -1358,15 +1368,7 @@ module Irc
}
# Flags
- @mode = {}
- class << @mode
- def any?(*ar)
- !!ar.find { |m| s = m.to_sym ; self[s] && self[s].set? }
- end
- def all?(*ar)
- !ar.find { |m| s = m.to_sym ; !(self[s] && self[s].set?) }
- end
- end
+ @mode = ModeHash.new
end
# Removes a user from the channel