From: hstuart Date: Sun, 11 Oct 2009 20:42:27 +0000 (+0000) Subject: mod-python: add emb_kick function X-Git-Tag: 1.9~152 X-Git-Url: https://jfr.im/git/irc/evilnet/x3.git/commitdiff_plain/749f05652db16ed3dcb6104589886477ce62cb31 mod-python: add emb_kick function --- diff --git a/ChangeLog b/ChangeLog index f193bd7..56deaf5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,10 @@ /*********************************************************************** X3 ChangeLog +2009-10-11 Henrik Stuart + + * src/mod-python.c: add emb_kick function. + 2009-10-11 Henrik Stuart * src/mod-python.c: add emb_get_config function. diff --git a/src/mod-python.c b/src/mod-python.c index 4ffab92..42317dc 100644 --- a/src/mod-python.c +++ b/src/mod-python.c @@ -827,6 +827,36 @@ emb_get_config(UNUSED_ARG(PyObject* self), PyObject* args) { return dict; } +static PyObject* emb_kick(UNUSED_ARG(PyObject* self), PyObject* args) { + struct userNode* who, *target; + struct chanNode* channel; + char const* msg; + + char const* who_s, *target_s, *channel_s; + + if (!PyArg_ParseTuple(args, "ssss", &who_s, &target_s, &channel_s, &msg)) + return NULL; + + if ((who = GetUserH(who_s)) == NULL) { + PyErr_SetString(PyExc_Exception, "no such user"); + return NULL; + } + + if ((target = GetUserH(target_s)) == NULL) { + PyErr_SetString(PyExc_Exception, "no such target"); + return NULL; + } + + if ((channel = GetChannel(channel_s)) == NULL) { + PyErr_SetString(PyExc_Exception, "no such channel"); + return NULL; + } + + irc_kick(who, target, channel, msg); + + return Py_None; +} + static PyMethodDef EmbMethods[] = { /* Communication methods */ {"dump", emb_dump, METH_VARARGS, "Dump raw P10 line to server"}, @@ -840,7 +870,7 @@ static PyMethodDef EmbMethods[] = { //TODO: {"unshun" //TODO: {"gline", emb_gline, METH_VARARGS, "gline a mask"}, //TODO: {"ungline", emb_ungline, METH_VARARGS, "remove a gline"}, -//TODO: {"kick", emb_kick, METH_VARARGS, "kick someone from a channel"}, + {"kick", emb_kick, METH_VARARGS, "kick someone from a channel"}, //TODO: {"channel_mode", emb_channel_mode, METH_VARARGS, "set modes on a channel"}, //TODO: {"user_mode", emb_user_mode, METH_VARARGS, "Have x3 set usermodes on one of its own nicks"}, //