aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--irc.h1
-rw-r--r--irc_commands.c49
-rw-r--r--irc_send.c15
3 files changed, 32 insertions, 33 deletions
diff --git a/irc.h b/irc.h
index db629a19..33f25538 100644
--- a/irc.h
+++ b/irc.h
@@ -169,6 +169,7 @@ void irc_send_part( irc_channel_t *ic, irc_user_t *iu, const char *reason );
void irc_send_names( irc_channel_t *ic );
void irc_send_topic( irc_channel_t *ic, gboolean topic_change );
void irc_send_whois( irc_user_t *iu );
+void irc_send_who( irc_t *irc, GSList *l, const char *channel );
/* irc_user.c */
irc_user_t *irc_user_new( irc_t *irc, const char *nick );
diff --git a/irc_commands.c b/irc_commands.c
index 5f9ae39f..b06e59bd 100644
--- a/irc_commands.c
+++ b/irc_commands.c
@@ -215,6 +215,21 @@ static void irc_cmd_mode( irc_t *irc, char **cmd )
}
}
+static void irc_cmd_who( irc_t *irc, char **cmd )
+{
+ char *channel = cmd[1];
+ irc_channel_t *ic;
+ struct groupchat *c;
+ GList *l;
+
+ if( !channel || *channel == '0' || *channel == '*' || !*channel )
+ irc_send_who( irc, irc->users, "**" );
+ else if( ( ic = irc_channel_by_name( irc, channel ) ) )
+ irc_send_who( irc, ic->users, channel );
+ else
+ irc_send_num( irc, 403, "%s :No such channel", channel );
+}
+
#if 0
//#if 0
static void irc_cmd_oper( irc_t *irc, char **cmd )
@@ -301,38 +316,6 @@ static void irc_cmd_privmsg( irc_t *irc, char **cmd )
}
}
-static void irc_cmd_who( irc_t *irc, char **cmd )
-{
- char *channel = cmd[1];
- user_t *u = irc->users;
- struct groupchat *c;
- GList *l;
-
- if( !channel || *channel == '0' || *channel == '*' || !*channel )
- while( u )
- {
- irc_send_num( irc, 352, "%s %s %s %s %s %c :0 %s", u->online ? irc->channel : "*", u->user, u->host, irc->myhost, u->nick, u->online ? ( u->away ? 'G' : 'H' ) : 'G', u->realname );
- u = u->next;
- }
- else if( g_strcasecmp( channel, irc->channel ) == 0 )
- while( u )
- {
- if( u->online )
- irc_send_num( irc, 352, "%s %s %s %s %s %c :0 %s", channel, u->user, u->host, irc->myhost, u->nick, u->away ? 'G' : 'H', u->realname );
- u = u->next;
- }
- else if( ( c = irc_chat_by_channel( irc, channel ) ) )
- for( l = c->in_room; l; l = l->next )
- {
- if( ( u = user_findhandle( c->ic, l->data ) ) )
- irc_send_num( irc, 352, "%s %s %s %s %s %c :0 %s", channel, u->user, u->host, irc->myhost, u->nick, u->away ? 'G' : 'H', u->realname );
- }
- else if( ( u = user_find( irc, channel ) ) )
- irc_send_num( irc, 352, "%s %s %s %s %s %c :0 %s", channel, u->user, u->host, irc->myhost, u->nick, u->online ? ( u->away ? 'G' : 'H' ) : 'G', u->realname );
-
- irc_send_num( irc, 315, "%s :End of /WHO list", channel?channel:"**" );
-}
-
static void irc_cmd_userhost( irc_t *irc, char **cmd )
{
user_t *u;
@@ -570,12 +553,12 @@ static const command_t irc_commands[] = {
{ "whowas", 1, irc_cmd_whowas, IRC_CMD_LOGGED_IN },
{ "motd", 0, irc_cmd_motd, IRC_CMD_LOGGED_IN },
{ "mode", 1, irc_cmd_mode, IRC_CMD_LOGGED_IN },
+ { "who", 0, irc_cmd_who, IRC_CMD_LOGGED_IN },
#if 0
{ "oper", 2, irc_cmd_oper, IRC_CMD_LOGGED_IN },
{ "invite", 2, irc_cmd_invite, IRC_CMD_LOGGED_IN },
{ "privmsg", 1, irc_cmd_privmsg, IRC_CMD_LOGGED_IN },
{ "notice", 1, irc_cmd_privmsg, IRC_CMD_LOGGED_IN },
- { "who", 0, irc_cmd_who, IRC_CMD_LOGGED_IN },
{ "userhost", 1, irc_cmd_userhost, IRC_CMD_LOGGED_IN },
{ "ison", 1, irc_cmd_ison, IRC_CMD_LOGGED_IN },
{ "watch", 1, irc_cmd_watch, IRC_CMD_LOGGED_IN },
diff --git a/irc_send.c b/irc_send.c
index f0c3958c..97fb3071 100644
--- a/irc_send.c
+++ b/irc_send.c
@@ -224,3 +224,18 @@ void irc_send_whois( irc_user_t *iu )
irc_send_num( irc, 318, "%s :End of /WHOIS list", iu->nick );
}
+
+void irc_send_who( irc_t *irc, GSList *l, const char *channel )
+{
+ while( l )
+ {
+ irc_user_t *iu = l->data;
+ /* TODO(wilmer): Restore away/channel information here */
+ irc_send_num( irc, 352, "%s %s %s %s %s %c :0 %s",
+ "*", iu->user, iu->host, irc->root->host,
+ iu->nick, 'H', iu->fullname );
+ l = l->next;
+ }
+
+ irc_send_num( irc, 315, "%s :End of /WHO list", channel );
+}