diff options
| -rw-r--r-- | irc.c | 2 | ||||
| -rw-r--r-- | irc.h | 12 | ||||
| -rw-r--r-- | irc_channel.c | 3 | ||||
| -rw-r--r-- | irc_send.c | 21 | ||||
| -rw-r--r-- | irc_user.c | 5 | 
5 files changed, 37 insertions, 6 deletions
@@ -623,6 +623,8 @@ int irc_check_login( irc_t *irc )  			irc_channel_set_topic( ic, CONTROL_TOPIC, irc->root );  			irc_channel_add_user( ic, irc->user ); +			irc->last_root_cmd = g_strdup( ROOT_CHAN ); +			  			return 1;  		}  	} @@ -64,6 +64,8 @@ typedef struct irc  	struct irc_user *root;  	struct irc_user *user; +	 +	char *last_root_cmd;  	char *password; /* HACK: Used to save the user's password, but before  	                   logging in, this may contain a password we should @@ -86,6 +88,11 @@ typedef struct irc  	struct bee *b;  } irc_t; +typedef enum +{ +	IRC_USER_PRIVATE = 1, +} irc_user_flags_t; +  typedef struct irc_user  {  	irc_t *irc; @@ -98,12 +105,12 @@ typedef struct irc_user  	/* Nickname in lowercase for case sensitive searches */  	char *key; -	char is_private; +	irc_user_flags_t flags;  	char *sendbuf;  	int sendbuf_len;  	guint sendbuf_timer; -	int sendbuf_flags; +	//int sendbuf_flags;  	//struct user *b; @@ -189,6 +196,7 @@ 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 ); +void irc_send_msg( irc_user_t *iu, const char *type, const char *dst, const char *msg );  /* irc_user.c */  irc_user_t *irc_user_new( irc_t *irc, const char *nick ); diff --git a/irc_channel.c b/irc_channel.c index ec0433c1..3afdddee 100644 --- a/irc_channel.c +++ b/irc_channel.c @@ -138,6 +138,9 @@ gboolean irc_channel_name_ok( const char *name )  /* Channel-type dependent functions, for control channels: */  static gboolean control_channel_privmsg( irc_channel_t *ic, const char *msg )  { +	g_free( ic->irc->last_root_cmd ); +	ic->irc->last_root_cmd = g_strdup( ic->name ); +	  	root_command_string( ic->irc, msg );  	return TRUE; @@ -108,18 +108,33 @@ void irc_send_motd( irc_t *irc )  	}  } -/* FIXME/REPLACEME */  void irc_usermsg( irc_t *irc, char *format, ... )  { +	irc_channel_t *ic; +	irc_user_t *iu;  	char text[1024];  	va_list params; -	//irc_user_t *iu;  	va_start( params, format );  	g_vsnprintf( text, sizeof( text ), format, params );  	va_end( params ); -	fprintf( stderr, "%s\n", text ); +	if( irc->last_root_cmd && +	    irc_channel_name_ok( irc->last_root_cmd ) &&  +	    ( ic = irc_channel_by_name( irc, irc->last_root_cmd ) ) && +	    ic->flags & IRC_CHANNEL_JOINED ) +		irc_send_msg( irc->root, "PRIVMSG", irc->last_root_cmd, text ); +	else if( irc->last_root_cmd && +	         ( iu = irc_user_by_name( irc, irc->last_root_cmd ) ) && +	         iu->f == &irc_user_root_funcs ) +		irc_send_msg( iu, "PRIVMSG", irc->user->nick, text ); +	else +	{ +		g_free( irc->last_root_cmd ); +		irc->last_root_cmd = NULL; +		 +		irc_send_msg( irc->root, "PRIVMSG", irc->user->nick, text ); +	}  	/*return( irc_msgfrom( irc, u->nick, text ) );*/  } @@ -33,7 +33,7 @@ irc_user_t *irc_user_new( irc_t *irc, const char *nick )  	iu->nick = g_strdup( nick );  	iu->user = iu->host = iu->fullname = iu->nick; -	iu->is_private = set_getbool( &irc->b->set, "private" ); +	iu->flags = set_getbool( &irc->b->set, "private" ) ? IRC_USER_PRIVATE : 0;  	iu->key = g_strdup( nick );  	nick_lc( iu->key ); @@ -116,6 +116,9 @@ gint irc_user_cmp( gconstpointer a_, gconstpointer b_ )  /* User-type dependent functions, for root/NickServ: */  static gboolean root_privmsg( irc_user_t *iu, const char *msg )  { +	g_free( iu->irc->last_root_cmd ); +	iu->irc->last_root_cmd = g_strdup( iu->nick ); +	  	root_command_string( iu->irc, msg );  	return TRUE;  | 
