]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
Extended the opme plugin into a more general op plugin. Functionality is the same...
authorMark Kretschmann <markey@web.de>
Tue, 10 Oct 2006 18:26:02 +0000 (18:26 +0000)
committerMark Kretschmann <markey@web.de>
Tue, 10 Oct 2006 18:26:02 +0000 (18:26 +0000)
data/rbot/plugins/op.rb [new file with mode: 0644]
data/rbot/plugins/opme.rb [deleted file]

diff --git a/data/rbot/plugins/op.rb b/data/rbot/plugins/op.rb
new file mode 100644 (file)
index 0000000..6ebbc60
--- /dev/null
@@ -0,0 +1,38 @@
+class OpPlugin < Plugin
+
+  def help(plugin, topic="")
+    return "op [<user>] [<channel>] => grant <user> (if ommitted yourself) ops in <channel> (or in the current channel if no channel is specified)"
+  end
+
+  def op(m, params)
+    channel = params[:channel]
+    user = params[:user]
+    unless channel
+      if m.private?
+        target = user.nil? ? "you" : user 
+        m.reply "You should tell me where you want me to op #{target}."
+        return
+      else
+        channel = m.channel.to_s
+      end
+    end
+    unless user
+      user = m.sourcenick
+    end
+
+    m.okay unless channel == m.channel.to_s
+    @bot.sendq("MODE #{channel} +o #{user}")
+  end
+
+  def opme(m, params)
+    params[:user] = m.sourcenick
+    op(m, params)
+  end
+
+end
+
+plugin = OpPlugin.new
+plugin.map("op [:user] [:channel]")
+plugin.map("opme [:channel]") # For backwards compatibility with 0.9.10
+plugin.default_auth("*",false)
+
diff --git a/data/rbot/plugins/opme.rb b/data/rbot/plugins/opme.rb
deleted file mode 100644 (file)
index 54f61b9..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-class OpMePlugin < Plugin
-
-  def help(plugin, topic="")
-    return "opme [<channel>] => grant user ops in <channel> (or in the current channel if no channel is specified)"
-  end
-
-  def opme(m, params)
-    channel = params[:chan]
-    unless channel
-      if m.private?
-        m.reply "you should tell me where you want me to op you"
-        return
-      else
-        channel = m.channel.to_s
-      end
-    end
-    target = m.sourcenick
-    m.okay unless channel == m.channel.to_s
-    @bot.sendq("MODE #{channel} +o #{target}")
-  end
-end
-
-plugin = OpMePlugin.new
-plugin.map("opme [:chan]")
-plugin.default_auth("*",false)