hi,
i have just modified TEXtfile Manager Made by Madman to script file manager and made some changes
plzz check this out :)
script updated 24/5/2007
-- 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 basta
-- Commands
-- addscript NewFile [New script to add]
-- delscript DelFile
-- showtxt
HUB = frmHub:GetHubName()
sBot = "Scripts manager"
--[[function Main()
frmHub:RegBot(sBot)
end]]--
function ChatArrival(curUser,data)
local data = string.sub(data,1,-2)
local s,e,prefix,cmd = data:find("%b<>%s+(%p)(%S+)")
if curUser.iProfile == 0 then
if cmd then
tCmds = {
["addscript"] = function(curUser,data)
local s,e,file,script = string.find(data,"%b<>%s+%S+%s+(%S+)%s+%[(.+)%]")
if file and script then
local txt = io.open(frmHub:GetPtokaXLocation().."/scripts/" ..file.. ".lua","w+")
txt:write(script)
txt:close()
curUser:SendPM(sBot,file.. ".lua added, please reload scripts")
else
curUser:SendPM(sBot,"syntax: !addscript filename [script to add]")
end
end,
["delscript"] = function(curUser,data)
local s,e,file = string.find(data,"%b<>%s+%S+%s+(%S+)")
if file then
os.remove(file..".lua")
curUser:SendPM(sBot,file.. ".lua removed, please reload scripts")
end
end,
}
if tCmds[cmd] then
return tCmds[cmd](curUser,data),1
end
else
curUser:SendData(frmHub:GetHubBotName(),"Ur profile is not allowed to use this command")
end
end
end
function OpConnected(user)
if user.iProfile == 0 then
user:SendData("$UserCommand 1 3 "..HUB.."\\Hub Commands\\"..sBot.."\\Add script$<%[mynick]> +addscript %[line:Filename] [ %[line:Script body] ] |")
user:SendData("$UserCommand 1 3 "..HUB.."\\Hub Commands\\"..sBot.."\\Delete script$<%[mynick]> +delscript %[line:Filename]|")
user:SendData("$UserCommand 1 3 "..HUB.."\\Hub Commands\\"..sBot.."\\restart script$<%[mynick]> +restartscript %[line:Filename]|")
user:SendData("$UserCommand 1 3 "..HUB.."\\Hub Commands\\"..sBot.."\\Start script$<%[mynick]> +startscript %[line:Filename]|")
user:SendData("$UserCommand 1 3 "..HUB.."\\Hub Commands\\"..sBot.."\\Stop script$<%[mynick]> +stopscript %[line:Filename]|")
user:SendData("$UserCommand 1 3 "..HUB.."\\Hub Commands\\"..sBot.."\\Restart all scripts$<%[mynick]> +restartscripts|")
user:SendData("$UserCommand 1 3 "..HUB.."\\Hub Commands\\"..sBot.."\\Get scripts$<%[mynick]> +getscripts|")
end
end
hope it was not already done :P
achiever
nice qwork but can u add the option of edit script
Quote from: Yahoo on 21 May, 2007, 10:33:08
nice qwork but can u add the option of edit script
Wats tht??
edit script will allow to make the changes in the current script which is already used in the hub
u can just use the add script command, b'coz thks to Madman its in overwrite mode so the old file will be replaced by new 1.
bug found and fixed.
script updated.
This script sometimes says this in mainchat:
[04:54:20] <Hub-Security> Ur profile is not allowed to use this command
Though I do nothing during this moment.
What's the reason?
Hello Mutor,
in ur script I am not able to add any of my scripts, I always get this error
Quote
[14:23] Private message from Scripts-Manager: <Scripts-Manager> syntax: !addscript filename [script to add]
Achievers script is running gd but it keeps a line space after each line in the script wich is added...
Thx Mutor,
It works gr8 ;)
Congo!!!!
hi,
mutor i got 1 bug in this script
when a script with right clicker is added thru this script it shows the right click in written form in main chat and not in right click.
thks,
achiever
Quote from: achiever on 19 June, 2007, 20:07:13
hi,
mutor i got 1 bug in this script
when a script with right clicker is added thru this script it shows the right click in written form in main chat and not in right click.
thks,
achiever
DC++ converts the line-ending HTML entities to endpipes. IMO there is no way to get past this.
well then most of the scripts cant be added or at least right clicks cant be added thru this script.
thanks,
achiever
Quote from: achiever on 19 June, 2007, 20:59:38
well then most of the scripts cant be added or at least right clicks cant be added thru this script.
Let me think it over... you add it to DC++ then it passes it to PtokaX. No, cannot be added. Although we can file a feature request in the DC++ tracker - if there were any. :-)
can we get to it in other way if not directly like the script 1st saves it as text file and then renames it as .lua file.
lol this should work, but should be boring long way, isnt it?
I think I have a solution. You need to base64-encode the data and the script can decode it serverside. I can add such a feature. For encoding, here is an online encoder (http://www.motobit.com/util/base64-decoder-encoder.asp).
I'll come up with a modded script soon.
Here you go.
I had to relicense it, see the notes.
-- 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
-- Added base64 decoding of text by bastya_elvtars
-- This way, DC++ will not fuck up your scripts.
-- !!! IMPORTANT: !!!
-- You _have_ _to_ base64-encode the required file.
-- This can be achieved by using an online base64-encoder:
-- http://makcoder.sourceforge.net/demo/base64.php
-- LEGAL STUFF:
-- As the base64 code is licensed under the GNU LGPL,
-- the full script has to be relicensed under it.
-- Since the script is public domain, this should mean
-- no problem, although I do not like viral licenses.
-- Here is the LGPL:
-- http://www.gnu.org/licenses/lgpl.html
-- If the original authors disagree, the base64 code needs
-- to be removed or replaced to one under a more permissive
-- license.
-- Oh, and please do not blame me, I just obeyed the rules.
local HUB = frmHub:GetHubName()
local sBot = "[Scripts-Manager]"
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 ]*(.+)")
--SendToAll("Flag: "..flag)
if file and script then
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
else
SendToAll(sBot,e)
end
local txt = io.open(file,"w+")
txt:write(decode(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]|")
user:SendData("$UserCommand 1 3 "..HUB.."\\Script Commands\\"..sBot.."\\Delete Script$<%[mynick]> +delscript %[line:Filename]|")
user:SendData("$UserCommand 1 3 "..HUB.."\\Script Commands\\"..sBot.."\\Restart Script$<%[mynick]> +restartscript %[line:Filename]|")
user:SendData("$UserCommand 1 3 "..HUB.."\\Script Commands\\"..sBot.."\\Start Script$<%[mynick]> +startscript %[line:Filename]|")
user:SendData("$UserCommand 1 3 "..HUB.."\\Script Commands\\"..sBot.."\\Stop Script$<%[mynick]> +stopscript %[line:Filename]|")
user:SendData("$UserCommand 1 3 "..HUB.."\\Script Commands\\"..sBot.."\\Restart All Scripts$ <%[mynick]> +restartscripts|")
user:SendData("$UserCommand 1 3 "..HUB.."\\Script Commands\\"..sBot.."\\Get Scripts$<%[mynick]> +getscripts|")
end
end
-- improved lua base64 codec (c) 2006-2007 by Alex Kloss
-- compatible with lua 5.1
-- http://www.it-rfc.de
-- licensed under the terms of the LGPL2
-- encryption table
local base64chars = {[0]='A',[1]='B',[2]='C',[3]='D',[4]='E',[5]='F',[6]='G',[7]='H',[8]='I',[9]='J',[10]='K',[11]='L',[12]='M',[13]='N',[14]='O',[15]='P',[16]='Q',
[17]='R',[18]='S',[19]='T',[20]='U',[21]='V',[22]='W',[23]='X',[24]='Y',[25]='Z',[26]='a',[27]='b',[28]='c',[29]='d',[30]='e',[31]='f',[32]='g',
[33]='h',[34]='i',[35]='j',[36]='k',[37]='l',[38]='m',[39]='n',[40]='o',[41]='p',[42]='q',[43]='r',[44]='s',[45]='t',[46]='u',[47]='v',[48]='w',
[49]='x',[50]='y',[51]='z',[52]='0',[53]='1',[54]='2',[55]='3',[56]='4',[57]='5',[58]='6',[59]='7',[60]='8',[61]='9',[62]='-',[63]='_'}
-- function encode
-- encodes input string to base64.
function encode(data)
local bytes = {}
local result = ""
for spos=0,string.len(data)-1,3 do
for byte=1,3 do bytes[byte] = string.byte(string.sub(data,(spos+byte))) or 0 end
result = string.format('%s%s%s%s%s',result,base64chars[math.floor(bytes[1]/4)] or "=",
base64chars[(bytes[1] % 4) * 16 + math.floor(bytes[2] / 16)] or "=",
({[true]=base64chars[(bytes[2] % 16) * 4 + math.floor(bytes[3] / 64)] or "=",[false]="="})[(string.len(data)-spos) > 1],
({[true]=base64chars[(bytes[3] % 64)] or "=",[false]="="})[(string.len(data)-spos) > 2])
end
return result
end
-- decryption table
local base64bytes = {['A']=0,['B']=1,['C']=2,['D']=3,['E']=4,['F']=5,['G']=6,['H']=7,['I']=8,['J']=9,['K']=10,['L']=11,['M']=12,['N']=13,['O']=14,['P']=15,['Q']=16,
['R']=17,['S']=18,['T']=19,['U']=20,['V']=21,['W']=22,['X']=23,['Y']=24,['Z']=25,['a']=26,['b']=27,['c']=28,['d']=29,['e']=30,['f']=31,['g']=32,
['h']=33,['i']=34,['j']=35,['k']=36,['l']=37,['m']=38,['n']=39,['o']=40,['p']=41,['q']=42,['r']=43,['s']=44,['t']=45,['u']=46,['v']=47,['w']=48,
['x']=49,['y']=50,['z']=51,['0']=52,['1']=53,['2']=54,['3']=55,['4']=56,['5']=57,['6']=58,['7']=59,['8']=60,['9']=61,['-']=62,['_']=63,['=']=nil}
-- function decode
-- decode base64 input to string
function decode(data)
local chars = {}
local result=""
for dpos=0,string.len(data)-1,4 do
for char=1,4 do chars[char] = base64bytes[(string.sub(data,(dpos+char),(dpos+char)) or "=")] end
result = string.format('%s%s%s%s',result,string.char(chars[1]*4 + math.floor(chars[2]/16)),
({[true]=string.char(((chars[2] or 0) % 16)*16 + math.floor((chars[3] or 0)/4)),[false]=""})[chars[3] ~= nil],
({[true]=string.char(((chars[3] or 0)%4) * 64 + (chars[4] or 0)),[false]=""})[chars[4] ~= nil])
end
return result
end
Quote from: Mutor on 20 June, 2007, 02:22:41
We should be able to gsub the ascii code back in before saving to file.
The pattern will need to assure it is indeed a UC, otherwise I don't see a problem.
I am not sure about DC++'s handling of such things. BTW it is pure idiotism from them to parse chatlines containing HTML entities.
Quote from: Mutor on 20 June, 2007, 02:37:48
I suspect we will only find this problem with clients that support text formatting.
No, because we are talking about the & #124; thing.
And is DC++ supposed to do this entity - pipe conversion on OUTGOING protocol commands?
Did some more testing and I found that this does not occur in CZDC++. Anyway the script I posted should help with this issue and also eliminates a lot of potential issues. There is more hassle, but hey, replacing scripts is not something that you do 23 times a day.
got 1 error
[09:25] Syntax ...oads\0.3.5.2[Fusion Hub]\scripts\scripts maneger.lua:149: attempt to perform arithmetic on field '?' (a nil value)
okk
i got it i did not encode it b4.
bastya i think there is a problem with the encoder thing as when the script decodes it it adds / before every "
plzz check.
achiever
wow the script is working gr8
good work mutor thanks,
achiever.
umm.. if any script with 1st line as comment is added then -- is deleted and the scripts gives error(i mean the script added).
plzz check.
Quote from: achiever on 20 June, 2007, 07:55:17
umm.. if any script with 1st line as comment is added then -- is deleted and the scripts gives error(i mean the script added).
plzz check.
Yes, tht's y u have to copy only the main script part.
but adding just the main part of the script will delete all the notes, i dont think its good to be done, is it?
http://www.motobit.com/util/base64-decoder-encoder.asp
That online encoder in the comments is flawed. This one works.
mutor the overwrite part seems not to be working it keeps on giving the same syntax thing even with /o as overwite
but new script is added without prob and works good.
bastya ur scripts giving error
[20:33] Syntax E:\Downloads\0.3.5.2[Fusion Hub]\scripts\testing.lua:149: attempt to perform arithmetic on field '?' (a nil value) on posting the enoded data from new link
working good now,
thanks.