about summary refs log tree commit diff stats
path: root/src/plugins/python_api.c
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2016-04-15 22:24:50 +0100
committerJames Booth <boothj5@gmail.com>2016-04-15 22:24:50 +0100
commitd90c47f28761b7535dcdced0212c22b6a25d3b1d (patch)
tree2415757cb1ef27740dc911db02181953738778be /src/plugins/python_api.c
parentb3a3351a350e60355f070c353cfbdcbaf5a66f05 (diff)
downloadprofani-tty-d90c47f28761b7535dcdced0212c22b6a25d3b1d.tar.gz
Plugins: Added more muc hooks
Diffstat (limited to 'src/plugins/python_api.c')
-rw-r--r--src/plugins/python_api.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/plugins/python_api.c b/src/plugins/python_api.c
index d3f684b1..34e81f11 100644
--- a/src/plugins/python_api.c
+++ b/src/plugins/python_api.c
@@ -316,6 +316,38 @@ python_api_get_current_muc(PyObject *self, PyObject *args)
     }
 }
 
+static PyObject *
+python_api_get_current_nick(PyObject *self, PyObject *args)
+{
+    allow_python_threads();
+    char *nick = api_get_current_nick();
+    disable_python_threads();
+    if (nick) {
+        return Py_BuildValue("s", nick);
+    } else {
+        return Py_BuildValue("");
+    }
+}
+
+static PyObject*
+python_api_get_current_occupants(PyObject *self, PyObject *args)
+{
+    allow_python_threads();
+    char **occupants = api_get_current_occupants();
+    disable_python_threads();
+    PyObject *result = PyList_New(0);
+    if (occupants) {
+        int len = g_strv_length(occupants);
+        int i = 0;
+        for (i = 0; i < len; i++) {
+            PyList_Append(result, Py_BuildValue("s", occupants[i]));
+        }
+        return result;
+    } else {
+        return result;
+    }
+}
+
 static PyObject*
 python_api_current_win_is_console(PyObject *self, PyObject *args)
 {
@@ -714,6 +746,8 @@ static PyMethodDef apiMethods[] = {
     { "notify", python_api_notify, METH_VARARGS, "Send desktop notification." },
     { "get_current_recipient", python_api_get_current_recipient, METH_VARARGS, "Return the jid of the recipient of the current window." },
     { "get_current_muc", python_api_get_current_muc, METH_VARARGS, "Return the jid of the room of the current window." },
+    { "get_current_nick", python_api_get_current_nick, METH_VARARGS, "Return nickname in current room." },
+    { "get_current_occupants", python_api_get_current_occupants, METH_VARARGS, "Return list of occupants in current room." },
     { "current_win_is_console", python_api_current_win_is_console, METH_VARARGS, "Returns whether the current window is the console." },
     { "log_debug", python_api_log_debug, METH_VARARGS, "Log a debug message" },
     { "log_info", python_api_log_info, METH_VARARGS, "Log an info message" },