% % CTCP is scripts... % ircII et al have long since moved away from this. % But SLang is fast enough that it shouldn't matter. % So... % variable ctcp_magic_char = ''; define ctcp_send_reply(to, command, text) { variable s = command; if(text != NullString) s = s + " " + text; irc_send_string(sprintf("NOTICE %s :%s\r\n", to, s)); } autoload("cmd_CTCP_VERSION", "ctcp_cmd.sl"); autoload("cmd_CTCP_TIME", "ctcp_cmd.sl"); autoload("cmd_CTCP_SOURCE", "ctcp_cmd.sl"); autoload("cmd_CTCP_AUTH", "ctcp_cmd.sl"); %autoload("cmd_CTCP_DCC", "dcc.sl"); () = evalfile("dcc.sl"); define cmd_CTCP_ACTION(from, text, isnotice) { variable nick; (nick,) = v_split(from,"!"); irc_action(text, nick, Rpms[2]); % irc_info(sprintf("Rpms[2]=%s",Rpms[2]),Rpms[2]); % debug irc_nick_action(nick,"ctcp action"); } define cmd_CTCP_PING(from, text, isnotice) { if(isnotice) irc_Inff("PONG from %s", extract_nick(from)); else irc_send_string(sprintf("NOTICE %s :PING %s\r\n", extract_nick(from), text)); } define ctcp_check(isnotice) { variable trgt = Rpms[2]; variable text = Rpms[3]; if(text[0] != ctcp_magic_char) return 0; variable l = strlen(text); if(text[l - 1] != ctcp_magic_char) { irc_Inff("[CTCP] First char was ^A, but last was %c?", text[l - 1]); return 0; } text = substr(text, 2, l - 2); % without the ^A's variable command,params,function; (command,params) = v_split(text," "); function = "cmd_CTCP_" + strup(command); if(strspn(trgt,"#&")) { % target is channel: ignore unless it's an ACTION if(function != "cmd_CTCP_ACTION") return 0; } if(is_defined(function)) { variable from = Rpms[0]; % if(strcmp(command, "ACTION")) % irc_Inff("[CTCP] Running %s(\"%s\", \"%s\", %d)", % function, % from, % params, % isnotice) from; params; isnotice; eval(function); return 1; } irc_Inff("[CTCP] Couldn't run command %s", command); return 0; }