% % Some of the less often used CTCP commands live here. % They need to be autoloaded from ctcp.sl % define cmd_CTCP_VERSION(from, text, is_notice) { variable nick,v; nick = extract_nick(from); if(is_notice) { irc_Inff("[CTCP] %s is running %s", nick, text); } else { irc_Inff("[CTCP] %s requested VERSION", from); v = sprintf("%s:%s:Unknown:http://www.megsinet.com/~stabro/slirc.html", ProgName,ProgVersion); ctcp_send_reply(nick, "VERSION", v); } } define cmd_CTCP_TIME(from, text, is_notice) { variable nick; nick = extract_nick(from); if(is_notice) { irc_Inff("[CTCP] %s localtime is %s", nick, text); } else { irc_Inff("[CTCP] %s requested TIME", from); ctcp_send_reply(nick, "TIME", time()); } } define cmd_CTCP_SOURCE(from, text, is_notice) { variable nick; nick = extract_nick(from); if(is_notice) { irc_Inff("[CTCP] %s SOURCE at %s", nick, text); } else { irc_Inff("[CTCP] %s requested SOURCE", from); ctcp_send_reply(nick, "SOURCE", "http://www.megsinet.com/~stabro/slirc.html"); } } % The following is experimental, and no bots support it. % Sorry... variable irc_bot_passwd = "SilverFish"; define cmd_CTCP_AUTH(from, text, is_notice) { variable subcommand, data, nick, proc, chk; nick = extract_nick(from); (subcommand, data) = v_split(text, " "); if(subcommand == "PLAINTEXT") { irc_Inff("[CTCP/AUTH] %s sent AUTH PLAINTEXT", from); irc_Inff("[CTCP/AUTH] (We ignored that one...)"); } if(subcommand == "MD5-CHALLENGE") { () = system(sprintf("md5sum --string=\"%s%s\" > /tmp/slirc.%s.%s", data, irc_bot_passwd, irc_nickname, irc_servername)); irc_Inff("[CTCP/AUTH] %s sent AUTH MD5-CHALLENGE \"%s\"", from, data); proc = vf_open(sprintf("/tmp/slirc.%s.%s", irc_nickname, irc_servername), O_RDONLY, 0600); irc_Inff("[CTCP/AUTH] Opened file"); () = set_rmode(proc, '\n', 512); do { chk = vf_read(proc, &data); irc_Inff("[CTCP/AUTH] Read %d bytes.", chk); if(chk < 0) { if(vf_error(proc)) irc_Inff("[CTCP/AUTH] Error reading output of md5sum"); else if(vf_eof(proc)) vf_close(proc); } else if(chk > 0) { irc_Inff("[CTCP/AUTH] Got data :- %s", data); data = extract_first_word(data); ctcp_send_reply(nick, "MD5-RESPONSE", data); irc_Inff("[CTCP/AUTH] Responded with \"%s\"", data); } } while(chk >= 0); } irc_Inff("[CTCP/AUTH] Clear out"); }