From 88b63e6506160a2901ee28ff5036aea54ba947bb Mon Sep 17 00:00:00 2001 From: "B.Greenham" Date: Tue, 23 Feb 2010 02:59:35 -0500 Subject: [PATCH] Make the target user's modes show up in whois. --- include/numeric.h | 2 ++ modules/m_whois.c | 16 +++++++++++++++- src/messages.tab | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/include/numeric.h b/include/numeric.h index a43c740..1648189 100644 --- a/include/numeric.h +++ b/include/numeric.h @@ -204,6 +204,8 @@ extern const char *form_str(int); #define RPL_ENDOFMOTD 376 #define RPL_WHOISHOST 378 +#define RPL_WHOISMODES 379 + #define RPL_YOUREOPER 381 #define RPL_REHASHING 382 #define RPL_MYPORTIS 384 diff --git a/modules/m_whois.c b/modules/m_whois.c index 2519971..2b186f8 100644 --- a/modules/m_whois.c +++ b/modules/m_whois.c @@ -239,6 +239,8 @@ single_whois(struct Client *source_p, struct Client *target_p, int operspy) hook_data_client hdata; int visible; int extra_space = 0; + int i; + char *m; if(target_p->user == NULL) { @@ -330,7 +332,19 @@ single_whois(struct Client *source_p, struct Client *target_p, int operspy) sendto_one_numeric(source_p, RPL_WHOISBOT, form_str(RPL_WHOISBOT), target_p->name); - + + m = buf; + *m++ = '+'; + + for (i = 0; i < 128; i++) /* >= 127 is extended ascii */ + if (target_p->umodes & user_modes[i]) + *m++ = (char) i; + *m = '\0'; + + sendto_one_numeric(source_p, RPL_WHOISMODES, + form_str(RPL_WHOISMODES), + target_p->name, buf); + if(MyClient(target_p)) { if (IsDynSpoof(target_p) && (IsOper(source_p) || source_p == target_p)) diff --git a/src/messages.tab b/src/messages.tab index 2345a5b..12fb081 100644 --- a/src/messages.tab +++ b/src/messages.tab @@ -400,7 +400,7 @@ static const char * replies[] = { /* 376 RPL_ENDOFMOTD, */ ":%s 376 %s :End of /MOTD command.", /* 377 */ NULL, /* 378 RPL_WHOISHOST, */ "%s :is connecting from *@%s %s", -/* 379 */ NULL, +/* 379 RPL_WHOISMODES */ "%s :%s, /* 380 */ NULL, /* 381 RPL_YOUREOPER, */ ":%s 381 %s :You're a IRC operator! Did you know that? This message is FACTUAL.", /* 382 RPL_REHASHING, */ ":%s 382 %s %s :Rehashing",