コード例 #1
0
ファイル: root_commands.c プロジェクト: EionRobb/bitlbee
static void cmd_group(irc_t *irc, char **cmd)
{
	GSList *l;
	int len;

	len = strlen(cmd[1]);
	if (g_strncasecmp(cmd[1], "list", len) == 0) {
		int n = 0;

		if (strchr(irc->umode, 'b')) {
			irc_rootmsg(irc, "Group list:");
		}

		for (l = irc->b->groups; l; l = l->next) {
			bee_group_t *bg = l->data;
			irc_rootmsg(irc, "%d. %s", n++, bg->name);
		}
		irc_rootmsg(irc, "End of group list");
	} else if (g_strncasecmp(cmd[1], "info", len) == 0) {
		bee_group_t *bg;
		int n = 0;

		MIN_ARGS(2);
		bg = bee_group_by_name(irc->b, cmd[2], FALSE);

		if (bg) {
			if (strchr(irc->umode, 'b')) {
				irc_rootmsg(irc, "Members of %s:", cmd[2]);
			}
			for (l = irc->b->users; l; l = l->next) {
				bee_user_t *bu = l->data;
				if (bu->group == bg) {
					irc_rootmsg(irc, "%d. %s", n++, bu->nick ? : bu->handle);
				}
			}
			irc_rootmsg(irc, "End of member list");
		} else {
コード例 #2
0
ファイル: irc_commands.c プロジェクト: dkrisman/Bitlbee
static void irc_cmd_join( irc_t *irc, char **cmd )
{
	char *comma, *s = cmd[1];
	
	while( s )
	{
		irc_channel_t *ic;
		
		if( ( comma = strchr( s, ',' ) ) )
			*comma = '\0';
		
		if( ( ic = irc_channel_by_name( irc, s ) ) == NULL &&
		    ( ic = irc_channel_new( irc, s ) ) )
		{
			if( strcmp( set_getstr( &ic->set, "type" ), "control" ) != 0 )
			{
				/* Autoconfiguration is for control channels only ATM. */
			}
			else if( bee_group_by_name( ic->irc->b, ic->name + 1, FALSE ) )
			{
				set_setstr( &ic->set, "group", ic->name + 1 );
				set_setstr( &ic->set, "fill_by", "group" );
			}
			else if( set_setstr( &ic->set, "protocol", ic->name + 1 ) )
			{
				set_setstr( &ic->set, "fill_by", "protocol" );
			}
			else if( set_setstr( &ic->set, "account", ic->name + 1 ) )
			{
				set_setstr( &ic->set, "fill_by", "account" );
			}
			else
			{
				/* The set commands above will run this already,
				   but if we didn't hit any, we have to fill the
				   channel with the default population. */
				bee_irc_channel_update( ic->irc, ic, NULL );
			}
		}
		else if( ic == NULL )
		{
			irc_send_num( irc, 479, "%s :Invalid channel name", s );
			goto next;
		}
		
		if( ic->flags & IRC_CHANNEL_JOINED )
			/* Dude, you're already there...
			   RFC doesn't have any reply for that though? */
			goto next;
		
		if( ic->f->join && !ic->f->join( ic ) )
			/* The story is: FALSE either means the handler
			   showed an error message, or is doing some work
			   before the join should be confirmed. (In the
			   latter case, the caller should take care of that
			   confirmation.) TRUE means all's good, let the
			   user join the channel right away. */
			goto next;
		
		irc_channel_add_user( ic, irc->user );
		
next:
		if( comma )
		{
			s = comma + 1;
			*comma = ',';
		}
		else
			break;
	}
}