mirror of
https://github.com/irssi/irssi.git
synced 2025-01-03 14:56:47 -05:00
add constants for WHOX queries
This commit is contained in:
parent
18ee6bb6f9
commit
b957d3ad4b
@ -50,7 +50,21 @@ loop:
|
||||
#include <irssi/src/irc/core/irc-channels.h>
|
||||
#include <irssi/src/irc/core/servers-redirect.h>
|
||||
|
||||
#define WHO_Ps_PPtna_745 "WHO %s %%tna,745"
|
||||
/* here are the WHOX commands we send. the full spec can be found on [1].
|
||||
|
||||
(1) WHOX_CHANNEL_FULL_CMD for getting the user list when we join a channel. we request the fields
|
||||
c (channel), u (user), h (host), n (nick), f (flags), d (hops), a (important, account!), and
|
||||
r (the real name goes last because it os the only that can contain spaces.) we request all
|
||||
those fields as they are also included in the "regular" WHO reply we would get without WHOX.
|
||||
|
||||
(2) WHOX_USERACCOUNT_CMD for getting the account names of people that joined. this code is
|
||||
obviously only used when we don't have extended-joins. we request n (nick) and a (account)
|
||||
only, and we only send WHO nick with this command.
|
||||
|
||||
[1] https://github.com/UndernetIRC/ircu2/blob/u2_10_12_branch/doc/readme.who
|
||||
*/
|
||||
#define WHOX_CHANNEL_FULL_CMD "WHO %s %%tcuhnfdar," WHOX_CHANNEL_FULL_ID
|
||||
#define WHOX_USERACCOUNT_CMD "WHO %s %%tna," WHOX_USERACCOUNT_ID
|
||||
|
||||
static void sig_connected(IRC_SERVER_REC *server)
|
||||
{
|
||||
@ -219,7 +233,7 @@ static void query_send(IRC_SERVER_REC *server, int query)
|
||||
case CHANNEL_QUERY_WHO:
|
||||
if (server->isupport != NULL &&
|
||||
g_hash_table_lookup(server->isupport, "whox") != NULL) {
|
||||
cmd = g_strdup_printf("WHO %s %%tcuhnfdar,743", chanstr_commas);
|
||||
cmd = g_strdup_printf(WHOX_CHANNEL_FULL_CMD, chanstr_commas);
|
||||
} else {
|
||||
cmd = g_strdup_printf("WHO %s", chanstr_commas);
|
||||
}
|
||||
@ -399,7 +413,7 @@ void irc_channels_query_purge_accountquery(IRC_SERVER_REC *server, const char *n
|
||||
|
||||
/* if it was removed we may have an outstanding query */
|
||||
if (was_removed) {
|
||||
target_cmd = g_strdup_printf(WHO_Ps_PPtna_745 "\r\n", nick);
|
||||
target_cmd = g_strdup_printf(WHOX_USERACCOUNT_CMD "\r\n", nick);
|
||||
|
||||
/* remove queued WHO command */
|
||||
prev = NULL;
|
||||
@ -519,7 +533,7 @@ static void sig_event_join(IRC_SERVER_REC *server, const char *data, const char
|
||||
"event 354", "silent event whox useraccount", /* */
|
||||
"", "event empty", /* */
|
||||
NULL);
|
||||
cmd = g_strdup_printf(WHO_Ps_PPtna_745, nick);
|
||||
cmd = g_strdup_printf(WHOX_USERACCOUNT_CMD, nick);
|
||||
g_hash_table_add(server->chanqueries->accountqueries, g_strdup(nick));
|
||||
/* queue the command */
|
||||
irc_send_cmd_full(server, cmd, FALSE, FALSE, FALSE);
|
||||
|
@ -19,6 +19,10 @@ enum {
|
||||
CHANNEL_QUERIES
|
||||
};
|
||||
|
||||
/* arbitrary 3-digit identifiers so we can find our WHOX responses */
|
||||
#define WHOX_CHANNEL_FULL_ID "743"
|
||||
#define WHOX_USERACCOUNT_ID "745"
|
||||
|
||||
#define CHANNEL_IS_MODE_QUERY(a) ((a) != CHANNEL_QUERY_WHO)
|
||||
|
||||
#define STRUCT_SERVER_REC IRC_SERVER_REC
|
||||
|
@ -274,7 +274,7 @@ static void event_who(SERVER_REC *server, const char *data)
|
||||
g_free(params);
|
||||
}
|
||||
|
||||
static void event_whox_743(SERVER_REC *server, const char *data)
|
||||
static void event_whox_channel_full(SERVER_REC *server, const char *data)
|
||||
{
|
||||
char *params, *id, *nick, *channel, *user, *host, *stat, *hops, *account, *realname;
|
||||
|
||||
@ -283,7 +283,7 @@ static void event_whox_743(SERVER_REC *server, const char *data)
|
||||
params = event_get_params(data, 10, NULL, &id, &channel, &user, &host, &nick, &stat, &hops,
|
||||
&account, &realname);
|
||||
|
||||
if (g_strcmp0(id, "743") != 0) {
|
||||
if (g_strcmp0(id, WHOX_CHANNEL_FULL_ID) != 0) {
|
||||
g_free(params);
|
||||
return;
|
||||
}
|
||||
@ -293,7 +293,7 @@ static void event_whox_743(SERVER_REC *server, const char *data)
|
||||
g_free(params);
|
||||
}
|
||||
|
||||
static void event_whox_745(IRC_SERVER_REC *server, const char *data)
|
||||
static void event_whox_useraccount(IRC_SERVER_REC *server, const char *data)
|
||||
{
|
||||
char *params, *id, *nick, *account;
|
||||
GSList *nicks, *tmp;
|
||||
@ -302,7 +302,7 @@ static void event_whox_745(IRC_SERVER_REC *server, const char *data)
|
||||
|
||||
params = event_get_params(data, 4, NULL, &id, &nick, &account);
|
||||
|
||||
if (g_strcmp0(id, "745") != 0) {
|
||||
if (g_strcmp0(id, WHOX_USERACCOUNT_ID) != 0) {
|
||||
g_free(params);
|
||||
return;
|
||||
}
|
||||
@ -601,10 +601,10 @@ void irc_nicklist_init(void)
|
||||
{
|
||||
signal_add_first("event nick", (SIGNAL_FUNC) event_nick);
|
||||
signal_add_first("event 352", (SIGNAL_FUNC) event_who);
|
||||
signal_add_first("event 354", (SIGNAL_FUNC) event_whox_743);
|
||||
signal_add_first("event 354", (SIGNAL_FUNC) event_whox_channel_full);
|
||||
signal_add("silent event who", (SIGNAL_FUNC) event_who);
|
||||
signal_add("silent event whox", (SIGNAL_FUNC) event_whox_743);
|
||||
signal_add("silent event whox useraccount", (SIGNAL_FUNC) event_whox_745);
|
||||
signal_add("silent event whox", (SIGNAL_FUNC) event_whox_channel_full);
|
||||
signal_add("silent event whox useraccount", (SIGNAL_FUNC) event_whox_useraccount);
|
||||
signal_add("silent event whois", (SIGNAL_FUNC) event_whois);
|
||||
signal_add_first("event 311", (SIGNAL_FUNC) event_whois);
|
||||
signal_add_first("whois away", (SIGNAL_FUNC) event_whois_away);
|
||||
@ -628,10 +628,10 @@ void irc_nicklist_deinit(void)
|
||||
{
|
||||
signal_remove("event nick", (SIGNAL_FUNC) event_nick);
|
||||
signal_remove("event 352", (SIGNAL_FUNC) event_who);
|
||||
signal_remove("event 354", (SIGNAL_FUNC) event_whox_743);
|
||||
signal_remove("event 354", (SIGNAL_FUNC) event_whox_channel_full);
|
||||
signal_remove("silent event who", (SIGNAL_FUNC) event_who);
|
||||
signal_remove("silent event whox", (SIGNAL_FUNC) event_whox_743);
|
||||
signal_remove("silent event whox useraccount", (SIGNAL_FUNC) event_whox_745);
|
||||
signal_remove("silent event whox", (SIGNAL_FUNC) event_whox_channel_full);
|
||||
signal_remove("silent event whox useraccount", (SIGNAL_FUNC) event_whox_useraccount);
|
||||
signal_remove("silent event whois", (SIGNAL_FUNC) event_whois);
|
||||
signal_remove("event 311", (SIGNAL_FUNC) event_whois);
|
||||
signal_remove("whois away", (SIGNAL_FUNC) event_whois_away);
|
||||
|
Loading…
Reference in New Issue
Block a user