static PyObject *PyIrcServer_redirect_get_signal(PyIrcServer *self, PyObject *args, PyObject *kwds) { static char *kwlist[] = {"prefix", "event", "args", NULL}; char *prefix = ""; char *event = ""; char *pargs = ""; RET_NULL_IF_INVALID(self->data); if (!PyArg_ParseTupleAndKeywords(args, kwds, "sss", kwlist, &prefix, &event, &pargs)) return NULL; RET_AS_STRING_OR_NONE(server_redirect_get_signal(self->data, prefix, event, pargs)); }
static void sig_server_event(IRC_SERVER_REC *server, const char *line, const char *nick, const char *address) { GSList *tmp; void *client; const char *signal; char *event, *args; int redirected; g_return_if_fail(line != NULL); if (!IS_IRC_SERVER(server)) return; /* get command.. */ event = g_strconcat("event ", line, NULL); args = strchr(event+6, ' '); if (args != NULL) *args++ = '\0'; else args = ""; while (*args == ' ') args++; ascii_strdown(event); signal = server_redirect_peek_signal(server, nick, event, args, &redirected); if ((signal != NULL && strncmp(signal, "proxy ", 6) != 0) || (signal == NULL && redirected)) { /* we want to send this to one client (or proxy itself) only */ /* proxy only */ g_free(event); return; } if (signal != NULL) { server_redirect_get_signal(server, nick, event, args); if (sscanf(signal+6, "%p", &client) == 1) { /* send it to specific client only */ if (g_slist_find(proxy_clients, client) != NULL) net_sendbuffer_send(((CLIENT_REC *) client)->handle, next_line->str, next_line->len); g_free(event); signal_stop(); return; } } if (g_strcmp0(event, "event privmsg") == 0 && strstr(args, " :\001") != NULL && strstr(args, " :\001ACTION") == NULL) { /* CTCP - either answer ourself or forward it to one client */ for (tmp = proxy_clients; tmp != NULL; tmp = tmp->next) { CLIENT_REC *rec = tmp->data; if (rec->want_ctcp == 1) { /* only CTCP for the chatnet where client is connected to will be forwarded */ if (strstr(rec->proxy_address, server->connrec->chatnet) != NULL) { net_sendbuffer_send(rec->handle, next_line->str, next_line->len); signal_stop(); } } } g_free(event); return; } if (g_strcmp0(event, "event ping") == 0 || g_strcmp0(event, "event pong") == 0) { /* We want to answer ourself to PINGs and CTCPs. Also hide PONGs from clients. */ g_free(event); return; } /* send the data to clients.. */ proxy_outdata_all(server, "%s", next_line->str); g_free(event); }