#include #include #include #include "codybot.h" char *slap_items[20] = { "an USB cord", "a power cord", "a laptop", "a slice of ham", "a keyboard", "a laptop cord", "a banana peel", "a dictionary", "an atlas book", "a biography book", "an encyclopedia", "a rubber band", "a large trout", "a rabbit", "a lizard", "a dinosaur", "a chair", "a mouse pad", "a C programming book", "a belt" }; unsigned int slap_max = 10, slap_cnt, slap_hour; void SlapCheck(struct raw_line *rawp) { char *c = rawp->text; if ((*c==1 && *(c+1)=='A' && *(c+2)=='C' && *(c+3)=='T' && *(c+4)=='I' && *(c+5)=='O' && *(c+6)=='N' && *(c+7)==' ' && *(c+8)=='s' && *(c+9)=='l' && *(c+10)=='a' && *(c+11)=='p' && *(c+12)=='s' && *(c+13)==' ') && ((*(c+14)=='c' && *(c+15)=='o' && *(c+16)=='d' && *(c+17)=='y' && *(c+18)=='b' && *(c+19)=='o' && *(c+20)=='t' && *(c+21)==' ') || (*(c+14)=='S' && *(c+15)=='p' && *(c+16)=='r' && *(c+17)=='i' && *(c+18)=='n' && *(c+19)=='g' && *(c+20)=='S' && *(c+21)=='p' && *(c+22)=='r' && *(c+23)=='o' && *(c+24)=='c' && *(c+25)=='k' && *(c+26)=='e' && *(c+27)=='t' && *(c+28)==' '))) { RawGetTarget(rawp); gettimeofday(&tv0, NULL); time_t slap_time = (time_t)tv0.tv_sec; struct tm *tm0 = gmtime(&slap_time); if (slap_cnt == 0) { slap_hour = tm0->tm_hour; } else { if (slap_hour != tm0->tm_hour) { slap_hour = tm0->tm_hour; slap_cnt = 0; } else if (slap_hour == tm0->tm_hour && slap_cnt >= slap_max) return; } srand((unsigned int)tv0.tv_usec/((rand()%10)+1)); sprintf(buffer, "\001ACTION slaps %s with %s\x01", rawp->nick, slap_items[rand()%20]); Msg(buffer); ++slap_cnt; } }