Standalone Cmdspy
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

Standalone Cmdspy

Started by Mikey, 18 March, 2006, 05:21:22

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Mikey

I need a standalone cmdspy for LUA 5 anyway to have one made?
Mikey

**Friends Unlimited Network**
    Network Founder

Herodes

#1
totaly untested...

-- CmdSpy v0.1
-- by Herodes 18/3/2006
--requested by Mikey

-- Currently ppl will need to edit the following table to add ppl that will listen to the cmds.. 
-- sry about this lil time left :)
tListeners = {
	["Herodes"] = "pm"
,
	["somenick"] = "main"
,
}

function Main()
	frmHub:RegBot( "CmdSpy" )
end

function ChatArrival( user, data )
	ParseSpyCmd( user, string.sub( data, 1, -2 ) )
end

function ToArrival( user, data )
	ParseSpyCmd( user, string.sub( data, 1, -2 ), true )
end

function ParseSpyCmd( user, data, how )
	if string.find( data, "%b<>%s*[%!%+%-%.]%S+") then
		if how then
			local s,e, to, chat = string.find( data, "%$To:%s(%S+)%sFrom:%s%S+%s%$(.-)$")
			data = chat
		end
		for i,v in pairs( tListeners) do
			local usr = GetItemByName(i) 
			if usr then
				if v == "pm" then
					usr:SendPM( "CmdSpy", "- <"..to.."> "..data )
				elseif v == "main" then
					usr:SendData( "CmdSpy", "- <"..to.."> "..data )
				end
			end
		end
	end
end

TiMeTrAVelleR

do i need to add commands in script  because when trying a command  nothing shows (added ofcourse my nick there )

greetz TT

jiten

#3
Here goes my attempt:

--[[

	Command Spy 1.1 LUA 5.1
	
	by jiten (3/18/2006)

	Changelog:
	
	- Changed: Script will only search for ! and + (thanks TT)
	- Fixed: Missing () in GetProfileName

]]--

Settings = {
	sBot = frmHub:GetHubBotName(),
	fSpy = "Notify.tbl",
	tSpy = {}
}

Main = function()
	if loadfile(Settings.fSpy) then dofile(Settings.fSpy) end
end

ChatArrival = function(user,data)
	local s,e,msg = string.find(data,"^%b<>%s+([%!%+].*)|$")
	-- Command Spy related
	if msg then return ParseCommands(user,msg) end
end

ToArrival = function(user,data)
	local s,e,to,msg = string.find(data, "^%$To:%s+(%S+)%s+From:%s+%S+%s-%$%b<>%s+([%!%+].*)|$")
	if to == Settings.sBot and msg then return ParseCommands(user, msg) end
end

ParseCommands = function(user, data)
	for i,v in pairs(Settings.tSpy) do
		local nick = GetItemByName(i)
		if nick then
			nick:SendPM(Settings.sBot,os.date("%x %X").." - "..(GetProfileName(GetUserProfile(user.sName)) or "User").." "..user.sName.." used command: "..data)
		end
	end
	local s,e,cmd = string.find(data,"^%p(%S+)")
	tCmds = { 
		-- Start: Command Spy Command
		["cmdspy"] = {
			tFunc = function(user,data)
				local s,e,flag = string.find(data,"%S+%s+(%S+)")
				if flag then
					flag = string.lower(flag)
					local tTable = {
						["on"] = function()
							if Settings.tSpy[user.sName] then
								user:SendData(Settings.sBot,"*** Command Spy is already enabled for you!")
							else
								Settings.tSpy[user.sName] = 1
								user:SendData(Settings.sBot,"*** Command Spy is now enabled for you.")
							end
						end,
						["off"] = function()
							if Settings.tSpy[user.sName] then
								Settings.tSpy[user.sName] = nil
								user:SendData(Settings.sBot,"*** Command Spy is now disabled for you!")
							else
								user:SendData(Settings.sBot,"*** Command Spy is already disabled for you!.")
							end
						end
					}
					if tTable[flag] then
						tTable[flag]()
					else
						user:SendData(Settings.sBot,"*** Usage: !cmdspy <on/off>")
					end
				end
			end,
			tLevels = {
				[0] = 1,
				[5] = 1,
			},
		},
	}
	if cmd and tCmds[string.lower(cmd)] then
		cmd = string.lower(cmd)
		if tCmds[cmd].tLevels[user.iProfile] then
			return tCmds[cmd].tFunc(user,data), 1
		else
			return user:SendData(Settings.sBot,"*** Error: You are not allowed to use this command."), 1
		end
	end
end

OnExit = function()
	local hFile = io.open(Settings.fSpy,"w+") Serialize(Settings.tSpy,"Settings.tSpy",hFile); hFile:close()
end

Serialize = function(tTable,sTableName,hFile,sTab)
	sTab = sTab or "";
	hFile:write(sTab..sTableName.." = {\n");
	for key,value in pairs(tTable) do
		if (type(value) ~= "function") then
			local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key);
			if(type(value) == "table") then
				Serialize(value,sKey,hFile,sTab.."\t");
			else
				local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value);
				hFile:write(sTab.."\t"..sKey.." = "..sValue);
			end
			hFile:write(",\n");
		end
	end
	hFile:write(sTab.."}");
end

6Marilyn6Manson6

I love this script but I don't understand. In topic   

http://forum.ptokax.org/index.php?topic=3740.0


most user ARE CONTRARY at PM Spy.. why now Herodes and jiten have made this script?

Herodes

#5
Quote from: 6Marilyn6Manson6 on 18 March, 2006, 13:42:29
I love this script but I don't understand. In topic   

http://forum.ptokax.org/index.php?topic=3740.0


most user ARE CONTRARY at PM Spy.. why now Herodes and jiten have made this script?
cause  it is not a pm spy :) it is spying on !commands hihi

Quote from: T?M??r?V?ll?R on 18 March, 2006, 13:20:47
do i need to add commands in script  because when trying a command  nothing shows (added ofcourse my nick there )

greetz TT
sry .. as i said in the comments no time left when at work... jiten seems that did a gr8 job though :)

6Marilyn6Manson6

LooooooooooooL ok now is ok :P

TiMeTrAVelleR

Oki works  but make sure it is first script   when its as last it dosent work :)

Thanks    TT

TiMeTrAVelleR

jiten youre version also reads the smilyes users use and the winamp now playing thing  lol

greetzz  TT

jiten

Quote from: T?M??r?V?ll?R on 18 March, 2006, 16:20:03
jiten youre version also reads the smilyes users use and the winamp now playing thing? lol

greetzz? TT

First post updated with that change :)

SMF spam blocked by CleanTalk