Author Topic: Convert new appi  (Read 3042 times)

0 Members and 1 Guest are viewing this topic.

Offline ?[-?Genius?-]?

  • Double Ace
  • *
  • Posts: 118
  • Karma: +3/-1
Convert new appi
« on: 13 May, 2008, 04:43:08 »

Hi I don't know to translate scripts for its new appi. I attempted the one converts than it is to exitste in this forum but we were not able to. Somebody myself can aid plz?

Code: [Select]



--=[ DvdRip.sytes.net ]=--
--=[ Script by Conejodelmal ]=--
--=[ Lua 5.1 ]=--

--=[ C?digo do script ]=--

--=[ Nome do Bot ]=-
sBot = "[!???] ??vdRip?"

--=[ Nome do OpChat ]=-
sOpChatName = "[!???] ?Op Cha??"


--=[ Configura??o ]=-

--=[ Insere aqui os prefixos ]=-
 
sPrefix = { "[CV]" ,}

--=[ Insere aqui as rangs dos users CV ]=-

arrIP = {
   ["10.6.0.0"] = "10.6.0.30",
   ["84.90.0.0"] = "84.91.255.255",      --  Cabovisao,SA
   ["213.228.128.0"] = "213.228.191.255",   --  Cabovisao,SA
   ["217.129.0.0"] = "217.129.255.255",      --  Cabovisao,SA
}

--=[ C?digo ]=-

function Main()
frmHub:RegBot(sBot)
end

function NewUserConnected(user)
if (CheckUserPrefix(user) == nil) and not (isGoodIP(user.sIP) == nil) then
user:SendPM(sBot, "Mensagem")
SendPmToOps(sOpChatName, " - = [  O utilizador  [ "..user.sName.." ]  com o Ip  [ "..user.sIP.." ]  foi requesitado a usar a TAG [CV]  ] = -")
end
end

OpConnected = NewUserConnected

function ConnectToMeArrival(user,data)
if (CheckUserPrefix(user) == nil) and (isGoodIP(user.sIP) ~= nil) then
user:SendData(sBot, "Mensagem")
return 1
end
end

RevConnectToMeArrival = ConnectToMeArrival

function CheckUserPrefix(user)
for key,pre in pairs(sPrefix) do
if string.find(string.lower(user.sName), string.lower(pre),1,1) then
return 1
end
end
end

function isGoodIP(sIP)
sIP = ipToNumber(sIP)
local iFirst,iLast
for iFirst, iLast in pairs(arrIP) do
if (sIP >= ipToNumber(iFirst) and sIP <= ipToNumber(iLast)) then
return 1
end
end
return nil
end

function ipToNumber(sIP)
iAux = ""
string.gsub(sIP,"(%d+)", function(w)
w = tonumber(w)
if (w < 10) then
iAux = iAux.."00"..w
elseif (w < 100) then
iAux = iAux.."0"..w
else
iAux = iAux..w
end
end)
return tonumber(iAux)
end



PtokaX forum

Convert new appi
« on: 13 May, 2008, 04:43:08 »

Offline CrazyGuy

  • Viking
  • ****
  • Posts: 506
  • Karma: +83/-20
    • ?????=-_The NightHawk_-=?????
Re: Convert new appi
« Reply #1 on: 13 May, 2008, 12:17:58 »
Try this code
I've documented all changes at the bottom of the script, so you can see what's been changed  :)

Code: [Select]


--=[ DvdRip.sytes.net ]=--
--=[ Script by Conejodelmal ]=--
--=[ Lua 5.1 ]=--
--=[ Converted to new API by CrazyGuy ]=--

--=[ C?digo do script ]=--

--=[ Nome do Bot ]=-
sBot = "[!???]_??vdRip?"

--=[ Nome do OpChat ]=-
sOpChatName = "[!???]_?Op Cha??"


--=[ Configura??o ]=-

--=[ Insere aqui os prefixos ]=-
 
sPrefix = { "[CV]" ,}

--=[ Insere aqui as rangs dos users CV ]=-

arrIP = {
   ["10.6.0.0"] = "10.6.0.30",
   ["84.90.0.0"] = "84.91.255.255",      --  Cabovisao,SA
   ["213.228.128.0"] = "213.228.191.255",   --  Cabovisao,SA
   ["217.129.0.0"] = "217.129.255.255",      --  Cabovisao,SA
   ["127.0.0.1"] = "127.0.0.1",
}

--=[ C?digo ]=-

function OnStartup()
Core.RegBot(sBot,"","",true)
end

function UserConnected(user)
if (CheckUserPrefix(user) == nil) and not (isGoodIP(user.sIP) == nil) then
Core.SendPmToUser(user,sBot, "Mensagem|")
Core.SendPmToOps(sOpChatName, " - = [  O utilizador  [ "..user.sNick.." ]  com o Ip  [ "..user.sIP.." ]  foi requesitado a usar a TAG [CV]  ] = -|")
end
end

OpConnected,RegConnected = UserConnected,UserConnected

function ConnectToMeArrival(user,data)
if (CheckUserPrefix(user) == nil) and (isGoodIP(user.sIP) ~= nil) then
Core.SendToUser(user,"<"..sBot.."> Mensagem|")
return true
end
end

RevConnectToMeArrival = ConnectToMeArrival

function CheckUserPrefix(user)
for key,pre in pairs(sPrefix) do
if string.find(string.lower(user.sNick), string.lower(pre),1,1) then
return 1
end
end
end

function isGoodIP(sIP)
sIP = ipToNumber(sIP)
local iFirst,iLast
for iFirst, iLast in pairs(arrIP) do
if (sIP >= ipToNumber(iFirst) and sIP <= ipToNumber(iLast)) then
return 1
end
end
return nil
end

function ipToNumber(sIP)
iAux = ""
string.gsub(sIP,"(%d+)", function(w)
w = tonumber(w)
if (w < 10) then
iAux = iAux.."00"..w
elseif (w < 100) then
iAux = iAux.."0"..w
else
iAux = iAux..w
end
end)
return tonumber(iAux)
end



--[[
API specific changes:

line 12: space is not allowed in botname
line 15: space is not allowed in opchatname
line 35: Main -> OnStartup
line 36: frmHub:RegBot(sBot) -> Core.RegBot(sBotName,sBotDesc,sBotEmail,bKey)
line 39: NewUserConnected -> UserConnected
line 41: user:SendPM(sFrom,sData) -> Core.SendPmToUser(tUser, sFromNick, sData)
line 42: SendPmToOps(sFrom,sData) -> Core.SendPmToOps(sFromNick, sData)
line 42: user.sName -> user.sNick
line 46: added RegConnected
line 50: user:SendData(sFrom,sData) -> Core.SendToUser(tUser,sData)
line 58: user.sName -> user.sNick

]]--


« Last Edit: 14 May, 2008, 12:25:16 by CrazyGuy »

Offline ?[-?Genius?-]?

  • Double Ace
  • *
  • Posts: 118
  • Karma: +3/-1
Re: Convert new appi
« Reply #2 on: 13 May, 2008, 15:56:41 »
Hi script gave an error in ptokax: S
 Since already obliged for the help. I do not perceive nothing of scripting

Code: [Select]
[14:53] Sintaxe cv.lua:104: unfinished long comment near '<eof>'
PS: Is not space Its assci "CTRL+255" :) 

Im using Ptokax 0.4.1.0 RC2
« Last Edit: 13 May, 2008, 16:01:11 by ?[-?Genius?-]? »

Offline ?[-?Genius?-]?

  • Double Ace
  • *
  • Posts: 118
  • Karma: +3/-1
Re: Convert new appi
« Reply #3 on: 14 May, 2008, 06:16:30 »
Hi Again

The script have another error

Code: [Select]
[05:12] Sintaxe cv.lua:58: bad argument #1 to 'lower' (string expected, got nil)
I am thankful for your aid. I did not forget myself to thank mutor. my English is very bad and for times I do not obtain to say what I intend.
If something will be missed with my messages must use a website to translate -? http://www1.worldlingo.com/pt/microsoft/computer_translation.html

Offline CrazyGuy

  • Viking
  • ****
  • Posts: 506
  • Karma: +83/-20
    • ?????=-_The NightHawk_-=?????
Re: Convert new appi
« Reply #4 on: 14 May, 2008, 12:26:38 »

Code: [Select]
[05:12] Sintaxe cv.lua:58: bad argument #1 to 'lower' (string expected, got nil)
I am thankful for your aid. I did not forget myself to thank mutor.

lol, you are welcome  ;D
Anyways, I've made a few minor changes to the script above, but was not able to reproduce the error.
Script works fine here as far as I could see  :-\

Offline ?[-?Genius?-]?

  • Double Ace
  • *
  • Posts: 118
  • Karma: +3/-1
Re: Convert new appi
« Reply #5 on: 14 May, 2008, 15:24:51 »
sure script this good one. I tested script not converted. I cannot test scripts at 6:00 lool
tankx a lot for script ( 5 stars :) very Good work. i like changes :)

PtokaX forum

Re: Convert new appi
« Reply #5 on: 14 May, 2008, 15:24:51 »