From b9f69dcda64e0250df6698ccdd079ceb26071e36 Mon Sep 17 00:00:00 2001 From: James Booth Date: Wed, 29 Oct 2014 22:06:08 +0000 Subject: [PATCH] Fixed RubyTest for new hooks --- tests/RubyTest.rb | 152 +++++++++++++++++++++++++++---------------- tests/python-test.py | 20 ++---- 2 files changed, 100 insertions(+), 72 deletions(-) diff --git a/tests/RubyTest.rb b/tests/RubyTest.rb index 610135c..d607ee5 100644 --- a/tests/RubyTest.rb +++ b/tests/RubyTest.rb @@ -2,122 +2,160 @@ module RubyTest def self.prof_init(version, status) Prof::cons_show("RubyTest: init, " + version + ", " + status) - - Prof::register_command("/ruby", 0, 1, "/ruby", "RubyTest", "RubyTest", cmd_ruby) - Prof::register_command("/lower", 0, 1, "/lower", "Lowercase input string", "Lowercase input string", cmd_lower) - - Prof::register_ac("/rcomplete", [ "england", "chile", "croatia" ]) - Prof::register_ac("/rcomplete england", [ "win", "lose", "whatever", "runnerup" ]) - Prof::register_ac("/rcomplete chile", [ "1", "10", "100", "200" ]) - Prof::register_command("/rcomplete", 0, 2, "/rcomplete", "Ruby completion", "Ruby completion", cmd_lower) - - Prof::register_timed(timer_test, 10) + Prof::register_command("/ruby", 0, 1, "/ruby [arg]", "RubyTest", "RubyTest", cmd_ruby) + Prof::register_command("/rb_upper", 1, 1, "/rb_upper string", "RubyTest", "RubyTest", cmd_upper) + Prof::register_command("/rb_notify", 0, 0, "/rb_notify", "RubyTest", "RubyTest", cmd_notify) + Prof::register_command("/rb_vercheck", 0, 0, "/rb_vercheck", "RubyTest", "RubyTest", cmd_vercheck) + Prof::register_ac("/rb_complete", [ "aaaa", "bbbb", "bcbcbc" ]) + Prof::register_ac("/rb_complete aaaa", [ "one", "two", "three", "four" ]) + Prof::register_ac("/rb_complete bcbcbc", [ "james", "jim", "jane", "bob" ]) + Prof::register_command("/rb_complete", 0, 2, "/rb_complete [arg1] [arg2]", "RubyTest", "RubyTest", cmd_ac) + Prof::register_timed(timer_test, 30) end - def self.prof_on_start() - Prof::cons_show("RubyTest: on_start") + def self.prof_on_start + Prof::cons_show("RubyTest: prof_on_start") Prof::log_debug("RubyTest: logged debug"); Prof::log_info("RubyTest: logged info"); Prof::log_warning("RubyTest: logged warning"); Prof::log_error("RubyTest: logged error"); end + def self.prof_on_shutdown + Prof::log_info("RubyTest: prof_on_shutdown"); + end + def self.prof_on_connect(account_name, fulljid) - Prof::cons_show("RubyTest: on_connect, " + account_name + ", " + fulljid) + Prof::cons_show("RubyTest: prof_on_connect, " + account_name + ", " + fulljid) end def self.prof_on_disconnect(account_name, fulljid) - Prof::cons_show("RubyTest: on_disconnect, " + account_name + ", " + fulljid) - Prof::log_info("RubyTest: on_disconnect, " + account_name + ", " + fulljid) + Prof::cons_show("RubyTest: prof_on_disconnect, " + account_name + ", " + fulljid) end - def self.prof_on_message_received(jid, message) - Prof::cons_show("RubyTest: on_message_received, " + jid + ", " + message) + def self.prof_pre_chat_message_display(jid, message) + Prof::cons_show("RubyTest: prof_pre_chat_message_display, " + jid + ", " + message) Prof::cons_alert - return message + "[RUBY]" + return message + "[RB_pre_chat_message_display]" end - def self.prof_on_room_message_received(room, nick, message) - Prof::cons_show("RubyTest: on_room_message_received, " + room + ", " + nick + ", " + message) + def self.prof_post_chat_message_display(jid, message) + Prof::cons_show("RubyTest: prof_post_chat_message_display, " + jid + ", " + message) Prof::cons_alert - return message + "[RUBY]" end - def self.prof_on_private_message_received(room, nick, message) - Prof::cons_show("RubyTest: on_private_message_received, " + room + ", " + nick + ", " + message) + def self.prof_pre_chat_message_send(jid, message) + Prof::cons_show("RubyTest: prof_pre_chat_message_send, " + jid + ", " + message) Prof::cons_alert - return message + "[RUBY]" + return message + "[RB_pre_chat_message_send]" end - def self.prof_on_message_send(jid, message) - Prof::cons_show("RubyTest: on_message_send, " + jid + ", " + message) + def self.prof_post_chat_message_send(jid, message) + Prof::cons_show("RubyTest: prof_post_chat_message_send, " + jid + ", " + message) Prof::cons_alert - return message + "[RUBY]" end - def self.prof_on_private_message_send(room, nick, message) - Prof::cons_show("RubyTest: on_private_message_send, " + room + ", " + nick + ", " + message) + def self.prof_pre_room_message_display(room, nick, message) + Prof::cons_show("RubyTest: prof_pre_room_message_display, " + room + ", " + nick + ", " + message) Prof::cons_alert - return message + "[RUBY]" + return message + "[RB_pre_room_message_display]" end - def self.prof_on_room_message_send(room, message) - Prof::cons_show("RubyTest: on_room_message_send, " + room + ", " + message) + def self.prof_post_room_message_display(room, nick, message) + Prof::cons_show("RubyTest: prof_post_room_message_display, " + room + ", " + nick + ", " + message) Prof::cons_alert - return message + "[RUBY]" end - def self.prof_on_shutdown() - Prof::log_info("RubyTest: on_shutdown"); + def self.prof_pre_room_message_send(room, message) + Prof::cons_show("RubyTest: prof_pre_room_message_send, " + room + ", " + message) + Prof::cons_alert + return message + "[RB_pre_room_message_send]" end - def self.cmd_ruby() + def self.prof_post_room_message_send(room, message) + Prof::cons_show("RubyTest: prof_post_room_message_send, " + room + ", " + message) + Prof::cons_alert + end + + def self.prof_pre_priv_message_display(room, nick, message) + Prof::cons_show("RubyTest: prof_pre_priv_message_display, " + room + ", " + nick + ", " + message) + Prof::cons_alert + return message + "[RB_pre_priv_message_display]" + end + + def self.prof_post_priv_message_display(room, nick, message) + Prof::cons_show("RubyTest: prof_post_priv_message_display, " + room + ", " + nick + ", " + message) + Prof::cons_alert + end + + def self.prof_pre_priv_message_send(room, nick, message) + Prof::cons_show("RubyTest: prof_pre_priv_message_send, " + room + ", " + nick + ", " + message) + Prof::cons_alert + return message + "[RB_pre_priv_message_send]" + end + + def self.prof_post_priv_message_send(room, nick, message) + Prof::cons_show("RubyTest: prof_post_priv_message_send, " + room + ", " + nick + ", " + message) + Prof::cons_alert + end + + def self.cmd_ruby return Proc.new { | msg | if msg Prof::cons_show("RubyTest: /ruby command called, arg = " + msg) else Prof::cons_show("RubyTest: /ruby command called with no arg") end - Prof::cons_alert - Prof::notify("RubyTest: notify", 2000, "Plugins") - Prof::send_line("/help") - Prof::cons_show("RubyTest: sent \"/help\" command") } end - def self.timer_test() + def self.cmd_ac + return Proc.new { | arg1, arg2 | + Prof::cons_show("RubyTest: /rb_complete called") + } + end + + def self.cmd_notify + return Proc.new { + Prof::notify("RubyTest: notify", 2000, "Plugins") + } + end + + def self.cmd_vercheck + return Proc.new { + Prof::send_line("/vercheck") + Prof::cons_show("RubyTest: sent \"/vercheck\" command") + } + end + + def self.timer_test return Proc.new { Prof::cons_show("RubyTest: timer fired.") - recipient = Prof::get_current_recipient - if recipient - Prof::cons_show(" current recipient = " + recipient) - end Prof::cons_alert } end - def self.cmd_lower() + def self.cmd_upper return Proc.new { | line | - win_tag = "Lower echo" + win_tag = "Ruby Plygin" if (Prof::win_exists(win_tag) == false) - Prof::win_create(win_tag, handle_lower) + Prof::win_create(win_tag, handle_upper) end - Prof::win_focus(win_tag) - if (line) - handle_lower.call(win_tag, line) + handle_upper.call(win_tag, line) end } end - def self.handle_lower() + def self.handle_upper return Proc.new { | win, line | - Prof::win_show(win, line.downcase) - Prof::win_show_red(win, "Red") - Prof::win_show_yellow(win, "Yellow") - Prof::win_show_green(win, "Green") - Prof::win_show_cyan(win, "Cyan") + upper = line.upcase + Prof::win_show(win, upper) + Prof::win_show_red(win, upper + " red") + Prof::win_show_yellow(win, upper + " yellow") + Prof::win_show_green(win, upper + " green") + Prof::win_show_cyan(win, upper + " cyan") } end end diff --git a/tests/python-test.py b/tests/python-test.py index 184583d..ba71966 100644 --- a/tests/python-test.py +++ b/tests/python-test.py @@ -1,7 +1,5 @@ import prof -_win_tag = "Python Plugin"; - def _timer_test(): prof.cons_show("python-test: timer fired.") prof.cons_alert() @@ -24,14 +22,12 @@ def _cmd_ac(arg1=None, arg2=None): prof.cons_show("python-test: /py_complete called"); def _cmd_upper(line): - global _win_tag; - if prof.win_exists(_win_tag) == False: - prof.win_create(_win_tag, _handle_upper) - - prof.win_focus(_win_tag) - + win_tag = "Python Plugin" + if prof.win_exists(win_tag) == False: + prof.win_create(win_tag, _handle_upper) + prof.win_focus(win_tag) if line: - _handle_upper(_win_tag, line) + _handle_upper(win_tag, line) def _cmd_notify(): prof.notify("python-test: notify", 2000, "Plugins") @@ -42,20 +38,14 @@ def _cmd_vercheck(): def prof_init(version, status): prof.cons_show("python-test: init, " + version + ", " + status) - prof.register_command("/python", 0, 1, "/python [arg]", "python-test", "python-test", _cmd_python) - prof.register_command("/py_upper", 1, 1, "/py_upper string", "python-test", "python-test", _cmd_upper) - prof.register_command("/py_notify", 0, 0, "/py_notify", "python-test", "python-test", _cmd_notify) - prof.register_command("/py_vercheck", 0, 0, "/py_vercheck", "python-test", "python-test", _cmd_vercheck) - prof.register_ac("/py_complete", [ "aaaa", "bbbb", "bcbcbc" ]) prof.register_ac("/py_complete aaaa", [ "one", "two", "three", "four" ]) prof.register_ac("/py_complete bcbcbc", [ "james", "jim", "jane", "bob" ]) prof.register_command("/py_complete", 0, 2, "/py_complete [arg1] [arg2]", "python-test", "python-test", _cmd_ac) - prof.register_timed(_timer_test, 30) def prof_on_start():