PtokaX forum

Archive => Archived 5.0 boards => Finished Scripts => Topic started by: NightLitch on 23 April, 2005, 18:50:44

Title: *** Convert YnHub Register to PtokaX
Post by: NightLitch on 23 April, 2005, 18:50:44
Here is a script that converts YnHub registry to PtokaX:

--//----------------------------------------------------------------------------------------------->>
--//-- Convert YnHub Register to PtokaX
--//-- Created by NightLitch 2005-04-23
--//-- To start the convert use specified command bellow in mainchat
--//-- Usage: #convert
--//----------------------------------------------------------------------------------------------->>

--//-- Specify the YnHub Profiles to work with your PtokaX Profiles
--//-- YnHub Profiles   =   PtokaX Profiles
ProfileRegistry = {
["Owner"] = "Master",
["OP"] = "Operator",
["VIP"] = "VIP",
["Registered"] = "Reg",
}

--//-- Specify the Path to YnHubs Register File
FileName = "filename_here.xml"

--//----------------------------------------------------------------------------------------------->>
--//-- Don't Edit
--//----------------------------------------------------------------------------------------------->>
function ConvertYnHubRegisterFile(filename)
    local curTable = {}
    local curNick = ""
    local Count = 0
    local file = io.open(filename, "r")
    for line in file:lines() do
        local s,e,col,value = string.find(line, "<(%S+)>(%S+)<")
        if col and value then
            if col == "Nick" and Count == 0 then
                curNick = value
                curTable[value] = {["Pass"] = "", ["Profile"] = ""}
                Count = Count + 1
            elseif col == "Pass" and Count == 1 then
                curTable[curNick].Pass = value
                Count = Count + 1
            elseif col == "Profile" and Count == 2 then
                curTable[curNick].Profile = value
                Count = 0
            end
        end
    end
    file:close()
    return curTable
end

function ChatArrival(sUser,sData)
local _,_,Cmd = string.find(sData, "%b<>%s*(%S+)%|")
if Cmd == "#convert" then
sUser:SendData("Converter","Start Converting YnHub register into PtokaX register")
local T = ConvertYnHubRegisterFile(FileName)
local t,g,b = 0,0,0
for nick,_ in T do
t = t + 1
if ProfileRegistry[T[nick].Profile] and GetProfileIdx(ProfileRegistry[T[nick].Profile]) ~= -1 then
g = g + 1
AddRegUser(nick,T[nick].Pass, GetProfileIdx(ProfileRegistry[T[nick].Profile]))
else
b = b +1
end
end
sUser:SendData("Converter", "*** Total ( "..t.." ) registered user(s) is found in YnHub")
sUser:SendData("Converter","*** Total ( "..g.." ) user(s) are registered to PtokaX registry")
sUser:SendData("Converter","*** Total ( "..b.." ) user(s) is not registered because profiles doesn't exist in PtokaX")
return 1
end
end
--// NightLitch

Enjoy!
Title:
Post by: Snooze on 23 April, 2005, 18:52:24
Thanks NightLitch for a quick and great fix for all those poor people still running YnHub

Best regards,

Snooze
Title:
Post by: NightLitch on 23 April, 2005, 18:54:51
Thank you.

Fun that an old "veteran" can be of some use  :D  LooooL

Me Veteran no no no no no no no no no .....  :P

Take care man...
Title:
Post by: GeceBekcisi on 24 April, 2005, 14:00:18
Getting errors when I use script without any editing except file path,


[14:59:16] Start Converting YnHub register into PtokaX register
[14:59:16] *** Total ( 0 ) registered user(s) is found in YnHub
[14:59:16] *** Total ( 0 ) user(s) are registered to PtokaX registry
[14:59:16] *** Total ( 0 ) user(s) is not registered because profiles doesn't exist in PtokaX


Couldnt make it work!
Title:
Post by: NightLitch on 25 April, 2005, 09:54:33
QuoteOriginally posted by GeceBekcisi
Getting errors when I use script without any editing except file path,


[14:59:16] Start Converting YnHub register into PtokaX register
[14:59:16] *** Total ( 0 ) registered user(s) is found in YnHub
[14:59:16] *** Total ( 0 ) user(s) are registered to PtokaX registry
[14:59:16] *** Total ( 0 ) user(s) is not registered because profiles doesn't exist in PtokaX


Couldnt make it work!

show me how you typed the part...

Easiest way is to copy the RegFile from YnHub into the Script folder in PtokaX and just enter the filename.
Title:
Post by: DarkElf on 18 July, 2005, 13:48:57
[13:47:00] Start Converting YnHub register into PtokaX register
[13:47:00] <[Wh???W???W]-?LiAl> #convert

And nothing else..

Ptokax(0.3.3.1)  say:

[13:47] Syntax ...rse dc++\hubserver\0.3.3.1.nt.dbg\scripts\yn2pto.lua:59: attempt to index local `file' (a nil value)
Title:
Post by: Snooze on 18 July, 2005, 19:09:26
Did you edit this part to fit your settings?

--//-- Specify the Path to YnHubs Register File
FileName = "filename_here.xml"


Snooze