diff options
author | Zido <Zido@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2006-04-08 12:09:36 +0000 |
---|---|---|
committer | Zido <Zido@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2006-04-08 12:09:36 +0000 |
commit | 74c9a56b7aa52fff54fa4a34a2f31910307b37eb (patch) | |
tree | 9c77d8672a67e520e3a3e589115e98b04d55fa3a /src/map/irc.c | |
parent | 8de982a279a9eca6505c790b32ca2f1d559a3380 (diff) | |
download | hercules-74c9a56b7aa52fff54fa4a34a2f31910307b37eb.tar.gz hercules-74c9a56b7aa52fff54fa4a34a2f31910307b37eb.tar.bz2 hercules-74c9a56b7aa52fff54fa4a34a2f31910307b37eb.tar.xz hercules-74c9a56b7aa52fff54fa4a34a2f31910307b37eb.zip |
- The IRC bot now reads a configuration file (irc.c) instead of it all being hardcoded
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@5958 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/irc.c')
-rw-r--r-- | src/map/irc.c | 55 |
1 files changed, 54 insertions, 1 deletions
diff --git a/src/map/irc.c b/src/map/irc.c index 79c5bd640..8a4d3b2e0 100644 --- a/src/map/irc.c +++ b/src/map/irc.c @@ -15,6 +15,7 @@ typedef int socklen_t; #include <netdb.h>
#include <arpa/inet.h>
#include <ctype.h>
+#include <stdlib.h>
#ifndef SIOCGIFCONF
#include <sys/sockio.h> // SIOCGIFCONF on Solaris, maybe others? [Shinomori]
@@ -54,7 +55,7 @@ char irc_channel[32]=""; char irc_trade_channel[32]="";
unsigned char irc_ip_str[128]="";
-unsigned long irc_ip=6667;
+unsigned long irc_ip=0;
unsigned short irc_port = 6667;
int irc_fd=0;
@@ -241,6 +242,8 @@ void irc_parse_sub(int fd, char *incoming_string) irc_send(send_string);
sprintf(send_string, "JOIN %s", irc_channel);
irc_send(send_string);
+ sprintf(send_string,"NAMES %s",irc_channel);
+ irc_send(send_string);
irc_si->state = 2;
}
else if(!strcmp(command,"433")){
@@ -460,3 +463,53 @@ int irc_rmnames() { return 0;
}
+
+int irc_read_conf(char *file) {
+ FILE *fp=NULL;
+ char w1[256];
+ char w2[256];
+ char path[256];
+ char row[1024];
+
+ memset(w1,'\0',256);
+ memset(w2,'\0',256);
+ memset(path,'\0',256);
+ memset(row,'\0',256);
+
+ sprintf(path,"conf/%s",file);
+
+ if(!(fp=fopen(path,"r"))) {
+ ShowError("Cannot find file: %s\n",path);
+ return 0;
+ }
+
+ while(fgets(row,1023,fp)!=NULL) {
+ if(row[0]=='/'&&row[1]=='/')
+ continue;
+ sscanf(row,"%[^:]: %255[^\r\n]",w1,w2);
+ if(strcmpi(w1,"use_irc")==0) {
+ if(strcmpi(w2,"on")==0)
+ use_irc=1;
+ else
+ use_irc=0;
+ }
+ else if(strcmpi(w1,"irc_server")==0)
+ strcpy(irc_ip_str,w2);
+ else if(strcmpi(w1,"irc_port")==0)
+ irc_port=atoi(w2);
+ else if(strcmpi(w1,"irc_channel")==0)
+ strcpy(irc_channel,w2);
+ else if(strcmpi(w1,"irc_trade_channel")==0)
+ strcpy(irc_trade_channel,w2);
+ else if(strcmpi(w1,"irc_nick")==0)
+ strcpy(irc_nick,w2);
+ else if(strcmpi(w1,"irc_pass")==0) {
+ if(strcmpi(w2,"0")!=0)
+ strcpy(irc_password,w2);
+ }
+ }
+
+ ShowInfo("IRC Config read successfully\n");
+
+ return 1;
+}
|