-- vim:ts=4:sw=4:noet -- -- spy snooper bot for PtokaX (tested on 0.3.2.3 Test2B) -- by Sedulus 20030201, no rights reserved -- -- this is a standalone snooper bot -- doesn't register itself as a regular bot, -- but sends a $Hello to the users who may use it. -- (refresh user list if you don't see it) -- -- usage: -- start starts snooping on -- stop stops snooping on (.*)%|$" ) if ret and to == bot_name and from == curUser.sName then --// help if msg == "help" then curUser:SendPM( bot_name, "snooper bot, commands:\r\n".. "start \r\n".. "stop \r\n".. "list" ) --// start elseif strsub( msg, 1, 5 ) == "start" then local nick = strsub( msg, 7 ) local obj = GetItemByName( nick ) if obj then if obj.bOperator and not is( bAllowOpSnoop ) then curUser:SendPM( bot_name, "refuses to snoop on operators" ) elseif nick == curUser.sName or nick == bot_name then curUser:SendPM( bot_name, "can't snoop on yourself or me" ) elseif snoopTable[curUser.sName][nick] then curUser:SendPM( bot_name, "on the job already" ) else snoopTable[curUser.sName][nick] = 1 curUser:SendPM( bot_name, "START snooping on "..nick ) end else curUser:SendPM( bot_name, nick.." is not online" ) end --// stop elseif strsub( msg, 1, 4 ) == "stop" then local nick = strsub( msg, 6 ) if snoopTable[curUser.sName][nick] then snoopTable[curUser.sName][nick] = nil curUser:SendPM( bot_name, "STOPPED snooping on "..nick ) else curUser:SendPM( bot_name, "wasn't snooping on "..nick ) end --// list elseif msg == "list" then local str = "snoop list:" for snooper, suspects in snoopTable do str = str.."\r\n"..snooper.." snooping on:" for suspect, e in suspects do str = str.."\r\n\t"..suspect end end curUser:SendPM( bot_name, str ) end end end --// snoop local ret,c,to = strfind( data, "^$To: ([^ ]+) " ) for snooper, suspects in snoopTable do for suspect, e in suspects do if suspect == curUser.sName then if ( strfind( data, "^<" ) and is( bSnoopChat ) ) or ( strfind( data, "^$To: " ) and is( bSnoopPM ) ) or ( strfind( data, "^$Search " ) and is( bSnoopSearch ) ) or ( strfind( data, "^$SR " ) and is( bSnoopSR ) ) or ( strfind( data, "^$ConnectToMe " ) and is( bSnoopConnect ) ) or ( strfind( data, "^$RevConnectToMe " ) and is( bSnoopConnect ) ) then SendPmToNick( snooper, bot_name, "<< data from "..suspect.." >> "..data ) end elseif ret and suspect == to and is( bSnoopPM ) then SendPmToNick( snooper, bot_name, "<< data to "..suspect.." >> "..data ) end end end end function clearSuspectFromList( name ) for snooper, suspects in snoopTable do for suspect, e in suspects do if suspect == name then snoopTable[snooper][suspect] = nil SendPmToNick( snooper, bot_name, "STOPPED snooping on "..name.." (went offline)" ) end end end end