diff --git a/src/module.c b/src/module.c index 50533d7..df3dffb 100644 --- a/src/module.c +++ b/src/module.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "cmd.h" #include "key.h" diff --git a/src/otr.c b/src/otr.c index 840c1b3..9c0d25f 100644 --- a/src/otr.c +++ b/src/otr.c @@ -363,6 +363,9 @@ int otr_send(SERVER_REC *irssi, const char *msg, const char *to, char **otr_msg) IRSSI_NOTICE(irssi, to, "Send failed."); goto error; } + + /* Modify some libotr messages (OTR init in particular) to work better with IRC. */ + if (*otr_msg) utils_escape_message(*otr_msg); IRSSI_DEBUG("Message sent..."); diff --git a/src/otr.h b/src/otr.h index 828c541..de62aa6 100644 --- a/src/otr.h +++ b/src/otr.h @@ -54,6 +54,10 @@ #define OTR_MSG_BEGIN_TAG "?OTR:" #define OTR_MSG_END_TAG '.' +#define OTR_MSG_HELP " This is a request for an Off-the-Record private conversation. "\ + "However, you do not have a plugin to support that. If you are using Irssi, "\ + "please install irssi-otr (irssi-plugin-otr)."; + /* IRC /me command marker and len. */ #define OTR_IRC_MARKER_ME "/me " #define OTR_IRC_MARKER_ME_LEN sizeof(OTR_IRC_MARKER_ME) - 1 diff --git a/src/utils.c b/src/utils.c index ceae3e9..c676853 100644 --- a/src/utils.c +++ b/src/utils.c @@ -73,6 +73,25 @@ char *utils_trim_string(char *s) return rtrim(ltrim(s)); } +/* + * Convert invalid characters (newlines from libotr) into spaces. + * Also change the init help string because IRC does not support HTML. + */ +char *utils_escape_message(char *s) { + char const* helpmsg = OTR_MSG_HELP; + size_t i; + if (strncmp(s, "?OTR", 4) == 0 && strstr(s, " has requested an