Command Spy
 

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

Command Spy

Started by antd, 14 October, 2006, 17:02:13

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

antd

Hello, I have to log everything in my hub as I use the hub in an organisation. Logs are required to be kept for 12months.

I have use the script commandspy1.0 but I don't know how to use it. I would be grateful if someone could tell me how to use the command.

Thank you.

The script I use:

--[[

	Command Spy 1.0 by jiten (3/18/2006)

]]--

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+(%p.*)|$")
	-- 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+(%p.*)|$")
	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

Rincewind

The script you posted is in Lua4. To use it with a modern PtokaX it will need converting to Lua 5.03 or Lua 5.1.1.

Not sure you'll have much luck getting someone here to convert it

antd

Thank you very much (again). Some kind person couldn't help me out with this?

6Marilyn6Manson6

Quote from: Rincewind on 14 October, 2006, 19:13:29
The script you posted is in Lua4. To use it with a modern PtokaX it will need converting to Lua 5.03 or Lua 5.1.1.

Not sure you'll have much luck getting someone here to convert it

This is false, because jiten not have made this script in Lua4, you can see:

ChatArrival = function(user,data)


or

for i,v in pairs(Settings.tSpy) do


these parts of script exist only on LUA5,so that's impossible this script can be on lua4, and you can see also this:

Command Spy 1.0 by jiten (3/18/2006)

antd

Quote from: 6Marilyn6Manson6 on 14 October, 2006, 19:42:56
This is false, because jiten not have made this script in Lua4, you can see:

ChatArrival = function(user,data)


or

for i,v in pairs(Settings.tSpy) do


these parts of script exist only on LUA5,so that's impossible this script can be on lua4, and you can see also this:

Command Spy 1.0 by jiten (3/18/2006)


It is because I posted a similar thread at another forum. He probably just copied and pasted his response assuming I posted the same topic.

6Marilyn6Manson6

Quote from: antd on 14 October, 2006, 19:51:46
It is because I posted a similar thread at another forum. He probably just copied and pasted his response assuming I posted the same topic.

I don't understand, ....can you tell me better your problem about this script?

Psycho_Chihuahua

Quote from: antd on 14 October, 2006, 17:02:13
Hello, I have to log everything in my hub as I use the hub in an organisation. Logs are required to be kept for 12months.

I have use the script commandspy1.0 but I don't know how to use it. I would be grateful if someone could tell me how to use the command.

Thank you.



Actually the script is simple to use

While the hub is running and the script is active do the following:

type  !cmdspy <on/off> to turn its function <on/off> for you iE. !cmdspy on  for activating


after you have done this you will get PM Messages for all Commands used by the Users in that hub in this type of fashion:
[20:11:41] <-SanitariuM-> 10/14/06 20:11:41 - Master Psycho_Chihuahua used command: !goinfo
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

antd

Quote from: 6Marilyn6Manson6 on 14 October, 2006, 20:01:41
I don't understand, ....can you tell me better your problem about this script?
I made a topic at another forum. Rincewind posted about the script being version 4 because on my -other- post the script was version 4. He just copied and pasted his response.

My problem is that I don't know how to use the script. It seems the above poster has solved my problem. Thank you all for posting.

6Marilyn6Manson6

Quote from: antd on 14 October, 2006, 20:20:37
I made a topic at another forum. Rincewind posted about the script being version 4 because on my -other- post the script was version 4. He just copied and pasted his response.

My problem is that I don't know how to use the script. It seems the above poster has solved my problem. Thank you all for posting.

This script have two command :  !cmdspy on   and   !cmdspy off  , or you can see Psycho_Chihuahua  ;D

Rincewind

Quite correct in what you assumed I did. I only took a cursory glance here and it seemed to be the same post as on the other board. I apologise for that and will take the time to fully read posts before replying again  :-X

6Marilyn6Manson6

Quote from: Rincewind on 15 October, 2006, 00:05:15
Quite correct in what you assumed I did. I only took a cursory glance here and it seemed to be the same post as on the other board. I apologise for that and will take the time to fully read posts before replying again  :-X

No Problem Guy  ;D

Mozzilla?

#11
Here it is converted to Lua 5.1

Hope it helps

--[[ 
 
	Command Spy 1.1 LUA 5.1 
	 
	by jiten (3/18/2006) 
 
	Changelog: 
	 
	- Changed: Script will only search for ! and + 
	- Fixed: Missing () in GetProfileName 
	- Added full profile table rather than just master and netfounder - Toobster?? - 16TH September 2006 
 
]]-- 
 
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, -- Masters  
				[1] = 1, -- Operators  
				[2] = 0, -- Vips  
				[3] = 0, -- Regs  
				[4] = 1, -- Moderator  
				[5] = 1, -- NetFounder  
				[6] = 1, --Owner 
				[-1] = 0, -- Users  
			}, 
		}, 
	} 
	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

antd


SMF spam blocked by CleanTalk