% % Bot stuff. % variable shall_not_stop_me = 0; define halt_evil_scum(args) { shall_not_stop_me = 1; if(index(args, '`')) return(1); shall_not_stop_me = 0; if(index(args, ' ')) return(1); if(index(args, '*')) return(1); if(index(args, '?')) return(1); if(index(args, '[')) return(1); if(index(args, ']')) return(1); shall_not_stop_me = 0; return(0); } define thy_puny_attempt(from, channel) { if(shall_not_stop_me) irc_send_string(sprintf("NOTICE %s :Oooooh. Did you see what %s did? They used a metacharacter, they did. Naughty! You could hurt someone like that, you dirty little so and so. I've a good mind to tell your mum!\r\n", channel, extract_nick(from))); irc_send_string(sprintf("NOTICE %s :Sorry. I have this morbid fear of metacharacters.\r\n", from)); } define bot_say_whatis(from, channel, args) { variable proc, pid; if(halt_evil_scum(args)) { thy_puny_attempt(from, channel); return; } % Uncomment below! return; () = system(sprintf("whatis %s > /tmp/bot.slirc.tmp", args)); proc = fopen("/tmp/bot.slirc.tmp", "r"); variable chk, buffer; irc_logf("[SLbot] - Running Whatis %s.", args, 1); do { chk = fgets(proc); if(chk == 0) { % irc_send_string(sprintf("NOTICE %s :[SLbot] - Whatis complete.\r\n", channel)); fclose(proc); } else if(chk < 0) { buffer = sprintf("NOTICE %s :[SLbot] - Whatis: error.\r\n", from); irc_send_string(buffer); irc_log("Whatis error..."); fclose(proc); } else { =buffer; irc_send_string(sprintf("NOTICE %s :[SLbot] - %s\r\n", from, buffer)); irc_say(sprintf("[SLbot] - %s", buffer), irc_nickname, from); } } while(chk > 0); irc_log("[SLbot] Whatis complete"); } define remove_ctrlh(buffer) { variable ret = NullString; variable i; for(i = 0; i < strlen(buffer); i++) { if(buffer[i] != '') if(buffer[i + 1] != '') ret = sprintf("%s%c", ret, buffer[i]); } return(ret); } define bot_say_synopsis(from, channel, args) { variable proc, pid; if(halt_evil_scum(args)) { thy_puny_attempt(from, channel); return; } return; () = system(sprintf("man %s > /tmp/bot.slirc.tmp", args)); proc = fopen("/tmp/bot.slirc.tmp", "r"); variable chk, buffer; irc_logf("[SLbot] - Running Synopsis %s.", args, 1); variable in_syn = 0; do { chk = fgets(proc); if(chk == 0) { % irc_send_string(sprintf("NOTICE %s :[SLbot] - Whatis complete.\r\n", channel)); fclose(proc); } else if(chk < 0) { buffer = sprintf("NOTICE %s :[SLbot] - Synopsis: error.\r\n", from); irc_send_string(buffer); irc_log("Whatis error..."); fclose(proc); } else { =buffer; if(in_syn) { if(in_syn < 4) { buffer = remove_ctrlh(buffer); irc_send_string(sprintf("NOTICE %s :[SLbot] - %s\r\n", from, buffer)); irc_say(sprintf("[SLbot] - %s", buffer), irc_nickname, from); in_syn++; } else { fclose(proc); chk = 0; } } else { if(buffer[0] == 'S') if(buffer[1] == '') if(buffer[3] == 'Y') in_syn = 1; } } } while(chk > 0); irc_log("[SLbot] Synopsis complete"); } define bot_say_seen(from, channel, args) { !if(strcmp(args, irc_nickname)) { variable buffer = sprintf("%s: I'm here, you fool!", from); irc_send_string(sprintf("PRIVMSG %s :%s\r\n", channel, buffer)); irc_say(buffer, irc_nickname, channel); } } define bot_say_when(from, channel, args) { !if(strcmp(args, irc_nickname)) { variable buffer = sprintf("%s: Want me to go away again so you can see it work?", from); irc_send_string(sprintf("PRIVMSG %s :%s\r\n", channel, buffer)); irc_say(buffer, irc_nickname, channel); } } define bot_say(from, channel, text) { variable command, args; command = substr(extract_first_word(text), 2, 9999); args = substr(text, strlen(command) + 3, 9999); variable function; function = sprintf("bot_say_%s", command); if(is_defined(function)) { from; channel; args; eval(function); } }