Ejemplo n.º 1
0
/* SYNTAX: PING <nicks> */
static void cmd_ping(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
{
	GTimeVal tv;
        char *str;

        CMD_IRC_SERVER(server);

	if (*data == '\0' || strcmp(data, "*") == 0) {
		if (!IS_IRC_ITEM(item))
                        cmd_return_error(CMDERR_NOT_JOINED);

		data = window_item_get_target(item);
	}

	g_get_current_time(&tv);

	str = g_strdup_printf("%s PING %ld %ld", data, tv.tv_sec, tv.tv_usec);
	signal_emit("command ctcp", 3, str, server, item);
	g_free(str);
}
Ejemplo n.º 2
0
/* SYNTAX: PING <nicks> */
static void cmd_ping(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
{
	GTimeVal tv;
        char *str;

	g_return_if_fail(data != NULL);
	if (!IS_IRC_SERVER(server) || !server->connected)
		cmd_return_error(CMDERR_NOT_CONNECTED);

	if (*data == '\0' || strcmp(data, "*") == 0) {
		if (!IS_IRC_ITEM(item))
                        cmd_return_error(CMDERR_NOT_JOINED);

		data = item->name;
	}

	g_get_current_time(&tv);

	str = g_strdup_printf("%s PING %ld %ld", data, tv.tv_sec, tv.tv_usec);
	signal_emit("command ctcp", 3, str, server, item);
	g_free(str);
}
Ejemplo n.º 3
0
/* SYNTAX: ME <message> */
static void cmd_me(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
{
	const char *target;
	char *subdata;
	char **splitdata;
	int n = 0;

        CMD_IRC_SERVER(server);
	if (!IS_IRC_ITEM(item))
		return;

	if (server == NULL || !server->connected)
		cmd_return_error(CMDERR_NOT_CONNECTED);

	target = window_item_get_target(item);
	splitdata = irc_server_split_action(server, target, data);
	while ((subdata = splitdata[n++])) {
		irc_server_send_action(server, target, subdata);
		signal_emit("message irc own_action", 3, server, subdata,
			    item->visible_name);
	}
	g_strfreev(splitdata);
}
Ejemplo n.º 4
0
/* SYNTAX: ME <message> */
static void cmd_me(const char *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
{
	const char *target;
	char *recoded;

        CMD_IRC_SERVER(server);
	if (!IS_IRC_ITEM(item))
		return;

	if (server == NULL || !server->connected)
		cmd_return_error(CMDERR_NOT_CONNECTED);

	target = window_item_get_target(item);
	recoded = recode_out(SERVER(server), data, target);

	signal_emit("message irc own_action", 3, server, recoded,
		    item->visible_name);

	irc_send_cmdv(server, "PRIVMSG %s :\001ACTION %s\001",
		      target, recoded);

	g_free(recoded);
}