From 1086b930153bc72559997cd801b3c579d44f2517 Mon Sep 17 00:00:00 2001 From: James Booth Date: Fri, 15 Apr 2016 23:18:52 +0100 Subject: [PATCH] Updated test plugins --- clients.py | 2 +- tests/python-test.py | 26 ++++++++++++++++++++-- tests/test-c-plugin/test-c-plugin.c | 34 +++++++++++++++++++++++++++-- 3 files changed, 57 insertions(+), 5 deletions(-) diff --git a/clients.py b/clients.py index 9e784d1..eb0352b 100644 --- a/clients.py +++ b/clients.py @@ -91,7 +91,7 @@ def prof_init(version, status, account_name, fulljid): synopsis = [ "/clients" ] - description = "Show clients used by chat room occupants" + description = "Show client software used by chat room occupants" args = [] examples = [] diff --git a/tests/python-test.py b/tests/python-test.py index 1e32e9d..37f82a3 100644 --- a/tests/python-test.py +++ b/tests/python-test.py @@ -121,6 +121,26 @@ def _get(subject): else: prof.win_focus(plugin_win) prof.win_show(plugin_win, "called -> prof_get_current_muc: ") + elif subject == "nick": + _create_win() + nick = prof.get_current_nick() + if nick: + prof.win_focus(plugin_win) + prof.win_show(plugin_win, "called -> prof_get_current_nick: " + nick) + else: + prof.win_focus(plugin_win) + prof.win_show(plugin_win, "called -> prof_get_current_nick: ") + elif subject == "occupants": + _create_win() + occupants = prof.get_current_occupants() + if occupants: + prof.win_focus(plugin_win) + prof.win_show(plugin_win, "called -> prof_get_current_occupants:") + for occupant in occupants: + prof.win_show(plugin_win, occupant) + else: + prof.win_focus(plugin_win) + prof.win_show(plugin_win, "called -> prof_get_current_occupants: ") else: prof.cons_bad_cmd_usage("/python-test") @@ -323,7 +343,7 @@ def prof_init(version, status, account_name, fulljid): "/python-test winshow_t ", "/python-test notify ", "/python-test sendline ", - "/python-test get recipient|room", + "/python-test get recipient|room|nick|occupants", "/python-test log debug|info|warning|error ", "/python-test count", "/python-test ping ", @@ -348,6 +368,8 @@ def prof_init(version, status, account_name, fulljid): [ "sendline ", "Pass line to profanity to process" ], [ "get recipient", "Show the current chat recipient, if in a chat window" ], [ "get room", "Show the current room JID, if ina a chat room"], + [ "get nick", "Show nickname in current room, if ina a chat room"], + [ "get occupants", "Show occupants in current room, if ina a chat room"], [ "log debug|info|warning|error ", "Log a message at the specified level" ], [ "count", "Show the counter, incremented every 5 seconds by a worker thread" ], [ "ping ", "Send an XMPP ping to the specified Jabber ID" ], @@ -393,7 +415,7 @@ def prof_init(version, status, account_name, fulljid): ] ) prof.completer_add("/python-test get", - [ "recipient", "room" ] + [ "recipient", "room", "nick", "occupants" ] ) prof.completer_add("/python-test log", [ "debug", "info", "warning", "error" ] diff --git a/tests/test-c-plugin/test-c-plugin.c b/tests/test-c-plugin/test-c-plugin.c index 5bc67de..69a1068 100644 --- a/tests/test-c-plugin/test-c-plugin.c +++ b/tests/test-c-plugin/test-c-plugin.c @@ -197,6 +197,34 @@ getsubject(char *subject) prof_win_focus(plugin_win); prof_win_show(plugin_win, "called -> prof_get_current_muc: "); } + } else if (strcmp(subject, "nick") == 0) { + create_win(); + char *nick = prof_get_current_nick(); + if (nick) { + prof_win_focus(plugin_win); + char *str = "called -> prof_get_current_nick: "; + char buf[strlen(str) + strlen(nick)]; + sprintf(buf, "%s%s", str, nick); + prof_win_show(plugin_win, buf); + } else { + prof_win_focus(plugin_win); + prof_win_show(plugin_win, "called -> prof_get_current_nick: "); + } + } else if (strcmp(subject, "occupants") == 0) { + create_win(); + char **occupants = prof_get_current_occupants(); + if (occupants) { + prof_win_focus(plugin_win); + prof_win_show(plugin_win, "called -> prof_get_current_occupants:"); + int i = 0; + while(occupants[i] != NULL) { + prof_win_show(plugin_win, occupants[i]); + i++; + } + } else { + prof_win_focus(plugin_win); + prof_win_show(plugin_win, "called -> prof_get_current_occupants: "); + } } else { prof_cons_bad_cmd_usage("/c-test"); } @@ -485,7 +513,7 @@ prof_init(const char * const version, const char * const status, const char *con "/c-test winshow_t ", "/c-test notify ", "/c-test sendline ", - "/c-test get recipient|room", + "/c-test get recipient|room|nick|occupants", "/c-test log debug|info|warning|error ", "/c-test count", "/c-test ping ", @@ -511,6 +539,8 @@ prof_init(const char * const version, const char * const status, const char *con { "sendline ", "Pass line to profanity to process" }, { "get recipient", "Show the current chat recipient, if in a chat window" }, { "get room", "Show the current room JID, if in a chat room" }, + { "get nick", "Show nickname in current room, if in a chat room" }, + { "get occupants", "Show occupants in current room, if in a chat room" }, { "log debug|info|warning|error ", "Log a message at the specified level" }, { "count", "Show the counter, incremented every 5 seconds by a worker thread" }, { "ping ", "Send an XMPP ping to the specified Jabber ID" }, @@ -559,7 +589,7 @@ prof_init(const char * const version, const char * const status, const char *con }; prof_completer_add("/c-test", cmd_ac); - char *get_ac[] = { "recipient", "room", NULL }; + char *get_ac[] = { "recipient", "room", "nick", "occupants", NULL }; prof_completer_add("/c-test get", get_ac); char *log_ac[] = { "debug", "info", "warning", "error", NULL };