예제 #1
0
static void sig_message_own_private(SERVER_REC *server, const char *msg,
				    const char *target, const char *origtarget)
{
	QUERY_REC *query;
        char *freemsg = NULL;

	g_return_if_fail(server != NULL);
	g_return_if_fail(msg != NULL);
	if (target == NULL) {
		/* this should only happen if some special target failed and
		   we should display some error message. currently the special
		   targets are only ',' and '.'. */
		g_return_if_fail(g_strcmp0(origtarget, ",") == 0 ||
				 g_strcmp0(origtarget, ".") == 0);

		printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE,
			    *origtarget == ',' ? TXT_NO_MSGS_GOT :
			    TXT_NO_MSGS_SENT);
		signal_stop();
		return;
	}

	query = privmsg_get_query(server, target, TRUE, MSGLEVEL_MSGS);

	if (settings_get_bool("emphasis"))
		msg = freemsg = expand_emphasis((WI_ITEM_REC *) query, msg);

	printformat(server, target,
		    MSGLEVEL_MSGS | MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT,
		    query == NULL ? TXT_OWN_MSG_PRIVATE :
		    TXT_OWN_MSG_PRIVATE_QUERY, target, msg, server->nick);

	g_free_not_null(freemsg);
}
예제 #2
0
static void sig_message_irc_action(IRC_SERVER_REC *server, const char *msg,
				   const char *nick, const char *address,
				   const char *target)
{
	void *item;
	const char *oldtarget;
        char *freemsg = NULL;
	int level;
	int own = FALSE;

	oldtarget = target;
	target = fe_channel_skip_prefix(IRC_SERVER(server), target);

	level = MSGLEVEL_ACTIONS |
		(server_ischannel(SERVER(server), target) ? MSGLEVEL_PUBLIC : MSGLEVEL_MSGS);

	if (ignore_check_plus(SERVER(server), nick, address, target, msg, &level, TRUE))
		return;

	if (server_ischannel(SERVER(server), target)) {
		item = irc_channel_find(server, target);
	} else {
		own = (!g_strcmp0(nick, server->nick));
		item = privmsg_get_query(SERVER(server), own ? target : nick, FALSE, level);
	}

	if (settings_get_bool("emphasis"))
		msg = freemsg = expand_emphasis(item, msg);

	if (server_ischannel(SERVER(server), target)) {
		/* channel action */
		if (window_item_is_active(item) && target == oldtarget) {
			/* message to active channel in window */
			printformat(server, target, level,
				    IRCTXT_ACTION_PUBLIC, nick, msg);
		} else {
			/* message to not existing/active channel, or to @/+ */
			printformat(server, target, level,
				    IRCTXT_ACTION_PUBLIC_CHANNEL,
				    nick, oldtarget, msg);
		}
	} else {
		if (own) {
			/* own action bounced */
			printformat(server, target,
				    MSGLEVEL_ACTIONS | MSGLEVEL_MSGS,
				    item != NULL && oldtarget == target ? IRCTXT_OWN_ACTION : IRCTXT_OWN_ACTION_TARGET,
				    server->nick, msg, oldtarget);
		} else {
			/* private action */
			printformat(server, nick, MSGLEVEL_ACTIONS | MSGLEVEL_MSGS,
				    item == NULL ? IRCTXT_ACTION_PRIVATE :
				    IRCTXT_ACTION_PRIVATE_QUERY,
				    nick, address == NULL ? "" : address, msg);
		}
	}

	g_free_not_null(freemsg);
}
예제 #3
0
static void sig_message_private(SERVER_REC *server, const char *msg,
				const char *nick, const char *address)
{
	QUERY_REC *query;

	/* create query window if needed */
	query = privmsg_get_query(server, nick, FALSE, MSGLEVEL_MSGS);

	/* reset the query's last_unread_msg timestamp */
        if (query != NULL)
		query->last_unread_msg = time(NULL);
}
예제 #4
0
static void sig_message_irc_action(IRC_SERVER_REC *server, const char *msg,
				   const char *nick, const char *address,
				   const char *target)
{
	void *item;
	const char *oldtarget;
        char *freemsg = NULL;
	int level;

	oldtarget = target;
	target = skip_target(IRC_SERVER(server), target);

	level = MSGLEVEL_ACTIONS |
		(ischannel(*target) ? MSGLEVEL_PUBLIC : MSGLEVEL_MSGS);

	if (ignore_check(SERVER(server), nick, address, target, msg, level))
		return;

	if (ignore_check(SERVER(server), nick, address, target, msg,
			 level | MSGLEVEL_NO_ACT))
		level |= MSGLEVEL_NO_ACT;

	if (ischannel(*target))
		item = irc_channel_find(server, target);
        else
		item = privmsg_get_query(SERVER(server), nick, FALSE, level);

	if (settings_get_bool("emphasis"))
		msg = freemsg = expand_emphasis(item, msg);

	if (ischannel(*target)) {
		/* channel action */
		if (window_item_is_active(item) && target == oldtarget) {
			/* message to active channel in window */
			printformat(server, target, level,
				    IRCTXT_ACTION_PUBLIC, nick, msg);
		} else {
			/* message to not existing/active channel, or to @/+ */
			printformat(server, target, level,
				    IRCTXT_ACTION_PUBLIC_CHANNEL,
				    nick, oldtarget, msg);
		}
	} else {
		/* private action */
		printformat(server, nick, MSGLEVEL_ACTIONS | MSGLEVEL_MSGS,
			    item == NULL ? IRCTXT_ACTION_PRIVATE :
			    IRCTXT_ACTION_PRIVATE_QUERY,
			    nick, address == NULL ? "" : address, msg);
	}
	
	g_free_not_null(freemsg);
}
예제 #5
0
파일: fe-queries.c 프로젝트: Adam-/irssi
static void sig_message_private(SERVER_REC *server, const char *msg,
				const char *nick, const char *address, const char *target)
{
	QUERY_REC *query;

	/* own message returned by bouncer? */
	int own = (!strcmp(nick, server->nick));

	/* create query window if needed */
	query = privmsg_get_query(server, own ? target : nick, FALSE, MSGLEVEL_MSGS);

	/* reset the query's last_unread_msg timestamp */
        if (query != NULL)
		query->last_unread_msg = time(NULL);
}
예제 #6
0
static void sig_message_irc_notice(SERVER_REC *server, const char *msg,
				   const char *nick, const char *address,
				   const char *target)
{
	const char *oldtarget;
	int level = MSGLEVEL_NOTICES;

	oldtarget = target;
	target = fe_channel_skip_prefix(IRC_SERVER(server), target);

	if (address == NULL || *address == '\0') {
		level = MSGLEVEL_SNOTES;
		/* notice from server */
		if (!ignore_check_plus(server, nick, "",
				       target, msg, &level, TRUE)) {
			printformat(server, target, level,
				    IRCTXT_NOTICE_SERVER, nick, msg);
		}
                return;
	}

	if (ignore_check_plus(server, nick, address,
			 server_ischannel(SERVER(server), target) ? target : NULL,
			      msg, &level, TRUE))
		return;

	if (server_ischannel(SERVER(server), target)) {
		/* notice in some channel */
		printformat(server, target, level,
			    IRCTXT_NOTICE_PUBLIC, nick, oldtarget, msg);
	} else {
		char *channel;
		/* check if this is a cnotice */
		channel = notice_channel_context(server, msg);

		if (channel == NULL) {
			/* private notice */
			privmsg_get_query(SERVER(server), nick, FALSE, MSGLEVEL_NOTICES);
		}
		printformat(server, channel == NULL ? nick : channel, level, IRCTXT_NOTICE_PRIVATE,
		            nick, address, msg);

		g_free(channel);
	}
}
예제 #7
0
static void sig_message_irc_notice(SERVER_REC *server, const char *msg,
				   const char *nick, const char *address,
				   const char *target)
{
	const char *oldtarget;
	int level = MSGLEVEL_NOTICES;
	
	oldtarget = target;
	target = skip_target(IRC_SERVER(server), target);

	if (address == NULL || *address == '\0') {
		/* notice from server */
		if (!ignore_check(server, nick, "",
				  target, msg, MSGLEVEL_SNOTES)) {
			printformat(server, target, MSGLEVEL_SNOTES,
				    IRCTXT_NOTICE_SERVER, nick, msg);
		}
                return;
	}

	if (ignore_check(server, nick, address,
			 ischannel(*target) ? target : NULL,
			 msg, level))
		return;

	if (ignore_check(server, nick, address,
			 ischannel(*target) ? target : NULL,
			 msg, level | MSGLEVEL_NO_ACT))
		level |= MSGLEVEL_NO_ACT;

        if (ischannel(*target)) {
		/* notice in some channel */
		printformat(server, target, level,
			    IRCTXT_NOTICE_PUBLIC, nick, oldtarget, msg);
	} else {
		/* private notice */
		privmsg_get_query(SERVER(server), nick, FALSE,
				  MSGLEVEL_NOTICES);
		printformat(server, nick, level,
			    IRCTXT_NOTICE_PRIVATE, nick, address, msg);
	}
}
예제 #8
0
static void event_notice(const char *data, IRC_SERVER_REC *server,
			 const char *nick, const char *addr)
{
	char *params, *target, *msg;
	int op_notice;

	g_return_if_fail(data != NULL);

	params = event_get_params(data, 2 | PARAM_FLAG_GETREST, &target, &msg);
	if (nick == NULL) {
		nick = server->real_address == NULL ?
			server->connrec->address :
			server->real_address;
	}

	if (addr == NULL) {
		/* notice from server */
		if (*msg != 1 && !ignore_check(SERVER(server), nick, "", target, msg, MSGLEVEL_SNOTES))
			printformat(server, target, MSGLEVEL_SNOTES, IRCTXT_NOTICE_SERVER, nick, msg);
	} else {
		op_notice = *target == '@' && ischannel(target[1]);
		if (op_notice) target++;

		if (ignore_check(SERVER(server), nick, addr, ischannel(*target) ?
				 target : NULL, msg, MSGLEVEL_NOTICES))
			return;

		if (ischannel(*target)) {
			/* notice in some channel */
			printformat(server, target, MSGLEVEL_NOTICES,
				    op_notice ? IRCTXT_NOTICE_PUBLIC_OPS : IRCTXT_NOTICE_PUBLIC,
				    nick, target, msg);
		} else {
			/* private notice */
			privmsg_get_query(SERVER(server), nick, FALSE, MSGLEVEL_NOTICES);
			printformat(server, nick, MSGLEVEL_NOTICES, IRCTXT_NOTICE_PRIVATE, nick, addr, msg);
		}
	}

	g_free(params);
}
예제 #9
0
/* we use "ctcp msg" here because "ctcp msg action" can be ignored with
   /IGNORE * CTCPS, and we don't want that.. */
static void ctcp_msg_check_action(const char *data, IRC_SERVER_REC *server,
				  const char *nick, const char *addr,
				  const char *target)
{
	void *item;
	int level;

	g_return_if_fail(data != NULL);

	if (g_strncasecmp(data, "ACTION ", 7) != 0)
		return;
	data += 7;

	level = MSGLEVEL_ACTIONS |
		(ischannel(*target) ? MSGLEVEL_PUBLIC : MSGLEVEL_MSGS);
	if (ignore_check(SERVER(server), nick, addr, target, data, level))
		return;

	if (ischannel(*target)) {
		/* channel action */
		item = irc_channel_find(server, target);

		if (window_item_is_active(item)) {
			/* message to active channel in window */
			printformat(server, target, level,
				    IRCTXT_ACTION_PUBLIC, nick, data);
		} else {
			/* message to not existing/active channel */
			printformat(server, target, level,
				    IRCTXT_ACTION_PUBLIC_CHANNEL, nick, target, data);
		}
	} else {
		/* private action */
		item = privmsg_get_query(SERVER(server), nick, FALSE, MSGLEVEL_MSGS);
		printformat(server, nick, level,
			    item == NULL ? IRCTXT_ACTION_PRIVATE : IRCTXT_ACTION_PRIVATE_QUERY,
			    nick, addr == NULL ? "" : addr, data);
	}
}
예제 #10
0
static void
sig_action(SERVER_REC *server, const char *msg, const char *nick,
    const char *target, gpointer gpointer_type)
{
	void *item;
	char *freemsg = NULL;
	int level, type;

	g_return_if_fail(server != NULL);
	g_return_if_fail(msg != NULL);
	g_return_if_fail(nick != NULL);
	g_return_if_fail(target != NULL);
	type = GPOINTER_TO_INT(gpointer_type);
	level = MSGLEVEL_ACTIONS | (type == SEND_TARGET_CHANNEL ?
	    MSGLEVEL_PUBLIC : MSGLEVEL_MSGS);
	item = type == SEND_TARGET_CHANNEL ?
	    (void *)channel_find(server, target)
	    : privmsg_get_query(SERVER(server), nick, FALSE, level);
	if (settings_get_bool("emphasis"))
		msg = freemsg = expand_emphasis(item, msg);
	/* MUC */
	if (type == SEND_TARGET_CHANNEL) {
		if (item && window_item_is_active(item))
			printformat_module(IRC_MODULE_NAME, server, target,
			    level, IRCTXT_ACTION_PUBLIC, nick, msg);
		else
			printformat_module(IRC_MODULE_NAME, server, target,
			    level, IRCTXT_ACTION_PUBLIC_CHANNEL, nick,
			    target, msg);
	/* General */
	} else
		printformat_module(IRC_MODULE_NAME, server, nick, level,
		    (item == NULL) ?
		    IRCTXT_ACTION_PRIVATE : IRCTXT_ACTION_PRIVATE_QUERY,
		    nick, nick, msg);
	g_free(freemsg);
}
예제 #11
0
static void sig_message_irc_notice(SERVER_REC *server, const char *msg,
				   const char *nick, const char *address,
				   const char *target)
{
	int op_notice;

	if (address == NULL) {
		/* notice from server */
		if (!ignore_check(server, nick, "",
				  target, msg, MSGLEVEL_SNOTES)) {
			printformat(server, target, MSGLEVEL_SNOTES,
				    IRCTXT_NOTICE_SERVER, nick, msg);
		}
                return;
	}

	op_notice = *target == '@' && ischannel(target[1]);
	if (op_notice) target++;

	if (ignore_check(server, nick, address,
			 ischannel(*target) ? target : NULL,
			 msg, MSGLEVEL_NOTICES))
		return;

	if (ischannel(*target)) {
		/* notice in some channel */
		printformat(server, target, MSGLEVEL_NOTICES,
			    op_notice ? IRCTXT_NOTICE_PUBLIC_OPS :
			    IRCTXT_NOTICE_PUBLIC, nick, target, msg);
	} else {
		/* private notice */
		privmsg_get_query(SERVER(server), nick, FALSE,
				  MSGLEVEL_NOTICES);
		printformat(server, nick, MSGLEVEL_NOTICES,
			    IRCTXT_NOTICE_PRIVATE, nick, address, msg);
	}
}
예제 #12
0
static void sig_message_irc_action(IRC_SERVER_REC *server, const char *msg,
				   const char *nick, const char *address,
				   const char *target)
{
	void *item;
	int level;

	level = MSGLEVEL_ACTIONS |
		(ischannel(*target) ? MSGLEVEL_PUBLIC : MSGLEVEL_MSGS);

	if (ignore_check(SERVER(server), nick, address, target, msg, level))
		return;

	if (ischannel(*target)) {
		/* channel action */
		item = irc_channel_find(server, target);

		if (window_item_is_active(item)) {
			/* message to active channel in window */
			printformat(server, target, level,
				    IRCTXT_ACTION_PUBLIC, nick, msg);
		} else {
			/* message to not existing/active channel */
			printformat(server, target, level,
				    IRCTXT_ACTION_PUBLIC_CHANNEL,
				    nick, target, msg);
		}
	} else {
		/* private action */
		item = privmsg_get_query(SERVER(server), nick, FALSE,
					 MSGLEVEL_MSGS);
		printformat(server, nick, MSGLEVEL_ACTIONS | MSGLEVEL_MSGS,
			    item == NULL ? IRCTXT_ACTION_PRIVATE :
			    IRCTXT_ACTION_PRIVATE_QUERY,
			    nick, address == NULL ? "" : address, msg);
	}
}
예제 #13
0
static void sig_message_private(SERVER_REC *server, const char *msg,
				const char *nick, const char *address)
{
	/* create query window if needed */
	privmsg_get_query(server, nick, FALSE, MSGLEVEL_MSGS);
}
예제 #14
0
static void cmd_msg(gchar *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
{
    WINDOW_REC *window;
    CHANNEL_REC *channel;
    NICK_REC *nickrec;
    char *params, *target, *msg, *nickmode, *freestr, *newtarget;
    int free_ret;

    g_return_if_fail(data != NULL);

    params = cmd_get_params(data, 2 | PARAM_FLAG_GETREST, &target, &msg);
    if (*target == '\0' || *msg == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);

    if (*target == '=')
    {
        /* dcc msg - handled in fe-dcc.c */
        g_free(params);
        return;
    }

    free_ret = FALSE;
    if (strcmp(target, ",") == 0 || strcmp(target, ".") == 0)
	    newtarget = parse_special(&target, server, item, NULL, &free_ret, NULL);
    else if (strcmp(target, "*") == 0 &&
	     (irc_item_channel(item) || irc_item_query(item)))
	    newtarget = item->name;
    else newtarget = target;

    if (newtarget == NULL) {
	    printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, *target == ',' ?
			IRCTXT_NO_MSGS_GOT : IRCTXT_NO_MSGS_SENT);
	    g_free(params);
	    signal_stop();
	    return;
    }
    target = newtarget;

    if (server == NULL || !server->connected) cmd_param_error(CMDERR_NOT_CONNECTED);
    channel = channel_find(server, target);

    freestr = !free_ret ? NULL : target;
    if (*target == '@' && ischannel(target[1]))
	target++; /* Hybrid 6 feature, send msg to all ops in channel */

    if (ischannel(*target))
    {
	/* msg to channel */
	nickrec = channel == NULL ? NULL : nicklist_find(channel, server->nick);
	nickmode = !settings_get_bool("show_nickmode") || nickrec == NULL ? "" :
	    nickrec->op ? "@" : nickrec->voice ? "+" : " ";

	window = channel == NULL ? NULL : window_item_window((WI_ITEM_REC *) channel);
	if (window != NULL && window->active == (WI_ITEM_REC *) channel)
	{
	    printformat(server, target, MSGLEVEL_PUBLIC | MSGLEVEL_NOHILIGHT,
			IRCTXT_OWN_MSG, server->nick, msg, nickmode);
	}
	else
	{
	    printformat(server, target, MSGLEVEL_PUBLIC | MSGLEVEL_NOHILIGHT,
			IRCTXT_OWN_MSG_CHANNEL, server->nick, target, msg, nickmode);
	}
    }
    else
    {
        /* private message */
        item = (WI_ITEM_REC *) privmsg_get_query(server, target, TRUE);
	printformat(server, target, MSGLEVEL_MSGS | MSGLEVEL_NOHILIGHT,
		    item == NULL ? IRCTXT_OWN_MSG_PRIVATE : IRCTXT_OWN_MSG_PRIVATE_QUERY, target, msg, server->nick);
    }
    g_free_not_null(freestr);

    g_free(params);
}