diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2007-11-06 22:39:10 +0000 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2007-11-06 22:39:10 +0000 |
commit | 4d193a6c8719351147faad15e9a91d391df94952 (patch) | |
tree | 08d9de3262a5f42c010c486529b98c2bcae19992 /lib | |
parent | 66b0acef370cd778ce943e9b50bd8590467d43bf (diff) |
New Irc Framework: methods to convert channel user modes (op, voice, etc) from mode (o, v, ...) to prefix (@, +, ...) and back
Diffstat (limited to 'lib')
-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 |