summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2013-08-05 15:34:53 +0200
committerHaru <haru@dotalux.com>2013-08-12 17:14:51 +0200
commit93d75b858d046022dcb3904476f2dd5071dfc36d (patch)
treed259b0fa6d913334d7f7b25e78e735852fd7062a /src/map
parentd20596083a12a8ab797614121be51d2a914abe58 (diff)
downloadhercules-93d75b858d046022dcb3904476f2dd5071dfc36d.tar.gz
hercules-93d75b858d046022dcb3904476f2dd5071dfc36d.tar.bz2
hercules-93d75b858d046022dcb3904476f2dd5071dfc36d.tar.xz
hercules-93d75b858d046022dcb3904476f2dd5071dfc36d.zip
Added support for JOIN, QUIT, PART, NICK in the IRC bridge
- It'll now show messages such as: [ #irc ] User IRC.<nick> joined the channel. [ #irc ] User IRC.<nick> left the channel. [Quit: <quit message>] [ #irc ] User IRC.<nick> left the channel. [<leave message>] [ #irc ] User IRC.<old nick> is now known as IRC.<new nick>" - To disable, comment out the respective entries in irc_bot_init. Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/map')
-rw-r--r--src/map/irc-bot.c68
-rw-r--r--src/map/irc-bot.h3
2 files changed, 71 insertions, 0 deletions
diff --git a/src/map/irc-bot.c b/src/map/irc-bot.c
index d8aa59440..45c302c1a 100644
--- a/src/map/irc-bot.c
+++ b/src/map/irc-bot.c
@@ -207,6 +207,66 @@ void irc_privmsg(int fd, char *cmd, char *source, char *target, char *msg) {
}
}
+/**
+ * Handler for the JOIN IRC command (notify an in-game channel of users joining
+ * the IRC channel)
+ * @see irc_parse_sub
+ */
+void irc_userjoin(int fd, char *cmd, char *source, char *target, char *msg) {
+ char source_nick[IRC_NICK_LENGTH], source_ident[IRC_IDENT_LENGTH], source_host[IRC_HOST_LENGTH];
+
+ source_nick[0] = source_ident[0] = source_host[0] = '\0';
+
+ if( source[0] != '\0' )
+ ircbot->parse_source(source,source_nick,source_ident,source_host);
+
+ if( ircbot->channel ) {
+ snprintf(send_string, 150, "[ #%s ] User IRC.%s joined the channel.",ircbot->channel->name,source_nick);
+ clif->chsys_msg2(ircbot->channel,send_string);
+ }
+}
+
+/**
+ * Handler for the PART and QUIT IRC commands (notify an in-game channel of
+ * users leaving the IRC channel)
+ * @see irc_parse_sub
+ */
+void irc_userleave(int fd, char *cmd, char *source, char *target, char *msg) {
+ char source_nick[IRC_NICK_LENGTH], source_ident[IRC_IDENT_LENGTH], source_host[IRC_HOST_LENGTH];
+
+ source_nick[0] = source_ident[0] = source_host[0] = '\0';
+
+ if( source[0] != '\0' )
+ ircbot->parse_source(source,source_nick,source_ident,source_host);
+
+ if( ircbot->channel ) {
+ if (!strcmpi(cmd, "QUIT"))
+ snprintf(send_string, 150, "[ #%s ] User IRC.%s left the channel. [Quit: %s]",ircbot->channel->name,source_nick,msg);
+ else
+ snprintf(send_string, 150, "[ #%s ] User IRC.%s left the channel. [%s]",ircbot->channel->name,source_nick,msg);
+ clif->chsys_msg2(ircbot->channel,send_string);
+ }
+}
+
+/**
+ * Handler for the NICK IRC commands (notify an in-game channel of users
+ * changing their name while in the IRC channel)
+ * @see irc_parse_sub
+ */
+void irc_usernick(int fd, char *cmd, char *source, char *target, char *msg) {
+ char source_nick[IRC_NICK_LENGTH], source_ident[IRC_IDENT_LENGTH], source_host[IRC_HOST_LENGTH];
+
+ source_nick[0] = source_ident[0] = source_host[0] = '\0';
+
+ if( source[0] != '\0' )
+ ircbot->parse_source(source,source_nick,source_ident,source_host);
+
+ if( ircbot->channel ) {
+ snprintf(send_string, 150, "[ #%s ] User IRC.%s is now known as IRC.%s",ircbot->channel->name,source_nick,msg);
+ clif->chsys_msg2(ircbot->channel,send_string);
+ }
+}
+
void irc_relay (char *name, const char *msg) {
if( !ircbot->isIn )
return;
@@ -217,6 +277,10 @@ void irc_bot_init(void) {
const struct irc_func irc_func_base[] = {
{ "PING" , ircbot->pong },
{ "PRIVMSG", ircbot->privmsg },
+ { "JOIN", ircbot->userjoin },
+ { "QUIT", ircbot->userleave },
+ { "PART", ircbot->userleave },
+ { "NICK", ircbot->usernick },
};
struct irc_func* function;
int i;
@@ -293,4 +357,8 @@ void ircbot_defaults(void) {
ircbot->pong = irc_pong;
ircbot->join = irc_join;
ircbot->privmsg = irc_privmsg;
+
+ ircbot->userjoin = irc_userjoin;
+ ircbot->userleave = irc_userleave;
+ ircbot->usernick = irc_usernick;
}
diff --git a/src/map/irc-bot.h b/src/map/irc-bot.h
index 0fd84bd5f..0efb0245e 100644
--- a/src/map/irc-bot.h
+++ b/src/map/irc-bot.h
@@ -52,6 +52,9 @@ struct irc_bot_interface {
void (*pong) (int fd, char *cmd, char *source, char *target, char *msg);
void (*join) (int fd, char *cmd, char *source, char *target, char *msg);
void (*privmsg) (int fd, char *cmd, char *source, char *target, char *msg);
+ void (*userjoin) (int fd, char *cmd, char *source, char *target, char *msg);
+ void (*userleave) (int fd, char *cmd, char *source, char *target, char *msg);
+ void (*usernick) (int fd, char *cmd, char *source, char *target, char *msg);
};
struct irc_bot_interface *ircbot;