aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--irc.h1
-rw-r--r--irc_commands.c48
-rw-r--r--irc_im.c17
-rw-r--r--irc_user.c19
4 files changed, 62 insertions, 23 deletions
diff --git a/irc.h b/irc.h
index 76ea650a..3a1a3520 100644
--- a/irc.h
+++ b/irc.h
@@ -209,6 +209,7 @@ int irc_user_free( irc_t *irc, irc_user_t *iu );
irc_user_t *irc_user_by_name( irc_t *irc, const char *nick );
int irc_user_set_nick( irc_user_t *iu, const char *new );
gint irc_user_cmp( gconstpointer a_, gconstpointer b_ );
+const char *irc_user_get_away( irc_user_t *iu );
/* irc_util.c */
char *set_eval_timezone( struct set *set, char *value );
diff --git a/irc_commands.c b/irc_commands.c
index f4c6ce48..35169607 100644
--- a/irc_commands.c
+++ b/irc_commands.c
@@ -383,10 +383,10 @@ static void irc_cmd_invite( irc_t *irc, char **cmd )
irc_send_num( irc, 482, "%s :Invite impossible; User/Channel non-existent or incompatible", channel );
}
+#endif
static void irc_cmd_userhost( irc_t *irc, char **cmd )
{
- user_t *u;
int i;
/* [TV] Usable USERHOST-implementation according to
@@ -396,18 +396,18 @@ static void irc_cmd_userhost( irc_t *irc, char **cmd )
*/
for( i = 1; cmd[i]; i ++ )
- if( ( u = user_find( irc, cmd[i] ) ) )
- {
- if( u->online && u->away )
- irc_send_num( irc, 302, ":%s=-%s@%s", u->nick, u->user, u->host );
- else
- irc_send_num( irc, 302, ":%s=+%s@%s", u->nick, u->user, u->host );
- }
+ {
+ irc_user_t *iu = irc_user_by_name( irc, cmd[i] );
+
+ if( iu )
+ irc_send_num( irc, 302, ":%s=%c%s@%s", iu->nick,
+ irc_user_get_away( iu ) ? '-' : '+',
+ iu->user, iu->host );
+ }
}
static void irc_cmd_ison( irc_t *irc, char **cmd )
{
- user_t *u;
char buff[IRC_MAX_LINE];
int lenleft, i;
@@ -423,17 +423,20 @@ static void irc_cmd_ison( irc_t *irc, char **cmd )
this = cmd[i];
while( *this )
{
+ irc_user_t *iu;
+
if( ( next = strchr( this, ' ' ) ) )
*next = 0;
- if( ( u = user_find( irc, this ) ) && u->online )
+ if( ( iu = irc_user_by_name( irc, this ) ) &&
+ iu->bu && iu->bu->flags & BEE_USER_ONLINE )
{
- lenleft -= strlen( u->nick ) + 1;
+ lenleft -= strlen( iu->nick ) + 1;
if( lenleft < 0 )
break;
- strcat( buff, u->nick );
+ strcat( buff, iu->nick );
strcat( buff, " " );
}
@@ -469,7 +472,7 @@ static void irc_cmd_watch( irc_t *irc, char **cmd )
for( i = 1; cmd[i]; i ++ )
{
char *nick;
- user_t *u;
+ irc_user_t *iu;
if( !cmd[i][0] || !cmd[i][1] )
break;
@@ -477,17 +480,19 @@ static void irc_cmd_watch( irc_t *irc, char **cmd )
nick = g_strdup( cmd[i] + 1 );
nick_lc( nick );
- u = user_find( irc, nick );
+ iu = irc_user_by_name( irc, nick );
if( cmd[i][0] == '+' )
{
if( !g_hash_table_lookup( irc->watches, nick ) )
g_hash_table_insert( irc->watches, nick, nick );
- if( u && u->online )
- irc_send_num( irc, 604, "%s %s %s %d :%s", u->nick, u->user, u->host, (int) time( NULL ), "is online" );
+ if( iu && iu->bu && iu->bu->flags & BEE_USER_ONLINE )
+ irc_send_num( irc, 604, "%s %s %s %d :%s", iu->nick, iu->user,
+ iu->host, (int) time( NULL ), "is online" );
else
- irc_send_num( irc, 605, "%s %s %s %d :%s", nick, "*", "*", (int) time( NULL ), "is offline" );
+ irc_send_num( irc, 605, "%s %s %s %d :%s", nick, "*", "*",
+ (int) time( NULL ), "is offline" );
}
else if( cmd[i][0] == '-' )
{
@@ -504,6 +509,7 @@ static void irc_cmd_watch( irc_t *irc, char **cmd )
}
}
+#if 0
static void irc_cmd_topic( irc_t *irc, char **cmd )
{
char *channel = cmd[1];
@@ -609,15 +615,15 @@ static const command_t irc_commands[] = {
{ "away", 0, irc_cmd_away, IRC_CMD_LOGGED_IN },
{ "version", 0, irc_cmd_version, IRC_CMD_LOGGED_IN },
{ "completions", 0, irc_cmd_completions, IRC_CMD_LOGGED_IN },
- { "oper", 2, irc_cmd_oper, IRC_CMD_LOGGED_IN },
-#if 0
- { "invite", 2, irc_cmd_invite, IRC_CMD_LOGGED_IN },
- { "notice", 1, irc_cmd_privmsg, 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 },
+#if 0
+ { "invite", 2, irc_cmd_invite, IRC_CMD_LOGGED_IN },
+ { "notice", 1, irc_cmd_privmsg, IRC_CMD_LOGGED_IN },
{ "topic", 1, irc_cmd_topic, IRC_CMD_LOGGED_IN },
#endif
+ { "oper", 2, irc_cmd_oper, IRC_CMD_LOGGED_IN },
{ "die", 0, NULL, IRC_CMD_OPER_ONLY | IRC_CMD_TO_MASTER },
{ "deaf", 0, NULL, IRC_CMD_OPER_ONLY | IRC_CMD_TO_MASTER },
{ "wallops", 1, NULL, IRC_CMD_OPER_ONLY | IRC_CMD_TO_MASTER },
diff --git a/irc_im.c b/irc_im.c
index dd015ba9..d6f66d74 100644
--- a/irc_im.c
+++ b/irc_im.c
@@ -79,14 +79,27 @@ static gboolean bee_irc_user_free( bee_t *bee, bee_user_t *bu )
static gboolean bee_irc_user_status( bee_t *bee, bee_user_t *bu, bee_user_t *old )
{
irc_t *irc = bee->ui_data;
+ irc_user_t *iu = bu->ui_data;
irc_channel_t *ic = irc->channels->data; /* For now, just pick the first channel. */
if( ( bu->flags & BEE_USER_ONLINE ) != ( old->flags & BEE_USER_ONLINE ) )
{
if( bu->flags & BEE_USER_ONLINE )
- irc_channel_add_user( ic, (irc_user_t*) bu->ui_data );
+ {
+ if( g_hash_table_lookup( irc->watches, iu->key ) )
+ irc_send_num( irc, 600, "%s %s %s %d :%s", iu->nick, iu->user,
+ iu->host, (int) time( NULL ), "logged online" );
+
+ irc_channel_add_user( ic, iu );
+ }
else
- irc_channel_del_user( ic, (irc_user_t*) bu->ui_data );
+ {
+ if( g_hash_table_lookup( irc->watches, iu->key ) )
+ irc_send_num( irc, 601, "%s %s %s %d :%s", iu->nick, iu->user,
+ iu->host, (int) time( NULL ), "logged offline" );
+
+ irc_channel_del_user( ic, iu );
+ }
}
return TRUE;
diff --git a/irc_user.c b/irc_user.c
index 7b2d4be1..13c6d5bd 100644
--- a/irc_user.c
+++ b/irc_user.c
@@ -132,6 +132,25 @@ gint irc_user_cmp( gconstpointer a_, gconstpointer b_ )
return strcmp( a->key, b->key );
}
+const char *irc_user_get_away( irc_user_t *iu )
+{
+ irc_t *irc = iu->irc;
+ bee_user_t *bu = iu->bu;
+
+ if( iu == irc->user )
+ return set_getstr( &irc->b->set, "away" );
+ else if( bu )
+ {
+ if( !bu->flags & BEE_USER_ONLINE )
+ return "Offline";
+ else if( bu->flags & BEE_USER_AWAY )
+ /* TODO: status msgs, etc. */
+ return bu->status;
+ }
+
+ return NULL;
+}
+
/* User-type dependent functions, for root/NickServ: */
static gboolean root_privmsg( irc_user_t *iu, const char *msg )
{