aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--irc.h3
-rw-r--r--irc_send.c45
2 files changed, 44 insertions, 4 deletions
diff --git a/irc.h b/irc.h
index b9bf0e28..3d8ad1d5 100644
--- a/irc.h
+++ b/irc.h
@@ -355,8 +355,11 @@ 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, const char *prefix);
+void irc_send_msg_tagged(irc_user_t *iu, const char *type, const char *dst, const char *msg, const char *prefix, const char *tags);
void irc_send_msg_raw(irc_user_t *iu, const char *type, const char *dst, const char *msg);
+void irc_send_msg_raw_tagged(irc_user_t *iu, const char *type, const char *dst, const char *msg, const char *tags);
void irc_send_msg_f(irc_user_t *iu, const char *type, const char *dst, const char *format, ...) G_GNUC_PRINTF(4, 5);
+void irc_send_msg_f_tagged(irc_user_t *iu, const char *type, const char *dst, const char *tags, const char *format, ...) G_GNUC_PRINTF(5, 6);
void irc_send_nick(irc_user_t *iu, const char *new_nick);
void irc_send_channel_user_mode_diff(irc_channel_t *ic, irc_user_t *iu,
irc_channel_user_flags_t old_flags, irc_channel_user_flags_t new_flags);
diff --git a/irc_send.c b/irc_send.c
index 5b760fb3..3c949c87 100644
--- a/irc_send.c
+++ b/irc_send.c
@@ -366,6 +366,11 @@ 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, const char *prefix)
{
+ irc_send_msg_tagged(iu, type, dst, msg, prefix, NULL);
+}
+
+void irc_send_msg_tagged(irc_user_t *iu, const char *type, const char *dst, const char *msg, const char *prefix, const char *tags)
+{
char last = 0;
const char *s = msg, *line = msg;
char raw_msg[strlen(msg) + 1024];
@@ -385,14 +390,14 @@ void irc_send_msg(irc_user_t *iu, const char *type, const char *dst, const char
strcpy(raw_msg, "\001ACTION ");
strncat(raw_msg, line + 4, s - line - 4);
strcat(raw_msg, "\001");
- irc_send_msg_raw(iu, type, dst, raw_msg);
+ irc_send_msg_raw_tagged(iu, type, dst, raw_msg, tags);
} else {
*raw_msg = '\0';
if (prefix && *prefix) {
strcpy(raw_msg, prefix);
}
strncat(raw_msg, line, s - line);
- irc_send_msg_raw(iu, type, dst, raw_msg);
+ irc_send_msg_raw_tagged(iu, type, dst, raw_msg, tags);
}
line = s + 1;
}
@@ -402,8 +407,20 @@ void irc_send_msg(irc_user_t *iu, const char *type, const char *dst, const char
void irc_send_msg_raw(irc_user_t *iu, const char *type, const char *dst, const char *msg)
{
- irc_write(iu->irc, ":%s!%s@%s %s %s :%s",
- iu->nick, iu->user, iu->host, type, dst, msg && *msg ? msg : " ");
+ irc_send_msg_raw_tagged(iu, type, dst, msg, NULL);
+}
+
+void irc_send_msg_raw_tagged(irc_user_t *iu, const char *type, const char *dst, const char *msg, const char *tags)
+{
+ if (!tags || !*tags) {
+ irc_write(iu->irc, ":%s!%s@%s %s %s :%s",
+ iu->nick, iu->user, iu->host,
+ type, dst, msg && *msg ? msg : " ");
+ } else {
+ irc_write(iu->irc, "@%s :%s!%s@%s %s %s :%s",
+ tags, iu->nick, iu->user, iu->host,
+ type, dst, msg && *msg ? msg : " ");
+ }
}
void irc_send_msg_f(irc_user_t *iu, const char *type, const char *dst, const char *format, ...)
@@ -419,6 +436,26 @@ void irc_send_msg_f(irc_user_t *iu, const char *type, const char *dst, const cha
iu->nick, iu->user, iu->host, type, dst, text);
}
+void irc_send_msg_f_tagged(irc_user_t *iu, const char *type, const char *dst, const char *tags, const char *format, ...)
+{
+ char text[IRC_MAX_LINE];
+ va_list params;
+
+ va_start(params, format);
+ g_vsnprintf(text, IRC_MAX_LINE, format, params);
+ va_end(params);
+
+ if (!tags || !*tags) {
+ irc_write(iu->irc, ":%s!%s@%s %s %s :%s",
+ iu->nick, iu->user, iu->host,
+ type, dst, text);
+ } else {
+ irc_write(iu->irc, "@%s :%s!%s@%s %s %s :%s",
+ tags, iu->nick, iu->user, iu->host,
+ type, dst, text);
+ }
+}
+
void irc_send_nick(irc_user_t *iu, const char *new)
{
irc_write(iu->irc, ":%s!%s@%s NICK %s",