#include "botserv.h" void do_seen(User *u, ChannelInfo *ci, char *target) { User *u2; Channel *targetchan; char timebuf[BUFSIZE], timebuf2[BUFSIZE], onlinebuf[BUFSIZE]; struct u_chanlist *uc; int type = 0; char *chan, *vhost, *msg, *newnick; time_t now = time(NULL); struct tm *lastbuf; long int tbuf, last; int days_, hours_, minutes_, seconds_ = 0; if (!target) return; if (strlen(target) > 30) { BotSpeakLang(ci, u, NICKTOOLONG, NICKMAX); return; } if (stricmp(target, ci->bi->nick)==0) { BotSpeakLang(ci, u, GS_BOT, u->nick); return; } if (stricmp(target, u->nick)==0) { BotSpeakLang(ci, u, GS_YOU, u->nick); return; } if ((u2 = finduser(target))) { snprintf(onlinebuf, BUFSIZE, getLangString(u, GS_ONLINE),NULL); } else { snprintf(onlinebuf, BUFSIZE, getLangString(u, GS_OFFLINE), target); } if (u2) { for (uc = u2->chans; uc; uc = uc->next) { if ((ci == uc->chan->ci)) { BotSpeakLang(ci, u, GS_IN_CHAN, target); return; } } } qbuf1 = quote(target); do_query("SELECT * FROM " DBNAME " WHERE `nick` = '%s';", qbuf1); free(qbuf1); myres = mysql_store_result(mymysql); if (mysql_num_rows(myres) > 0) { myrow = mysql_fetch_row(myres); type = atoi(myrow[1]); vhost = myrow[3]; chan = myrow[4]; msg = myrow[5]; newnick = myrow[8]; last = atol(myrow[6]); tbuf = now - last; days_ = (tbuf/86400); hours_ = (tbuf/3600) % 24; minutes_ = (tbuf/60) % 60; seconds_ = (tbuf) % 60; lastbuf = localtime(&last); strftime_lang(timebuf2, BUFSIZE, u, STRFTIME_DATE_TIME_FORMAT, lastbuf); if (days_) { snprintf(timebuf, BUFSIZE, getLangString(u, GS_TIME_FULL), days_, hours_, minutes_); } else if (hours_) { snprintf(timebuf, BUFSIZE, getLangString(u, GS_TIME_HOURS), hours_, minutes_); } else if (minutes_) { snprintf(timebuf, BUFSIZE, getLangString(u, GS_TIME_MINUTES), minutes_); } else { snprintf(timebuf, BUFSIZE, getLangString(u, GS_TIME_SECONDS), seconds_); } if (type == 1) { // connect BotSpeakLang(ci, u, GS_CONNECT, target, vhost, timebuf, timebuf2, onlinebuf); } else if (type == 2) { // nickchange to if ((u2 = finduser(newnick))) { snprintf(onlinebuf, BUFSIZE, getLangString(u, GS_ONLINE_AS), newnick); } else { snprintf(onlinebuf, BUFSIZE, getLangString(u, GS_OFFLINE), newnick); } BotSpeakLang(ci, u, GS_NICKCHANGE_TO, target, vhost, newnick, timebuf, onlinebuf); } else if (type == 3) { // nickchange from BotSpeakLang(ci, u, GS_NICKCHANGE_FROM, target, vhost, newnick, target, timebuf, onlinebuf); } else if (type == 4) { // join targetchan=findchan(chan); if ((stricmp(ci->name,chan)!=0) && ((targetchan) && (targetchan->mode & anope_get_secret_mode()))) { BotSpeakLang(ci, u, GS_JOIN_SECRET, target, vhost, timebuf, onlinebuf); } else { BotSpeakLang(ci, u, GS_JOIN, target, vhost, chan, timebuf, onlinebuf); } } else if (type == 5) { // part targetchan=findchan(chan); if ((stricmp(ci->name,chan)!=0) && ((targetchan) && (targetchan->mode & anope_get_secret_mode()))) { BotSpeakLang(ci, u, GS_PART_SECRET, target, vhost, timebuf, onlinebuf); } else { BotSpeakLang(ci, u, GS_PART, target, vhost, chan, msg, timebuf, onlinebuf); } } else if (type == 6) { // quit BotSpeakLang(ci, u, GS_QUIT, target, vhost, msg, timebuf, timebuf2); } else if (type == 7) { // kick targetchan=findchan(chan); if ((stricmp(ci->name,chan)!=0) && ((targetchan) && (targetchan->mode & anope_get_secret_mode()))) { BotSpeakLang(ci, u, GS_KICK_SECRET, target, vhost, timebuf, onlinebuf); } else { if (((u->na && u->na->nc && (u->na->nc->language == LANG_DE)) || (NSDefLanguage == LANG_DE))) { // german language have a different grammar BotSpeakLang(ci, u, GS_KICK, target, vhost, timebuf, chan, msg, onlinebuf); } else { // english or other languages BotSpeakLang(ci, u, GS_KICK, target, vhost, chan, msg, timebuf, onlinebuf); } } } else { // error - this message should never be send BotSpeakLang(ci, u, GS_FAILED); } } else { // (mysql_num_rows(res) // not found BotSpeakLang(ci, u, GS_NOT_SEEN, target); } if (myres) mysql_free_result(myres); }