summaryrefslogtreecommitdiff
path: root/src/map/irc-bot.c
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2015-01-22 00:28:24 +0100
committerHaru <haru@dotalux.com>2015-01-24 14:37:25 +0100
commitfc50b63d454f59620e0d3ef6674bd9ae54a6175f (patch)
tree35bcd04fd592a40aca634995cca3fe33031fc5c4 /src/map/irc-bot.c
parenta75714ca455c728d34918dd12200fcec87ebc0d4 (diff)
downloadhercules-fc50b63d454f59620e0d3ef6674bd9ae54a6175f.tar.gz
hercules-fc50b63d454f59620e0d3ef6674bd9ae54a6175f.tar.bz2
hercules-fc50b63d454f59620e0d3ef6674bd9ae54a6175f.tar.xz
hercules-fc50b63d454f59620e0d3ef6674bd9ae54a6175f.zip
Moved the Hercules Channel System to its own file/interface
Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/map/irc-bot.c')
-rw-r--r--src/map/irc-bot.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/src/map/irc-bot.c b/src/map/irc-bot.c
index 36c19ccbd..173675911 100644
--- a/src/map/irc-bot.c
+++ b/src/map/irc-bot.c
@@ -10,7 +10,7 @@
#include <stdlib.h>
#include <string.h>
-#include "clif.h"
+#include "channel.h"
#include "map.h"
#include "pc.h"
#include "../common/cbasetypes.h"
@@ -41,7 +41,7 @@ int irc_connect_timer(int tid, int64 tick, int id, intptr_t data) {
ircbot->last_try = timer->gettick();
- if ((ircbot->fd = make_connection(ircbot->ip, clif->hChSys->irc_server_port, &opt)) > 0) {
+ if ((ircbot->fd = make_connection(ircbot->ip, channel->config->irc_server_port, &opt)) > 0) {
session[ircbot->fd]->func_parse = ircbot->parse;
session[ircbot->fd]->flag.server = 1;
timer->add(timer->gettick() + 3000, ircbot->identify_timer, 0, 0);
@@ -60,7 +60,7 @@ int irc_identify_timer(int tid, int64 tick, int id, intptr_t data) {
sprintf(send_string, "USER HerculesWS%d 8 * : Hercules IRC Bridge",rnd()%777);
ircbot->send(send_string);
- sprintf(send_string, "NICK %s", clif->hChSys->irc_nick);
+ sprintf(send_string, "NICK %s", channel->config->irc_nick);
ircbot->send(send_string);
timer->add(timer->gettick() + 3000, ircbot->join_timer, 0, 0);
@@ -76,15 +76,15 @@ int irc_join_timer(int tid, int64 tick, int id, intptr_t data) {
if( !ircbot->isOn )
return 0;
- if (clif->hChSys->irc_nick_pw[0] != '\0') {
- sprintf(send_string, "PRIVMSG NICKSERV : IDENTIFY %s", clif->hChSys->irc_nick_pw);
+ if (channel->config->irc_nick_pw[0] != '\0') {
+ sprintf(send_string, "PRIVMSG NICKSERV : IDENTIFY %s", channel->config->irc_nick_pw);
ircbot->send(send_string);
- if (clif->hChSys->irc_use_ghost) {
- sprintf(send_string, "PRIVMSG NICKSERV : GHOST %s %s", clif->hChSys->irc_nick, clif->hChSys->irc_nick_pw);
+ if (channel->config->irc_use_ghost) {
+ sprintf(send_string, "PRIVMSG NICKSERV : GHOST %s %s", channel->config->irc_nick, channel->config->irc_nick_pw);
}
}
- sprintf(send_string, "JOIN %s", clif->hChSys->irc_channel);
+ sprintf(send_string, "JOIN %s", channel->config->irc_channel);
ircbot->send(send_string);
ircbot->isIn = true;
@@ -120,7 +120,7 @@ int irc_parse(int fd) {
ircbot->isOn = false;
ircbot->isIn = false;
ircbot->fails = 0;
- ircbot->ip = host2ip(clif->hChSys->irc_server);
+ ircbot->ip = host2ip(channel->config->irc_server);
timer->add(timer->gettick() + 120000, ircbot->connect_timer, 0, 0);
return 0;
}
@@ -243,7 +243,7 @@ void irc_privmsg_ctcp(int fd, char *cmd, char *source, char *target, char *msg)
if( strcmpi(cmd,"ACTION") == 0 ) {
if( ircbot->channel ) {
snprintf(send_string, 150, "[ #%s ] * IRC.%s %s *",ircbot->channel->name,source_nick,msg);
- clif->chsys_msg2(ircbot->channel,send_string);
+ clif->channel_msg2(ircbot->channel,send_string);
}
} else if( strcmpi(cmd,"ERRMSG") == 0 ) {
// Ignore it
@@ -290,10 +290,10 @@ void irc_privmsg(int fd, char *cmd, char *source, char *target, char *msg) {
irc_privmsg_ctcp(fd, command, source, target, message);
#ifdef IRCBOT_DEBUG
- } else if (strcmpi(target, clif->hChSys->irc_nick) == 0) {
+ } else if (strcmpi(target, channel->config->irc_nick) == 0) {
ShowDebug("irc_privmsg: Received message from %s: '%s'\n", source ? source : "(null)", msg);
#endif // IRCBOT_DEBUG
- } else if (msg && strcmpi(target, clif->hChSys->irc_channel) == 0) {
+ } else if (msg && strcmpi(target, channel->config->irc_channel) == 0) {
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';
@@ -305,7 +305,7 @@ void irc_privmsg(int fd, char *cmd, char *source, char *target, char *msg) {
size_t padding_len = strlen(ircbot->channel->name) + strlen(source_nick) + 13;
while (1) {
snprintf(send_string, 150, "[ #%s ] IRC.%s : %s",ircbot->channel->name,source_nick,msg);
- clif->chsys_msg2(ircbot->channel,send_string);
+ clif->channel_msg2(ircbot->channel,send_string);
//break; // Uncomment this line to truncate long messages instead of posting them as multiple lines
if (strlen(msg) <= 149 - padding_len)
break;
@@ -330,7 +330,7 @@ void irc_userjoin(int fd, char *cmd, char *source, char *target, char *msg) {
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);
+ clif->channel_msg2(ircbot->channel,send_string);
}
}
@@ -352,7 +352,7 @@ void irc_userleave(int fd, char *cmd, char *source, char *target, char *msg) {
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);
+ clif->channel_msg2(ircbot->channel,send_string);
}
}
@@ -371,7 +371,7 @@ void irc_usernick(int fd, char *cmd, char *source, char *target, char *msg) {
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);
+ clif->channel_msg2(ircbot->channel,send_string);
}
}
@@ -383,7 +383,7 @@ void irc_usernick(int fd, char *cmd, char *source, char *target, char *msg) {
void irc_relay(char *name, const char *msg) {
if( !ircbot->isIn )
return;
- sprintf(send_string,"PRIVMSG %s :[ %s ] : %s", clif->hChSys->irc_channel, name, msg);
+ sprintf(send_string,"PRIVMSG %s :[ %s ] : %s", channel->config->irc_channel, name, msg);
ircbot->send(send_string);
}
@@ -406,12 +406,12 @@ void irc_bot_init(bool minimal) {
if (minimal)
return;
- if (!clif->hChSys->irc)
+ if (!channel->config->irc)
return;
- if (!(ircbot->ip = host2ip(clif->hChSys->irc_server))) {
- ShowError("Unable to resolve '%s' (irc server), disabling irc channel...\n", clif->hChSys->irc_server);
- clif->hChSys->irc = false;
+ if (!(ircbot->ip = host2ip(channel->config->irc_server))) {
+ ShowError("Unable to resolve '%s' (irc server), disabling irc channel...\n", channel->config->irc_server);
+ channel->config->irc = false;
return;
}
@@ -444,7 +444,7 @@ void irc_bot_init(bool minimal) {
void irc_bot_final(void) {
int i;
- if (!clif->hChSys->irc)
+ if (!channel->config->irc)
return;
if( ircbot->isOn ) {
ircbot->send("QUIT :Hercules is shutting down");