+
+ name = PyString_FromString("nick_change");
+ if (name == NULL) {
+ err = "unable to allocate memory for handler function name";
+ goto cleanup;
+ }
+
+ oldnick = PyString_FromString(old_nick);
+
+ retval = PyObject_CallMethodObjArgs(handler_object, name, usr, oldnick, NULL);
+ if (retval == NULL) {
+ err = "error calling nick_change handler";
+ goto cleanup;
+ }
+
+cleanup:
+ Py_XDECREF(usr);
+ Py_XDECREF(name);
+ Py_XDECREF(oldnick);
+ Py_XDECREF(retval);
+
+ if (err != NULL)
+ log_module(PY_LOG, LOG_WARNING, "%s", err);
+}
+
+void python_handle_del_user(struct userNode *user, struct userNode *killer, const char *why, UNUSED_ARG(void *extra)) {
+ PyObject *usr = NULL, *killr = NULL, *name = NULL;
+ PyObject *reason = NULL, *retval = NULL;
+ char const* err = NULL;
+
+ if (handler_object == NULL) {
+ err = "No Python handler is allocated. Ignoring python_handle_server_link.";
+ goto cleanup;
+ }
+
+ if (user == NULL) {
+ Py_INCREF(Py_None);
+ usr = Py_None;
+ } else {
+ usr = pyobj_from_usernode(user);
+ if (usr == NULL) {
+ err = "unable to allocate usernode for user";
+ goto cleanup;
+ }
+ }
+
+ if (killer == NULL) {
+ Py_INCREF(Py_None);
+ killr = Py_None;
+ } else {
+ killr = pyobj_from_usernode(killer);
+ if (killr == NULL) {
+ err = "unable to allocate usernode for killer";
+ goto cleanup;
+ }
+ }
+
+ if (why == NULL) {
+ Py_INCREF(Py_None);
+ reason = Py_None;
+ } else {
+ reason = PyString_FromString(why);
+ if (reason == NULL) {
+ err = "unable to allocate memory for reason";
+ goto cleanup;
+ }
+ }
+
+ name = PyString_FromString("del_user");
+ if (name == NULL) {
+ err = "unable to allocate memory for handler function name";
+ goto cleanup;
+ }
+
+ retval = PyObject_CallMethodObjArgs(handler_object, name, usr, killr, reason, NULL);
+ if (retval == NULL) {
+ err = "error calling del_user handler";
+ goto cleanup;
+ }
+
+cleanup:
+ Py_XDECREF(usr);
+ Py_XDECREF(killr);
+ Py_XDECREF(name);
+ Py_XDECREF(reason);
+ Py_XDECREF(retval);
+
+ if (err != NULL)
+ log_module(PY_LOG, LOG_WARNING, "%s", err);