From 01d8a64ebbaa1ba2714233bee13b737bf575a472 Mon Sep 17 00:00:00 2001 From: "Robert \"ar\" Gerus" Date: Tue, 4 Jun 2013 21:31:27 +0200 Subject: [PATCH] Two plugins. Nothing useful. --- plugins/commands.rb | 27 +++++++++++++++++++++++++++ plugins/pretty_print.rb | 5 +++++ 2 files changed, 32 insertions(+) create mode 100644 plugins/commands.rb create mode 100644 plugins/pretty_print.rb diff --git a/plugins/commands.rb b/plugins/commands.rb new file mode 100644 index 0000000..9cf8961 --- /dev/null +++ b/plugins/commands.rb @@ -0,0 +1,27 @@ +include EventMachine::IRC::Commands + +repost.register_trigger("PRIVMSG") { |msg| + src_nick = msg[:prefix].split('!').first + message = msg[:params][1] + + if msg[:params][0] == Config[:client][:nick] then + target = src_nick + reply_prefix = "" + else + target = msg[:params][0] + reply_prefix = "#{src_nick}: " + end + + if message.split.first == Config[:client][:nick] + ":" then + command = message.split[1] + arguments = message.split[2..-1] + else + if message.split.first[0] == ":" then + command = message.split.first[1..-1] + arguments = message.split[1..-1] + end + end + + repost.privmsg(target, "#{reply_prefix}command: #{command} arguments: #{arguments.join(' ')}") + +} diff --git a/plugins/pretty_print.rb b/plugins/pretty_print.rb new file mode 100644 index 0000000..36087c0 --- /dev/null +++ b/plugins/pretty_print.rb @@ -0,0 +1,5 @@ +include EventMachine::IRC::Commands + +repost.register_trigger("PRIVMSG") { |msg| + p msg +}