summaryrefslogtreecommitdiff
path: root/src/plugins/scripts/python
diff options
context:
space:
mode:
authorEmmanuel Bouthenot <kolter@openics.org>2006-02-16 16:10:25 +0000
committerEmmanuel Bouthenot <kolter@openics.org>2006-02-16 16:10:25 +0000
commit8855d39f44892dc91f7aaef536e49082ff8517f7 (patch)
tree229d3b42fd7dcbeff57a6b4b1f4c6f32fb68bf51 /src/plugins/scripts/python
parent91af3fe7285267bffceebc5e09575c4b93025ce0 (diff)
downloadweechat-8855d39f44892dc91f7aaef536e49082ff8517f7.zip
make possible to log with plugins / scripts
Diffstat (limited to 'src/plugins/scripts/python')
-rw-r--r--src/plugins/scripts/python/weechat-python.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/plugins/scripts/python/weechat-python.c b/src/plugins/scripts/python/weechat-python.c
index b33a61444..007ed3edc 100644
--- a/src/plugins/scripts/python/weechat-python.c
+++ b/src/plugins/scripts/python/weechat-python.c
@@ -248,6 +248,45 @@ weechat_python_print_infobar (PyObject *self, PyObject *args)
}
/*
+ * weechat_python_log: log message in server/channel (current or specified ones)
+ */
+
+static PyObject *
+weechat_python_log (PyObject *self, PyObject *args)
+{
+ char *message, *channel_name, *server_name;
+
+ /* make gcc happy */
+ (void) self;
+
+ if (!python_current_script)
+ {
+ python_plugin->printf_server (python_plugin,
+ "Python error: unable to log message, "
+ "script not initialized");
+ return Py_BuildValue ("i", 0);
+ }
+
+ message = NULL;
+ channel_name = NULL;
+ server_name = NULL;
+
+ if (!PyArg_ParseTuple (args, "s|ss", &message, &channel_name, &server_name))
+ {
+ python_plugin->printf_server (python_plugin,
+ "Python error: wrong parameters for "
+ "\"log\" function");
+ return Py_BuildValue ("i", 0);
+ }
+
+ python_plugin->log (python_plugin,
+ server_name, channel_name,
+ "%s", message);
+
+ return Py_BuildValue ("i", 1);
+}
+
+/*
* weechat_python_command: send command to server
*/
@@ -976,6 +1015,7 @@ PyMethodDef weechat_python_funcs[] = {
{ "register", weechat_python_register, METH_VARARGS, "" },
{ "prnt", weechat_python_print, METH_VARARGS, "" },
{ "print_infobar", weechat_python_print_infobar, METH_VARARGS, "" },
+ { "log", weechat_python_log, METH_VARARGS, "" },
{ "command", weechat_python_command, METH_VARARGS, "" },
{ "add_message_handler", weechat_python_add_message_handler, METH_VARARGS, "" },
{ "add_command_handler", weechat_python_add_command_handler, METH_VARARGS, "" },