]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
IRC Framework: Channel.npname()
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Sun, 1 Nov 2009 08:52:30 +0000 (09:52 +0100)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Sun, 1 Nov 2009 09:36:54 +0000 (10:36 +0100)
Returns the unprefixed part of a channel name

lib/rbot/irc.rb

index c893fc2728d22b0d44383f755970390fa4c7faa8..ebfbaed3deb2a571081633ce351de44f6b1c8b0a 100644 (file)
@@ -1323,6 +1323,13 @@ module Irc
   #
   class Channel
 
+    # Return the non-prefixed part of a channel name.
+    # Also works with ## channels found on some networks
+    # (e.g. FreeNode)
+    def self.npname(str)
+      return str.to_s.sub(/^[&#+!]+/,'')
+    end
+
     include ServerOrCasemap
     attr_reader :name, :topic, :mode, :users
     alias :to_s :name