+static PyObject*
+emb_get_info(UNUSED_ARG(PyObject *self), UNUSED_ARG(PyObject *args))
+{
+ /* return some info about the general setup
+ * of X3, such as what the chanserv's nickname
+ * is.
+ */
+
+
+ return Py_BuildValue("{s:s,s:s,s:s,s:s,s:s}",
+ "chanserv", chanserv? chanserv->nick : "ChanServ",
+ "nickserv", nickserv?nickserv->nick : "NickServ",
+ "opserv", opserv?opserv->nick : "OpServ",
+ "global", global?global->nick : "Global",
+ "spamserv", spamserv?spamserv->nick : "SpamServ");
+}
+
+static PyObject*
+emb_log_module(UNUSED_ARG(PyObject *self), PyObject *args)
+{
+ /* a gateway to standard X3 logging subsystem.
+ * level is a value 0 to 9 as defined by the log_severity enum in log.h.
+ *
+ * for now, all logs go to the PY_LOG log. In the future this will change.
+ */
+ char *message;
+ int ret = 0;
+ int level;
+
+
+ if(!PyArg_ParseTuple(args, "is", &level, &message))
+ return NULL;
+
+ log_module(PY_LOG, level, "%s", message);
+
+ return Py_BuildValue("i", ret);
+}
+
+static PyObject*
+emb_kill(UNUSED_ARG(PyObject* self), PyObject* args) {
+ char const* from_nick, *target_nick, *message;
+ struct userNode *target;
+ struct service *service;
+
+ if (!PyArg_ParseTuple(args, "sss", &from_nick, &target_nick, &message))
+ return NULL;
+
+ if(!(service = service_find(from_nick))) {
+ PyErr_SetString(PyExc_Exception, "unknown service user specified as from user");
+ return NULL;
+ }
+
+ if ((target = GetUserH(target_nick)) == NULL) {
+ PyErr_SetString(PyExc_Exception, "unknown target user");
+ return NULL;
+ }
+
+ irc_kill(service->bot, target, message);
+
+ return Py_None;
+}
+
+struct py_timeq_extra {
+ PyObject* func;
+ PyObject* arg;
+};
+
+static
+void py_timeq_callback(void* data) {
+ struct py_timeq_extra* extra = (struct py_timeq_extra*)data;
+
+ PyObject* retval = PyObject_Call(extra->func, extra->arg, NULL);
+ Py_XDECREF(retval);
+
+ Py_DECREF(extra->func);
+ Py_DECREF(extra->arg);
+}
+
+static PyObject*
+emb_timeq_add(UNUSED_ARG(PyObject* self), PyObject* args) {
+ time_t when;
+ PyObject* func, *arg;
+ struct py_timeq_extra* extra;
+
+ if (!PyArg_ParseTuple(args, "lOO", &when, &func, &arg))
+ return NULL;
+
+ if (!PyFunction_Check(func)) {
+ PyErr_SetString(PyExc_Exception, "first argument must be a function");
+ return NULL;
+ }
+
+ if (!PyTuple_Check(arg)) {
+ PyErr_SetString(PyExc_Exception, "second argument must be a tuple");
+ return NULL;
+ }
+
+ extra = malloc(sizeof(struct py_timeq_extra));
+ if (extra == NULL) {
+ PyErr_SetString(PyExc_Exception, "out of memory");
+ return NULL;
+ }
+
+ Py_INCREF(func);
+ Py_INCREF(arg);
+
+ extra->func = func;
+ extra->arg = arg;
+
+ timeq_add(when, py_timeq_callback, (void*)extra);
+
+ return Py_None;
+}