/* * pubhandlers.c * (C) Peter Salanki 2004 * This program is copyright, and covered by the Gnu Public License. * The Natasha bot. * sorcer@linux.se */ #include #include #include #include #include #include #include #include #include "../../settings.h" #include "../../globals.h" #include "../../bottypes.h" #include "pubtab.h" #define NAME "PUBHandlers" #define VERSION 1.00 char *p_gettv (char *buffer, char name[10]); void qreg(struct arm *arm, char *email); MODULE_INIT _module_init(MODULE m); MODULE_DESTROY _module_destroy(MODULE m); MODULE_INIT _module_init(MODULE m) { strncpy(m->name, NAME, 20); strncpy(m->compiledate, __DATE__ " " __TIME__, 30); m->version = VERSION; } MODULE_DESTROY _module_destroy(MODULE m) { } void p_parse (char *command, char *a, struct arm *arm) { int i = 0; char msg[256]; if(strcasecmp(command, "ME") == 0) return; // We don't want me commands if(strcasecmp(command, arm->nick) == 0) strcpy(command, "ME"); while (pubtab[i].func != 0) { if (strcasecmp (pubtab[i].msg, command) == 0) { if (userlevel(arm->parsevars->u) >= pubtab[i].level) { pubtab[i].func (a, arm); } else { sprintf(msg, "You don't have access to this command. If you think you should have, check that you are AUTH'd and try /msg %s IDENT", arm->nick); say(arm->parsevars->sender, msg, arm, arm->parsevars->u); } return; } i++; } } void p_me (char *a, struct arm *arm) { char command[512]; char arg[512]; char tmp[512]; struct module *m; void (*cmd)(); sscanf(a, "%s", command); sprintf(tmp, "%s ", command); STR_replace_c (a, tmp, "", arg); m = findmodule("MSGHandlers"); if(m != NULL) { if(strcasecmp(command, "OP") == 0) { if(countargs(a) == 1) sprintf(command, "%s %s", arm->parsevars->args[0], arm->parsevars->sender); if(countargs(a) == 2) sprintf(command, "%s %s", arm->parsevars->args[0], arg); cmd = dlsym(m->fl, "m_op"); cmd(command, arm); return; } if(strcasecmp(command, "DEOP") == 0) { if(countargs(a) == 1) sprintf(command, "%s %s", arm->parsevars->args[0], arm->parsevars->sender); if(countargs(a) == 2) sprintf(command, "%s %s", arm->parsevars->args[0], arg); cmd = dlsym(m->fl, "m_deop"); cmd(command, arm); return; } if(strcasecmp(command, "DEVOICE") == 0) { if(countargs(a) == 1) sprintf(command, "%s %s", arm->parsevars->args[0], arm->parsevars->sender); if(countargs(a) == 2) sprintf(command, "%s %s", arm->parsevars->args[0], arg); cmd = dlsym(m->fl, "m_devoice"); cmd(command, arm); return; } if(strcasecmp(command, "VOICE") == 0) { if(countargs(a) == 1) sprintf(command, "%s %s", arm->parsevars->args[0], arm->parsevars->sender); if(countargs(a) == 2) sprintf(command, "%s %s", arm->parsevars->args[0], arg); cmd = dlsym(m->fl, "m_voice"); cmd(command, arm); return; } if(strcasecmp(command, "CHANSET") == 0) { sprintf(command, "%s %s", arm->parsevars->args[0], arg); cmd = dlsym(m->fl, "m_chanset"); cmd(command, arm); return; } if(strcasecmp(command, "USERLEV") == 0) { sprintf(command, "%s %s", arm->parsevars->args[0], arg); cmd = dlsym(m->fl, "m_userlev"); cmd(command, arm); return; } if(strcasecmp(command, "GREET") == 0) { sprintf(command, "%s %s", arm->parsevars->args[0], arg); cmd = dlsym(m->fl, "m_greet"); cmd(command, arm); return; } if(strcasecmp(command, "KICK") == 0) { sprintf(command, "%s %s", arm->parsevars->args[0], arg); cmd = dlsym(m->fl, "m_kick"); cmd(command, arm); return; } if(strcasecmp(command, "BAN") == 0) { sprintf(command, "%s %s", arm->parsevars->args[0], arg); cmd = dlsym(m->fl, "m_ban"); cmd(command, arm); return; } if(strcasecmp(command, "UNBAN") == 0) { sprintf(command, "%s %s", arm->parsevars->args[0], arg); cmd = dlsym(m->fl, "m_unban"); cmd(command, arm); return; } if(strcasecmp(command, "WHOIS") == 0) { cmd = dlsym(m->fl, "m_whois"); cmd(arg, arm); return; } if(strcasecmp(command, "ACCESS") == 0) { sprintf(command, "%s %s", arm->parsevars->args[0], arg); cmd = dlsym(m->fl, "m_access"); cmd(command, arm); return; } if(strcasecmp(command, "IDENT") == 0) { cmd = dlsym(m->fl, "m_ident"); cmd(arg, arm); return; } } #ifdef Q if(strcasecmp(command, "QREG") == 0) { if(userlevel(arm->parsevars->u) < MASTER_TECHNICIAN) return; if(strcasecmp(arg, "QREG") == 0 || strstr(arg, "@") != NULL) qreg(arm, arg); /* Send to another function */ else { sprintf(command, "%s@%s", Q_NICK, Q_HOST); sprintf(tmp, "AUTH %s %s", arm->auth, arg); exprivmsg(command, tmp, arm); sprintf(tmp, "NEWPASS %s %s %s", arg, Q_PASS, Q_PASS); exprivmsg(Q_NICK, tmp, arm); } return; } #ifdef Q_AUTOAUTH if(strcasecmp(command, "SYNC") == 0) { if(userlevel(arm->parsevars->u) < HELPER) return; cmd = dlsym(m->fl, "m_sync"); cmd(arm->parsevars->args[0], arm); } #endif #endif } void p_stats (char *a, struct arm *arm) { char msg[512]; if(arm->parsevars->c == NULL) return; #ifdef PAY_STATS else if(arm->parsevars->c->stats == 0) sprintf(msg, "To activate logging and statistics on your channel, please visit: http://www.botservice.se/get_stats.php"); #else else if(arm->parsevars->c->stats == 0) sprintf(msg, "Logging and statistics are not activated on this channel."); #endif else sprintf(msg, "%cStats:%c %s?cid=%i %cLogs:%c %s?cid=%i", BOLD, BOLD, STATSADDR, arm->parsevars->c->id, BOLD, BOLD, LOGADDR, arm->parsevars->c->id); privmsg(arm->parsevars->args[0], msg); } void p_chaninfo (char *a, struct arm *arm) { char msg[512]; if(arm->parsevars->c == NULL) return; else if(arm->parsevars->c->infobot == 0 && userlevel(arm->parsevars->u) < HELPER) snprintf(msg, 512,"Chanmode infobot is not activated on this channel."); else snprintf(msg, 512, "%cChaninfo:%c %s?channel=%s", BOLD, BOLD, CHANINFOADDR, arm->parsevars->c->name+1); privmsg(arm->parsevars->args[0], msg); } void p_peak (char *a, struct arm *arm) { char msg[512]; if(arm->parsevars->c == NULL || arm->parsevars->c->peak == 0) return; else sprintf(msg, "%cPeak:%c %i", BOLD, BOLD, arm->parsevars->c->peak); #ifdef SPAMSCAN if(SOnChannel(arm->parsevars->c)) if(!SpamChannel(arm->parsevars->c)) say(arm->parsevars->sender, "Peak has already been asked in the last minutes. Please wait a while before asking again.", arm, arm->parsevars->u); else { privmsg(arm->parsevars->args[0], msg); SpamChannelWait(arm->parsevars->c); } else #endif privmsg(arm->parsevars->args[0], msg); } void p_quote(char *a, struct arm *arm) { /* Handle !quote, quoting commands. * !quote, will print a random quote. * !quote add , will add a quote * !quote del , will delete a quote */ char msg[512]; char query[MAX_QUERY*2]; char command[512]; char arg[512]; char tmp[512]; int cid; char *estext; if(arm->parsevars->c != NULL && arm->parsevars->c->quotes == 0) { say(arm->parsevars->sender, "Channel needs to be +quotes for !quote to work.", arm, arm->parsevars->u); return; } if(arm->parsevars->c == NULL) cid = 0; else cid = arm->parsevars->c->id; if(cid == 0 && arm->id != 1) return; if(countargs(a) == 0) { snprintf(query, MAX_QUERY*2, "SELECT `adder`,`text` FROM `quotes` WHERE `cid` = '%i' ORDER BY RAND() LIMIT 0,1", cid); dbquery(query); if((row = mysql_fetch_row(res))) { snprintf(msg, 512, "%c\"%s\"%c added by: %c%s%c", BOLD, row[1], BOLD, BOLD, row[0], BOLD); } else snprintf(msg, 512, "No quotes in database."); EndDbQuery(); #ifdef SPAMSCAN if(SOnChannel(arm->parsevars->c)) if(!SpamChannel(arm->parsevars->c)) say(arm->parsevars->sender, "A random quote has already been asked in the last minutes. Please wait a while before asking again.", arm, arm->parsevars->u); else { privmsg(arm->parsevars->args[0], msg); SpamChannelWait(arm->parsevars->c); } else #endif privmsg(arm->parsevars->args[0], msg); } else { sscanf(a, "%s", command); sprintf(tmp, "%s ", command); STR_replace_c (a, tmp, "", arg); if(strcasecmp(command, "ADD") == 0) { if(arm->parsevars->c != NULL && chanuserlevel(arm->parsevars->u, arm->parsevars->c) < CHAN_FRIEND) { say(arm->parsevars->sender, "You need to be atleast channel friend to add quotes.", arm, arm->parsevars->u); return; } estext = escapequery(arg); snprintf(query, MAX_QUERY*2, "INSERT INTO `quotes` (`adder`,`text`,`cid`) VALUES ('%s','%s','%i')", arm->parsevars->sender, estext, cid); Free(estext); dbquery(query); EndDbQuery(); say(arm->parsevars->sender, "Quote added.", arm, arm->parsevars->u); } else if(strcasecmp(command, "DEL") == 0) { estext = escapequery(arg); snprintf(query, MAX_QUERY*2, "DELETE FROM `quotes` WHERE `text` = '%s' AND `cid` = %i", estext, cid); Free(estext); dbquery(query); EndDbQuery(); say(arm->parsevars->sender, "Quote deleted.", arm, arm->parsevars->u); } else say(arm->parsevars->sender, "Syntax error, you nedd to use !quote add or !quote del or just !quote.", arm, arm->parsevars->u); } } void p_netstat (char *a, struct arm *arm) { struct channel *c; char msg[2048]; short go = 0; if(strcmp(arm->parsevars->args[0], HOMECHAN) != 0) return; c = firstchan; while (c != NULL) { if(c->arm == arm) { if(c->suspended == 0 && (c->ison == 0 || c->isop == 0)) { if(go == 0) { go = 1; sprintf(msg, "%cNo op/can't get in:%c ", BOLD, BOLD); } if(c->ison == 0) strcat(msg ,"*"); strcat(msg, c->name); strcat(msg, " "); } } c = c->next; } if(go == 1) say(arm->parsevars->sender, msg, arm, arm->parsevars->u); } void p_tv (char *a, struct arm *arm) { FILE *pFile; long lSize; char *buffer; char msg[512] = ""; struct channel *c; char *svt1, *svt2, *tv3, *tv4, *kanal5, *ztv; c = findchannel(arm->parsevars->args[0]); if(c == NULL || c->tv == 0) return; pFile = fopen ("tv" , "r"); if (pFile==NULL) return; fseek (pFile , 0 , SEEK_END); lSize = ftell (pFile); rewind (pFile); buffer = (char*) Malloc (lSize); if (buffer == NULL) return; fread (buffer,1,lSize,pFile); fclose (pFile); svt1 = p_gettv(buffer, "svt1"); svt2 = p_gettv(buffer, "svt2"); tv3 = p_gettv(buffer, "tv3"); tv4 = p_gettv(buffer, "tv4"); kanal5 = p_gettv(buffer, "kanal5"); ztv = p_gettv(buffer, "ztv"); /* Say */ sprintf(msg, "%cTV:%c SVT 1: %c%s%c SVT 2: %c%s%c TV3: %c%s%c TV4: %c%s%c Kanal 5: %c%s%c ZTV: %c%s%c", BOLD, BOLD, BOLD, svt1, BOLD, BOLD, svt2, BOLD, BOLD, tv3, BOLD, BOLD, tv4, BOLD, BOLD, kanal5, BOLD, BOLD, ztv, BOLD); Free(svt1); Free(svt2); Free(tv3); Free(tv4); Free(kanal5); Free(ztv); #ifdef SPAMSCAN if(SOnChannel(c)) if(!SpamChannel(c)) say(arm->parsevars->sender, "TV has already been asked in the last minutes. Please wait a while before asking again.", arm, arm->parsevars->u); else { privmsg(arm->parsevars->args[0], msg); SpamChannelWait(c); } else #endif privmsg(arm->parsevars->args[0], msg); Free (buffer); } char *p_gettv (char *buffer, char name[10]) { char tmp[1000]; char tmp2[10000]; int i = 0; int j = 0; char *text = Malloc(256); memset(text,0x0,256); sprintf(tmp, "src=\"img2/%s.gif\"", name); if(strstr(buffer, tmp) == NULL) return text; strncpy(tmp2, strstr(buffer, tmp), 10000); if(strstr(tmp2, "('http://") == NULL) return text; strncpy(tmp, strstr(tmp2, "('http://"), 1000); for(j = 0; tmp[i] != '\0' && tmp[i] != '>'; ++i); ++i; strncpy(tmp2, "", 1000); for(j = 0; tmp[i] != '\0' && tmp[i] != '<' && i < 1000; ++j) { tmp2[j] = tmp[i]; ++i; } strncpy(text, tmp2, 256); return text; } void p_google (char *a, struct arm *arm) { /* Google command, query from web, read and parse */ char run[512]; int i, j, fd; char buffer[2048] = ""; struct channel *c = findchannel(arm->parsevars->args[0]); if(c == NULL) return; else if(c->infobot == 0 && userlevel(arm->parsevars->u) < HELPER) { privmsg(arm->parsevars->args[0], "Chanmode infobot is not activated on this channel."); return; } if(!checkargs(1, 1, a, arm)) return; #ifdef SPAMSCAN if(SOnChannel(c)) if(!SpamChannel(c)) { say(arm->parsevars->sender, "TV or google has already been asked in the last minutes. Please wait a while before asking again.", arm, arm->parsevars->u); return; } SpamChannelWait(c); #endif snprintf(run, 512, "wget --timeout=3 --tries=2 --output-document=googletmp \"" GOOGLEADDR "?query=%s\"", a); system(run); /* Do the googeling */ /* Read results into buffer */ fd = open ("googletmp", O_RDONLY); if(fd == 0) return; for(i = 0; i < 2047; ++i) read(fd, &(buffer[i]), 1); close(fd); if(buffer[0] == '0' && buffer[1] == '\0') { privmsg(arm->parsevars->args[0], "No matches."); return; } /* Handle the data in the buffer */ STR_replace_c(buffer, "%B", "\002", buffer); /* Put to IRC */ for(i = 0; buffer[i] != '\0'; ++i) { memset(run, 0, 512); for(j = 0; buffer[i] != '\n' && buffer[i] != '\0'; ++j) { run[j] = buffer[i]; ++i; } privmsg(arm->parsevars->args[0], run); } } #if 0 void p_weather (char *a, struct arm *arm) { FILE *pFile; long lSize; char *buffer; char msg[512] = ""; struct channel *c; char *svt1, *svt2, *tv3, *tv4, *kanal5, *ztv; c = findchannel(arm->parsevars->args[0]); if(c == NULL || c->tv == 0) return; pFile = fopen ("weather" , "r"); if (pFile==NULL) return; fseek (pFile , 0 , SEEK_END); lSize = ftell (pFile); rewind (pFile); buffer = (char*) Malloc (lSize); if (buffer == NULL) return; fread (buffer,1,lSize,pFile); fclose (pFile); svt1 = p_gettv(buffer, "svt1"); svt2 = p_gettv(buffer, "svt2"); tv3 = p_gettv(buffer, "tv3"); tv4 = p_gettv(buffer, "tv4"); kanal5 = p_gettv(buffer, "kanal5"); ztv = p_gettv(buffer, "ztv"); /* Say */ sprintf(msg, "%cTV:%c SVT 1: %c%s%c SVT 2: %c%s%c TV3: %c%s%c TV4: %c%s%c Kanal 5: %c%s%c ZTV: %c%s%c", BOLD, BOLD, BOLD, svt1, BOLD, BOLD, svt2, BOLD, BOLD, tv3, BOLD, BOLD, tv4, BOLD, BOLD, kanal5, BOLD, BOLD, ztv, BOLD); Free(svt1); Free(svt2); Free(tv3); Free(tv4); Free(kanal5); Free(ztv); #ifdef SPAMSCAN if(SOnChannel(c)) if(!SpamChannel(c)) say(arm->parsevars->sender, "TV has already been asked in the last minutes. Please wait a while before asking again.", arm, arm->parsevars->u); else { privmsg(arm->parsevars->args[0], msg); SpamChannelWait(c); } else #endif privmsg(arm->parsevars->args[0], msg); Free (buffer); } char *p_getweather (char *buffer, char name[10]) { char tmp[1000]; char tmp2[10000]; int i = 0; int j = 0; char *text = Malloc(256); memset(text,0x0,256); sprintf(tmp, "src=\"img2/%s.gif\"", name); if(strstr(buffer, tmp) == NULL) return text; strncpy(tmp2, strstr(buffer, tmp), 10000); if(strstr(tmp2, "('http://") == NULL) return text; strncpy(tmp, strstr(tmp2, "('http://"), 1000); for(j = 0; tmp[i] != '\0' && tmp[i] != '>'; ++i); ++i; strncpy(tmp2, "", 1000); for(j = 0; tmp[i] != '\0' && tmp[i] != '<' && i < 1000; ++j) { tmp2[j] = tmp[i]; ++i; } strncpy(text, tmp2, 256); return text; } #endif void p_date (char *a, struct arm *arm) { time_t tim; char tmstr[512] = ""; struct channel *c; struct tm *tmstruct; c = findchannel(arm->parsevars->args[0]); if(c == NULL || c->infobot == 0) return; tim = time(NULL); tmstruct = localtime(&tim); strftime(tmstr, 512, "It is %A the %dth of %B. The time is: %H:%M:%S.", tmstruct); privmsg(arm->parsevars->args[0], tmstr); } void p_vote (char *a, struct arm *arm) { /* Handle !vote, voting commands. * !vote start , will start a vote. CHAN_OP required. Max question length: 255 chars * !vote stop, will stop a vote. Vote founder or CHAN_MASTER * !vote yes, will vote yes * !vote no, will vote no */ char command[512]; char arg[512]; char tmp[512]; int i, j; struct vote *vote; struct activeuser *u; struct channel *c; if(!checkargs(1, 1, a, arm)) return; sscanf(a, "%s", command); sprintf(tmp, "%s ", command); STR_replace_c (a, tmp, "", arg); c = findchannel(arm->parsevars->args[0]); if(c == NULL) { if(arm->id == 1) say(arm->parsevars->sender, "This is homechan, go vote somewhere else.", arm, arm->parsevars->u); return; } else if(c->vote != 1) { say(arm->parsevars->sender, "Sorry, but this channel doesen't have vote enabled (chanset +vote).", arm, arm->parsevars->u); return; } if(strcasecmp(command, "START") == 0) { if(!checkargs(3, 1, a, arm)) return; for(i = 0; a[i] != ' '; ++i); ++i; for(; a[i] != ' '; ++i); ++i; strncpy(tmp, "", 512); j = 0; while (a[i] != '\0' && j < 510) { tmp[j] = a[i]; ++i; ++j; } if(strlen(tmp) > 255) { say(arm->parsevars->sender, "Sorry, the question cannot be longer than 255 characters.", arm, arm->parsevars->u); return; } sscanf(a, "%s %i", command, &i); if(i > 3600*24 || i < 1) { say(arm->parsevars->sender, "Time value is out of range. Time should be in minutes and in the range of 1 minute to 24 hours.", arm, arm->parsevars->u); return; } if((vote = AllocateVote(c)) == NULL) { say(arm->parsevars->sender, "There is already a vote active for that channel.", arm, arm->parsevars->u); return; } strncpy(vote->question, tmp, 255); vote->asker = findauser(arm->parsevars->sender)->userid; vote->expiretime = time(NULL) + i*60; /* Announce vote into channel */ snprintf(tmp, 512, "A vote has been started by: %c%s%c. The question is: %c%s%c Type %c!vote yes%c to vote yes and %c!vote no%c to vote no.", BOLD, arm->parsevars->sender, BOLD, BOLD, vote->question, BOLD, BOLD, BOLD, BOLD, BOLD); privmsg(arm->parsevars->args[0], tmp); } else if(strcasecmp(command, "STOP") == 0) { /* Stop the vote */ if((vote = c->votestruct) == NULL) { say(arm->parsevars->sender, "There is no vote going on in here.", arm, arm->parsevars->u); return; } u = findauser(arm->parsevars->sender); if(vote->asker == u->userid || chanuserlevel(arm->parsevars->u, arm->parsevars->c) >= CHAN_MASTER) { if(vote->yes > vote->no) snprintf(tmp, 512, "Vote stopped. %cYes%c won with %c%i%c votes against %c%i%c.", BOLD, BOLD, BOLD, vote->yes, BOLD, BOLD, vote->no, BOLD); else if(vote->no > vote->yes) snprintf(tmp, 512, "Vote stopped. %cNo%c won with %c%i%c votes against %c%i%c.", BOLD, BOLD, BOLD, vote->no, BOLD, BOLD, vote->yes, BOLD); else if(vote->no == vote->yes) snprintf(tmp, 512, "Vote stopped. Vote ended in tie with %c%i%c yes and no votes.", BOLD, vote->yes, BOLD); privmsg(arm->parsevars->args[0], tmp); FreeVote(c); } else say(arm->parsevars->sender, "Not enough access.", arm, arm->parsevars->u); } else if(strcasecmp(command, "YES") == 0) { /* Vote yes */ if((vote = c->votestruct) == NULL) { say(arm->parsevars->sender, "There is no vote going on in here.", arm, arm->parsevars->u); return; } u = findauser(arm->parsevars->sender); for(i = 0; i <= vote->lastvid; ++i) { if(vote->voted[i] == u) { say(arm->parsevars->sender, "You have already voted in this vote.", arm, arm->parsevars->u); return; } } ++vote->lastvid; vote->voted[vote->lastvid] = u; ++vote->yes; say(arm->parsevars->sender, "Voted yes.", arm, arm->parsevars->u); } else if(strcasecmp(command, "NO") == 0) { /* Vote no */ if((vote = c->votestruct) == NULL) { say(arm->parsevars->sender, "There is no vote going on in here.", arm, arm->parsevars->u); return; } u = findauser(arm->parsevars->sender); for(i = 0; i <= vote->lastvid; ++i) { if(vote->voted[i] == u) { say(arm->parsevars->sender, "You have already voted in this vote.", arm, arm->parsevars->u); return; } } ++vote->lastvid; vote->voted[vote->lastvid] = u; ++vote->no; say(arm->parsevars->sender, "Voted no.", arm, arm->parsevars->u); } else if(strcasecmp(command, "STATUS") == 0) { /* Vote status */ if((vote = c->votestruct) == NULL) { say(arm->parsevars->sender, "There is no vote going on in here.", arm, arm->parsevars->u); return; } if(vote->yes > vote->no) snprintf(tmp, 512, "Vote question: %c%s%c %cYes%c is ahead with %c%i%c votes against %c%i%c. Vote with !vote yes and !vote no", BOLD, vote->question, BOLD, BOLD, BOLD, BOLD, vote->yes, BOLD, BOLD, vote->no, BOLD); else if(vote->no > vote->yes) snprintf(tmp, 512, "Vote question: %c%s%c %cNo%c is ahead with %c%i%c votes against %c%i%c. Vote with !vote yes and !vote no", BOLD, vote->question, BOLD, BOLD, BOLD, BOLD, vote->no, BOLD, BOLD, vote->yes, BOLD); else if(vote->no == vote->yes) snprintf(tmp, 512, "Vote question: %c%s%c Vote is in tie with %c%i%c yes and no votes.", BOLD, vote->question, BOLD, BOLD, vote->no, BOLD); privmsg(arm->parsevars->args[0], tmp); snprintf(tmp, 512, "The vote will end in %li minute(s). Vote with %c!vote yes%c and %c!vote no%c", (vote->expiretime - time(NULL))/60, BOLD, BOLD, BOLD, BOLD); privmsg(arm->parsevars->args[0], tmp); } } #ifdef MODULE_bash void p_tickets (char *a, struct arm *arm) { /* Handle !tickets, bash command. */ amodfunc("bash", "ticket", arm); } void p_sz (char *a, struct arm *arm) { /* Handle !sz, bash command. */ amodfunc("bash", "sz_time", arm); } void p_gz (char *a, struct arm *arm) { /* Handle !gz, bash command. */ amodfunc("bash", "gz_time", arm); } #endif void p_showcommands (struct arm *arm) { int i = 0, j; char buffer[512]; while (pubtab[i].func != 0) { if (pubtab[i].level <= userlevel (arm->parsevars->u)) { memset (buffer, 0, 512); sprintf(buffer, "%cPublic:%c ", BOLD, BOLD); if(strcmp(pubtab[i].msg, "ME") == 0) strncat (buffer, arm->nick, 256); else strncat (buffer, pubtab[i].msg, 256); strcat (buffer, " "); strncat (buffer, pubtab[i].summary, 200); j = strlen (buffer); sprintf (buffer + j, " - level %d.", pubtab[i].level); dumpmessage (arm->parsevars->sender, buffer); } i++; } } void p_help (char *a, struct arm *arm) { int i; char send[4096]; i = 0; while (pubtab[i].func != 0) { if (strcasecmp (a, pubtab[i].msg) == 0) { sprintf(send, pubtab[i].help, arm->nick); dumpmessage (arm->parsevars->sender, send); return; } i++; } sprintf(send, "No help found on that topic. Try /msg %s SHOWCOMMANDS.", arm->nick); say (arm->parsevars->sender, send, arm, arm->parsevars->u); } void qreg(struct arm *arm, char *email) { /* First step in a Qreg */ char newnick[NICKLEN], oldnick[NICKLEN]; char tmp[512]; /* Fix nick for Q auth */ STR_replace_c(arm->nick, "^", "", newnick); STR_replace_c(newnick, "|", "", newnick); /* Store old nick */ strncpy(oldnick, arm->nick, NICKLEN); /* Switch to new nick */ strncpy(arm->nick, newnick, NICKLEN); nick(arm->nick, arm); /* Send Q hello */ snprintf(tmp, 512,"HELLO %s %s", email, email); exprivmsg(Q_NICK, tmp, arm); /* Set correct auth */ strncpy(arm->auth, newnick, NICKLEN); snprintf(tmp, 512, "UPDATE `arms` SET `auth` = '%s' WHERE `id` = %i", arm->auth, arm->id); dbquery(tmp); EndDbQuery(); /* Restore nick */ strncpy(arm->nick, oldnick, NICKLEN); nick(arm->nick, arm); }