diff options
-rw-r--r-- | lib/rbot/irc.rb | 16 | ||||
-rw-r--r-- | lib/rbot/rfc2812.rb | 3 |
2 files changed, 17 insertions, 2 deletions
diff --git a/lib/rbot/irc.rb b/lib/rbot/irc.rb index 64cfdf5a..02835b36 100644 --- a/lib/rbot/irc.rb +++ b/lib/rbot/irc.rb @@ -1533,6 +1533,22 @@ module Irc @capabilities = {}
end
+ # Convert a mode (o, v, h, ...) to the corresponding
+ # prefix (@, +, %, ...). See also mode_for_prefix
+ def prefix_for_mode(mode)
+ return @supports[:prefix][:prefixes][
+ @supports[:prefix][:modes].index(mode.to_sym)
+ ]
+ end
+
+ # Convert a prefix (@, +, %, ...) to the corresponding
+ # mode (o, v, h, ...). See also prefix_for_mode
+ def mode_for_prefix(pfx)
+ return @supports[:prefix][:modes][
+ @supports[:prefix][:prefixes].index(pfx.to_sym)
+ ]
+ end
+
# Resets the Channel and User list
#
def reset_lists
diff --git a/lib/rbot/rfc2812.rb b/lib/rbot/rfc2812.rb index 9de781a8..d4f1e466 100644 --- a/lib/rbot/rfc2812.rb +++ b/lib/rbot/rfc2812.rb @@ -1178,8 +1178,7 @@ module Irc chan.add_user(u, :silent => true) debug "Adding user #{u}" if ar[1] - m = @server.supports[:prefix][:prefixes].index(ar[1].to_sym) - ms = @server.supports[:prefix][:modes][m] + ms = @server.mode_for_prefix(ar[1].to_sym) debug "\twith mode #{ar[1]} (#{ms})" chan.mode[ms].set(u) end |