254 lines
7.0 KiB
C
Executable File
254 lines
7.0 KiB
C
Executable File
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <time.h>
|
|
#include "config.h"
|
|
#include "myfile.h"
|
|
#include "nicklist.h"
|
|
|
|
extern char UPLINK[];
|
|
extern char *token[], buf[], sockbuf[];
|
|
extern int sevsck, botsck;
|
|
extern int status,doclearkick,doclearops,docleanchan,docleanops;
|
|
extern time_t NOWTIME;
|
|
extern char channel[];
|
|
extern char opcommand[];
|
|
extern char comment[],orig[];
|
|
int have_names=0,have_bans=0;
|
|
extern int CLEAR_KICK;
|
|
char modelist[10];
|
|
char modemask[512];
|
|
int modecnt;
|
|
extern int DccCtr;
|
|
|
|
|
|
sevnum(int num)
|
|
{
|
|
int i,j,k;
|
|
char temp[512];
|
|
char mask[100];
|
|
struct aUser *myuser;
|
|
struct nicklist *nicklistid;
|
|
char *tptr,*sptr;
|
|
static time_t lastkill=0;
|
|
k=chk_num(0);
|
|
if(!lastkill) lastkill=NOWTIME-120;
|
|
switch(num) {
|
|
case 307: /* USERIP */
|
|
/*okc.ok.us.undernet.org 307 wildtest :WildThang*=-~danny@207.3.94.229*/
|
|
if(!token[3] || ((tptr=strchr(token[3],'=')) == NULL)) break;
|
|
token[3]++;
|
|
if(*(tptr-1) == '*') *(tptr-1)='\0';
|
|
else *tptr='\0';
|
|
if( (nicklistid = find_nicklist(token[3])) == NULL) break;
|
|
if( (tptr=strchr(tptr,'@'))!= NULL) break;
|
|
if(nicklistid->iphost) free(nicklistid->iphost);
|
|
nicklistid->iphost=strdup(tptr+1);
|
|
break;
|
|
case 313:
|
|
if(status == SHOW_HOSTS) show_hosts(token[3],1);
|
|
else if(status == KILTEL)
|
|
{ sprintf(buf,":%s NOTICE %s :You have been Terminated by %s\n",CHANSVR,channel,token[3]);
|
|
writeln(sevsck,buf);
|
|
sprintf(buf,":%s NOTICE %s :seeya Terminated by %s\n",
|
|
CHANSVR,channel,token[3]);
|
|
writeln(sevsck,buf);
|
|
sprintf(buf,"109 %s :Termination\n",channel);
|
|
writeln(sevsck,buf);
|
|
sprintf(buf,":%s NOTICE %s :%s has been Shot!\n",
|
|
CHANSVR,token[3], channel);
|
|
writeln(sevsck,buf);
|
|
}
|
|
else if(status == SCAN)
|
|
{
|
|
sprintf(buf,
|
|
":%s NOTICE %s :Total Users with %s userid is %d\n",
|
|
CHANSVR,channel,opcommand,scan_userid(opcommand));
|
|
writeln(sevsck,buf);
|
|
}
|
|
break;
|
|
|
|
case 324:
|
|
if((status == CLEARCHAN) || (status == CLEARMODE))
|
|
{
|
|
*token[4]='-';
|
|
strcpy(temp,token[4]);
|
|
for(i=5;i<k;i++) {
|
|
strcat(temp," ");
|
|
strcat(temp,token[i]);
|
|
}
|
|
sprintf(buf,"MODE %s %s 0\n",channel,temp);
|
|
writeln(sevsck,buf);
|
|
if(status == CLEARMODE) status=0;
|
|
}
|
|
break;
|
|
case 353:
|
|
if((status == CLEARCHAN) || (status == CLEAROPS))
|
|
{ char modechar[6];
|
|
char nicklist[60];
|
|
char kickbuf[255];
|
|
char hostmask[55];
|
|
int nck;
|
|
int opcnt=0;
|
|
|
|
strcpy(modechar,"-");
|
|
nicklist[0]='\0';
|
|
for(nck=5;nck<k;nck++)
|
|
{ if(*token[nck]==':') token[nck]++;
|
|
|
|
if((status == CLEARCHAN) && (docleanops) &&
|
|
(*token[nck]=='@'))
|
|
{ *token[nck]++;
|
|
if(*token[nck]=='+') *token[nck]++;
|
|
if (GetUserHost(token[nck],hostmask) <1) continue;
|
|
if(hostmask[0]!='\0')
|
|
{
|
|
do_gline(hostmask,"CHANNELBLAST",
|
|
(comment[0]!='\0')?comment:
|
|
"BANNED by Channel Cleanup", 600);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
|
|
if((status == CLEARCHAN) && (docleanchan))
|
|
{
|
|
if(*token[nck]=='@') *token[nck]++;
|
|
if(*token[nck]=='+') *token[nck]++;
|
|
if (GetUserHost(token[nck],hostmask) <1) continue;
|
|
if(hostmask[0]!='\0')
|
|
{
|
|
do_gline(hostmask,"CHANNELBLAST",
|
|
(comment[0]!='\0')?comment:
|
|
"BANNED by Channel Cleanup", 600);
|
|
}
|
|
continue;
|
|
}
|
|
|
|
if(((status == CLEARCHAN) && (doclearops)) ||
|
|
(status== CLEAROPS))
|
|
{
|
|
if(*token[nck]=='@')
|
|
{ /* this is a chan op */
|
|
*token[nck]++;
|
|
if(!strcmp(token[nck],CHANSVR)) continue;
|
|
strcat(modechar,"o");
|
|
strcat(nicklist," ");
|
|
strcat(nicklist,token[nck]);
|
|
opcnt++;
|
|
if(opcnt > 6)
|
|
{ sprintf(buf,"MODE %s %s %s 0\n",
|
|
token[4],modechar,nicklist);
|
|
writeln(sevsck,buf);
|
|
opcnt=0;
|
|
strcpy(modechar,"-");
|
|
nicklist[0]='\0';
|
|
}
|
|
}
|
|
}
|
|
if( (*token[nck]=='+') || (*token[nck]=='@')) *token[nck]++;
|
|
if((CLEAR_KICK) || (doclearkick))
|
|
{ if(strcmp(token[nck],CHANSVR))
|
|
{ sprintf(kickbuf,"KICK %s %s :CLEARCHAN KICK\n",
|
|
token[4],token[nck]);
|
|
writeln(sevsck,kickbuf);
|
|
}
|
|
}
|
|
}
|
|
if(opcnt)
|
|
{ sprintf(buf,"MODE %s %s %s 0\n",
|
|
token[4],modechar,nicklist);
|
|
writeln(sevsck,buf);
|
|
opcnt=0;
|
|
}
|
|
}
|
|
break;
|
|
case 366:
|
|
if(status == CLEAROPS)
|
|
{ status=0;
|
|
doclearkick=0;
|
|
doclearops=0;
|
|
sprintf(buf,":%s PART %s\n",CHANSVR,channel);
|
|
writeln(sevsck,buf);
|
|
}
|
|
if(status == CLEARCHAN)
|
|
{ have_names=1;
|
|
docleanchan=0;
|
|
docleanops=0;
|
|
|
|
if(!CLEAR_KICK)
|
|
{ sprintf(buf,":%s PART %s\n",CHANSVR,channel);
|
|
writeln(sevsck,buf);
|
|
}
|
|
else
|
|
{ sprintf(buf,"MODE %s +o %s 0\n",channel,CHANSVR);
|
|
writeln(sevsck,buf);
|
|
}
|
|
}
|
|
break;
|
|
case 367:
|
|
if((status == CLEARCHAN) || (status == CLEARBANS))
|
|
{
|
|
if(modecnt==0)
|
|
{ strcpy(modelist,"-");
|
|
strcpy(modemask,"");
|
|
}
|
|
|
|
strcat(modelist,"b");
|
|
strcat(modemask," ");
|
|
strcat(modemask,token[4]);
|
|
modecnt++;
|
|
|
|
if(modecnt>3)
|
|
{ sprintf(buf,"MODE %s %s %s\n", channel,modelist,modemask);
|
|
writeln(sevsck,buf);
|
|
strcpy(modelist,"-");
|
|
strcpy(modemask,"");
|
|
modecnt=0;
|
|
}
|
|
}
|
|
break;
|
|
case 368:
|
|
if(modecnt)
|
|
{ sprintf(buf,"MODE %s %s %s\n", channel,modelist,modemask);
|
|
writeln(sevsck,buf);
|
|
strcpy(modelist,"-");
|
|
strcpy(modemask,"");
|
|
modecnt=0;
|
|
}
|
|
|
|
if(status == CLEARBANS)
|
|
{ status = 0;
|
|
if(!CLEAR_KICK)
|
|
{ sprintf(buf,":%s PART %s\n",CHANSVR,channel);
|
|
writeln(sevsck,buf);
|
|
}
|
|
}
|
|
if(status == CLEARCHAN) {
|
|
have_bans=1;
|
|
|
|
|
|
if( (have_bans && have_names) )
|
|
{ status=0;
|
|
have_names=0;
|
|
have_bans=0;
|
|
if(!CLEAR_KICK)
|
|
{ sprintf(buf,":%s PART %s\n",CHANSVR,channel);
|
|
writeln(sevsck,buf);
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
case 433:
|
|
case 463:
|
|
if(DccCtr!=-2) break;
|
|
if(NOWTIME-lastkill < 90) break;
|
|
close(botsck);
|
|
sprintf(buf,"KILL UWORLD UWORLD :GO AWAY\n");
|
|
writeln(sevsck,buf);
|
|
botsck=bot_login(UPLINK);
|
|
break;
|
|
default:
|
|
return;
|
|
}
|
|
}
|