script manger conversion help
 

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

script manger conversion help

Started by rolipoli, 29 March, 2008, 18:18:00

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

rolipoli

Hello all!Please help me to convert this script for the new API.Here is the script:

-- modified Textfile manager to Scripts manager by Achiever 21/05/2007
-- added right click functions also
-- also change a bit of pattern matching
-- main chat block bug fixed thks to brock for report 24/05/2007

-- TEXtfile Manager
-- Made by Madman

-- Fixed: small path bug
-- Added: Syntax error to addscript
-- Changed: better pattern matching, thanks bastya
-- Revision by Mutor [ mod by achiever as 'Scripts Mgr.']

-- Commands
-- addscript NewFile [New script to add]
-- delscript DelFile
-- showtxt

local HUB = frmHub:GetHubName()
local sBot = "[ScriptManager]"

function Main()
	frmHub:RegBot(sBot)
end

local tCmds = {
	["addscript"] = function(curUser,data)
		local method = "added"
		local _,_,flag = data:lower():find("%b<> %p%a+ %S+ (%/o)")
		local _,_,file,script = data:find("%b<> %p%a+ (%S+) [%/o ]*(.+)")
		if file and script then
			--Add more codes to replace here, if needed
			local t = {
			[1] = {"\r\n","\n"},
			[2] = {"&amp;","&"},
			}
			for i, v in pairs(t) do
				script = script:gsub(v[1],v[2])
			end
			for code in script:gmatch("&#(%d+);") do
				code = tonumber(code)
				if code ~= 124 then
					script = script:gsub("%&%#"..code.."%;",string.char(code))
				end
			end
			file = file:gsub("%.lua","")..".lua"
			local r,e = os.rename(file,file)
			if r then
				if not flag then
					return curUser:SendPM(sBot,file.." exists, syntax: !addscript"..
					" filename script [filename /o script  to overwrite])")
				else
					method = "updated"
				end
			end
			local txt = io.open(file,"w+")
			txt:write(script)
			txt:flush()
			txt:close()
			curUser:SendPM(sBot,file.." "..method..", please reload scripts")
		else
			curUser:SendPM(sBot,"syntax: !addscript filename [script to add]")
		end
	end,
	["delscript"] = function(curUser,data)
		local s,e,file = data:find("%b<>%s+%S+%s+(%w+)%.*.*")
		if file then
			os.remove(file..".lua")
			curUser:SendPM(sBot,file.. ".lua removed, please reload scripts")
		end
	end,
	}
	
function ChatArrival(curUser,data)
	if curUser.iProfile == 0 then
		data = data:sub(1,-2)
		local s,e,cmd = data:find("%b<> %p(%S+)")
		if cmd and tCmds[cmd] then
			return tCmds[cmd](curUser,data),1
		end
	end
end
ToArrival = ChatArrival

function OpConnected(user)
	if user.iProfile == 0 then
		user:SendData("$UserCommand 1 3 "..HUB.."\\Script Commands\\"..sBot.."\\Add Script$<%[mynick]> +addscript %[line:Filename (filename -o  to overwrite))] %[line:Script body]&#124;")
		user:SendData("$UserCommand 1 3 "..HUB.."\\Script Commands\\"..sBot.."\\Delete Script$<%[mynick]> +delscript %[line:Filename]&#124;")
		user:SendData("$UserCommand 1 3 "..HUB.."\\Script Commands\\"..sBot.."\\Restart Script$<%[mynick]> +restartscript %[line:Filename]&#124;")
		user:SendData("$UserCommand 1 3 "..HUB.."\\Script Commands\\"..sBot.."\\Start Script$<%[mynick]> +startscript %[line:Filename]&#124;")
		user:SendData("$UserCommand 1 3 "..HUB.."\\Script Commands\\"..sBot.."\\Stop Script$<%[mynick]> +stopscript %[line:Filename]&#124;")
		--user:SendData("$UserCommand 1 3 "..HUB.."\\Script Commands\\"..sBot.."\\Restart All Scripts$ <%[mynick]> +restartscripts&#124;")
		user:SendData("$UserCommand 1 3 "..HUB.."\\Script Commands\\"..sBot.."\\Get Scripts$<%[mynick]> +getscripts&#124;")
	end
end

I tried to convert it,but in the converted version didn't appear the right click menu,and the "delscript" command didn't work.I attached the converted version to.Please help!Sorry for my bad english.
Thanks in advance. rolipoli

rolipoli

Thank you Sir for the quick answer :) ,but unfortunately there are some problems :
1.when i give the "restartscripts"from the rightclickmenu its disconnect me from the hub.
2.on the "addscript"command which i give in private to the bot the script it stops and the error message is:Syntax scriptmanager.lua:60: bad argument count to 'SendPmToUser'(3 expected,got 4).
3.and these error message appear: Syntax scriptmanager.lua:69: bad argument count to 'SendPmToUser'(3 expected,got 4)
on the "delscript" commnad from the right clicker, and in private, if i use the command nothing happend
What is the cause of this errors,and can be fixed it? ???

Tw?sT?d-d?v

#2
having a quick look at script shouldnt Core:  be  Core.  ?
And the restartallscript in the first script is stoped/commeted   
user:SendData("$UserCommand 1 3 "..HUB.."\\Script Commands\\"..sBot.."\\Stop Script$<%[mynick]> +stopscript %[line:Filename]&#124;")
--user:SendData("$UserCommand 1 3 "..HUB.."\\Script Commands\\"..sBot.."\\Restart All Scripts$ <%[mynick]> +restartscripts&#124;")
user:SendData("$UserCommand 1 3 "..HUB.."\\Script Commands\\"..sBot.."\\Get Scripts$<%[mynick]> +getscripts&#124;")

That might be cause it didnt work b4  ??

Madman

Yes. Core: should be Core.
Change that and it should work.
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

rolipoli

#4
Quote from: Tw?sT?d-d?v?l on 30 March, 2008, 14:25:47
having a quick look at script shouldnt Core:  be  Core.  ?
And the restartallscript in the first script is stoped/commeted   
user:SendData("$UserCommand 1 3 "..HUB.."\\Script Commands\\"..sBot.."\\Stop Script$<%[mynick]> +stopscript %[line:Filename]&#124;")
--user:SendData("$UserCommand 1 3 "..HUB.."\\Script Commands\\"..sBot.."\\Restart All Scripts$ <%[mynick]> +restartscripts&#124;")
user:SendData("$UserCommand 1 3 "..HUB.."\\Script Commands\\"..sBot.."\\Get Scripts$<%[mynick]> +getscripts&#124;")

That might be cause it didnt work b4  ??
Hello all!It was my mistake to forgot to mention, in the first(unconverted) script the"restartscripts" command was commented/stoped by me because,it disconnect me too,and i decide to use the inbuild ptx commands instead of that.
Mutor!In the script revised by you the "delscript" command still Not working, ??? I tried to give in pm to the bot,in the main,and in the rightclicker but whitout any results ,the rest of the commands are working fine now.

rolipoli

Quote from: Mutor on 31 March, 2008, 22:33:48
Sure it is, use simple filename without spaces.
File extension is not required.
I'm so stupid :D because i forgot to use just the filename without extensions in command.You have perfectly right ,now the script works fine thanks to You!
Thanks again Mutor!
rolipoli

SMF spam blocked by CleanTalk