aboutsummaryrefslogtreecommitdiffstats
path: root/irc_send.c
diff options
context:
space:
mode:
Diffstat (limited to 'irc_send.c')
-rw-r--r--irc_send.c78
1 files changed, 67 insertions, 11 deletions
diff --git a/irc_send.c b/irc_send.c
index 89f0100a..d133c530 100644
--- a/irc_send.c
+++ b/irc_send.c
@@ -44,7 +44,7 @@ void irc_send_login(irc_t *irc)
PACKAGE, BITLBEE_VERSION);
irc_send_num(irc, 3, ":%s", IRCD_INFO);
irc_send_num(irc, 4, "%s %s %s %s", irc->root->host, BITLBEE_VERSION, UMODES UMODES_PRIV, CMODES);
- irc_send_num(irc, 5, "PREFIX=(ohv)@%%+ CHANTYPES=%s CHANMODES=,,,%s NICKLEN=%d CHANNELLEN=%d "
+ irc_send_num(irc, 5, "PREFIX=(qaohv)~&@%%+ CHANTYPES=%s CHANMODES=,,,%s NICKLEN=%d CHANNELLEN=%d "
"NETWORK=BitlBee SAFELIST CASEMAPPING=rfc1459 MAXTARGETS=1 WATCH=128 "
"FLOOD=0/9999 :are supported by this server",
CTYPES, CMODES, MAX_NICK_LENGTH - 1, MAX_NICK_LENGTH - 1);
@@ -364,6 +364,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_tagged_msg(iu, type, dst, msg, prefix, NULL);
+}
+
+void irc_send_tagged_msg(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];
@@ -383,14 +388,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_tagged_msg_raw(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_tagged_msg_raw(iu, type, dst, raw_msg, tags);
}
line = s + 1;
}
@@ -400,21 +405,56 @@ 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_tagged_msg_raw(iu, type, dst, msg, NULL);
+}
+
+void irc_send_tagged_msg_raw(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, ...)
{
- char text[IRC_MAX_LINE];
va_list params;
va_start(params, format);
- g_vsnprintf(text, IRC_MAX_LINE, format, params);
+ irc_send_tagged_msg_vf(iu, type, dst, NULL, format, params);
+ va_end(params);
+
+}
+
+void irc_send_tagged_msg_f(irc_user_t *iu, const char *type, const char *dst, const char *tags, const char *format, ...)
+{
+ va_list params;
+
+ va_start(params, format);
+ irc_send_tagged_msg_vf(iu, type, dst, tags, format, params);
va_end(params);
+}
+
+void irc_send_tagged_msg_vf(irc_user_t *iu, const char *type, const char *dst, const char *tags, const char *format, va_list params)
+{
+ char text[IRC_MAX_LINE];
- irc_write(iu->irc, ":%s!%s@%s %s %s :%s",
- iu->nick, iu->user, iu->host, type, dst, text);
+ g_vsnprintf(text, IRC_MAX_LINE, format, 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)
@@ -427,11 +467,27 @@ void irc_send_nick(irc_user_t *iu, const char *new)
void irc_send_channel_user_mode_diff(irc_channel_t *ic, irc_user_t *iu,
irc_channel_user_flags_t old, irc_channel_user_flags_t new)
{
- char changes[3 * (5 + strlen(iu->nick))];
- char from[strlen(ic->irc->root->nick) + strlen(ic->irc->root->user) + strlen(ic->irc->root->host) + 3];
+ char changes[5 * (5 + strlen(iu->nick))];
+ char from[strlen(ic->irc->root->nick) + strlen(ic->irc->root->user) + strlen(ic->irc->root->host) + 5];
int n;
*changes = '\0'; n = 0;
+ if ((old & IRC_CHANNEL_USER_OWNER) != (new & IRC_CHANNEL_USER_OWNER)) {
+ n++;
+ if (new & IRC_CHANNEL_USER_OWNER) {
+ strcat(changes, "+q");
+ } else {
+ strcat(changes, "-q");
+ }
+ }
+ if ((old & IRC_CHANNEL_USER_ADMIN) != (new & IRC_CHANNEL_USER_ADMIN)) {
+ n++;
+ if (new & IRC_CHANNEL_USER_ADMIN) {
+ strcat(changes, "+a");
+ } else {
+ strcat(changes, "-a");
+ }
+ }
if ((old & IRC_CHANNEL_USER_OP) != (new & IRC_CHANNEL_USER_OP)) {
n++;
if (new & IRC_CHANNEL_USER_OP) {