Two scripts in need of conversion.
 

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

Two scripts in need of conversion.

Started by Jaakko, 30 August, 2007, 11:59:04

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Jaakko

I tried to download Mutor's conversion app, but couldn't find any working link. :'(

First one is anti advertising script that sends me advertisers info.
---------- 

-- Code: 

---------- 

----------------------------------------------------------------- 

-- A.I. Anti Advertising v1.1 - written by Guibs 21th Apr 2003 -- 

----------------------------------------------------------------- 

--------------------- 

-- Version History -- 

--------------------- 

-- v1.1 Changes synthax about 'strfind' (Thks to sedulus for the tips), by Guibs 21th Apr 2003 

-- v1.1 added +allowedadd, +refusedadd commands (Thks to Dazzler for the ideas), by Guibs 21th Apr 2003 

-- v1.0 first version. Greets to sebastiannielsen for the cool idea 



-- It works in PM, and on the main chat & blocks the bad addresses 

-- Ops can't be kicked 

-- Edit the safeadd list, to put your good hub addresses 



--Converted to lua5 by Hoke



------------------------------------ 

-- Sourcecode is below this point -- 

------------------------------------ 



safeadd = { 

["dchub://kahvinorjat.no-ip.info"]=1, 

["kahvinorjat.no-ip.info"]=2,

["dchub://yhdistynyt.no-ip.info:2411"]=3,

["yhdistynyt.no-ip.info:2411"]=4,

["dchub://v8power.no-ip.info"]=5,

["v8power.no-ip.info"]=6,

["dchub://kotihubi.no-ip.info:1411"]=7,

["kotihubi.no-ip.info:1411"]=8,

["dchub://kanihubi.no-ip.org:4411"]=9,

["kanihubi.no-ip.org:4411"]=10,

["dchub://vittu.kicks-ass.org:4111"]=11,

["vittu.kicks-ass.org:4111"]=12,

} 


trigs = { 

["dns2go"]=1, 

["myftpsite"]=2, 

["servebeer"]=3, 

["mine.nu"]=4, 

["no-ip"]=5, 

["dynip"]=6, 

["staticip"]=7, 

["serveftp"]=8, 

["ipactive"]=9, 

["ip.org"]=10, 

["servegame"]=11, 

["ath.cx"]=12, 

["dyndns"]=13, 

["clanpimp"]=14, 

["idlegames"]=15, 

["sytes"]=16, 

["uni.cc"]=17, 

["homeunix"]=18, 

["deftonzs.com"]=19, 

["flamenap"]=20, 

["xs4all"]=21, 

["serveftp"]=22, 

["myftp"]=23, 

["d2g"]=24, 

["hopto.org"]=25, 

["orgdns"]=26, 

["gotdns"]=27, 

["baanapojat"]=28, 

["finx.org"]=29,

["outwar.com"]=30,

["ihmemaa.org"]=31,

["urlcut.com"]=32,

["no - ip"]=33,

["no ip"]=34,

["no.ip"]=35,

["no .ip"]=36,

["no -ip"]=37,

["80.186.197.96"]=38,

["80.186.197.111"]=39,

["galy.szm"]=40,

["KNUCKLES"]=41,

["/?p=hub&id="]=42,

["h4xx0rd00d"]=43,

["www.sexstreamtv.com"]=44,

["www.pushthebutton.fr"]=45,

["www.ochyda.abc.pl"]=46,

["servehttp"]=47,

["http://"]=48,

[".zapto.org"]=49,

[".servecounterstrike."]=50,

["www."]=51,

[".org"]=52,

[".net"]=53,

[".com"]=54,

["_org"]=55,

["_net"]=56,

["_com"]=57,

["www"]=58,

["thechaos.(no)-(ip).(biz):600"]=59,

["SUPERHUB"]=60,

["dchub://"]=61,

[".ru"]=62,

[".ro"]=63,

[".cz"]=64,

[".tk"]=65,

["hub."]=66,

[".lv"]=67,

} 



--------------------- 

-- Global Settings -- 

--------------------- 



Bot = "#Raziel" 

Owner = "[Admin]Cain"-- who get report in pm, remember to anable pm from bots in your client settings



------------------ 

-- Data Arrival -- 

------------------ 



function ChatArrival(user, data) 



returndata = 0 

founded = 0 

safe = 0 

allowedadd = 0 

refusedadd = 0 



if (string.sub(data,1,1)=="<") then 

data=string.sub(data,1,string.len(data)-1) 

s,e,to,cmd=string.find(data,"<(.*)>%s+(%S+)") 

cmd=string.lower(cmd) 

s,e,cmd = string.find(data,"%b<>%s+(%S+)") 



if user.bOperator then

if (cmd=="+allowedadd") then 

user:SendData(Bot, allowedadd.." allowed addresses has been sended on the main chat or in pm") 

returndata = 1 



elseif (cmd=="+refusedadd") then 

user:SendData(Bot, refusedadd.." refused addresses has been sended on the main chat or in pm") 

returndata = 1 

end 

end 



if user.bOperator then -- and Owner==1 then 

else 

for key,a in trigs do 

if(string.find(string.lower(data),key,5,1)) then 

founded = 1 

break 

end 

end 

if founded == 1 then 

for safekey,a in safeadd do 

if(string.find(string.lower(data),safekey,5,1)) then 

safe = 1 

break 

end 

end 

end 

if founded == 1 then 

if safe == 1 then 

allowedadd=allowedadd+1 

else 

returndata = 1 

refusedadd=refusedadd+1 

SendPmToNick( Owner, Bot, user.sName.. " IP: " ..user.sIP.. " ja jaossa: " ..user.iShareSize.. " B otti osumaa. Viesti: "..data ) 

user:SendPM(Bot, "You have been kicked for advertising without permit. - Kenk?? tuli mainostamisesta ilman lupaa.") 

user:TempBan() --Unmark this line if you want user no to be banned (nick and IP banned)

user:Disconnect() 

end 

end 

end 

end 

end

function ToArrival(user, data) 



returndata = 0 

founded = 0 

safe = 0 

allowedadd = 0 

refusedadd = 0 



if (string.sub(data,1,4)=="$To:") then 

data=string.sub(data,1,string.len(data)-1) 

s,e,whoTo=string.find(data,"$To:%s+(%S+)") 

--cmd=string.lower(cmd) 

s,e,cmd = string.find(data,"$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(.*)") 



if user.bOperator then

if (cmd=="+allowedadd") then 

user:SendData(Bot, allowedadd.." allowed addresses has been sended on the main chat or in pm") 

returndata = 1 



elseif (cmd=="+refusedadd") then 

user:SendData(Bot, refusedadd.." refused addresses has been sended on the main chat or in pm") 

returndata = 1 

end 

end 



if user.bOperator then -- and Owner==1 then 

else 

for key,a in trigs do 

if(string.find(string.lower(data),key,17,1)) then 

founded = 1 

break 

end 

end 

if founded == 1 then 

for safekey,a in safeadd do 

if(string.find(string.lower(data),safekey,17,1)) then 

safe = 1 

break 

end 

end 

end 

if founded == 1 then 

if safe == 1 then 

allowedadd=allowedadd+1 

else 

returndata = 1 

refusedadd=refusedadd+1 

SendPmToNick( Owner, Bot, user.sName.. " IP: " ..user.sIP.. " ja jaossa: " ..user.iShareSize.. " B otti osumaa. Viesti: "..data ) 

user:SendPM(Bot, "You have been kicked for advertising without permit. - Kenk?? tuli mainostamisesta ilman lupaa.") 

user:TempBan() --Unmark this line if you want user no to be banned (nick and IP banned)

user:Disconnect() 

end 

end 

end 

end 

end


Second one is gamebot.
sAuthor = "RabidWombat";

sEmail = "cbarber@dwc.edu";

sConversion = " Converted to LUA 5 by ?˜”??•Hawk•??”˜? 03/03/2005"

bGameRunning, bGamePaused = nil, nil;

sJumblePhrase, sActualPhrases, NoSpacePhrase = nil,nil,nil;

iLength, iBonusTime = 0, 0;

sScoreOutput, sHintOutput, sHelpOutput, sOpHelpOutput = nil, nil, nil, "";

iTimeCount, iGameNoReplyCount = 0, 0;

tScores, tScoresByName  = { n = 0 }, {};

tChannelUsers, iChannelCount = {}, nil;



-- PtokaX Events --



function Main()

dofile("jumble_5.0.cgf");



sScoreFormula = "return "..sScoreFormula;

sBonusFormula = "return "..sBonusFormula;

sHintFormula  = "return "..sHintFormula;



frmHub:RegBot(sBotName);



sHelpOutput = StrReplace(tStringTable[1]);



for cmd,tTemp in tCommands do

if(tTemp[1] == DisplayJumbleHelp) then

sJumbleHelp = cmd;

end



sCmd, sDesc = cmd, tTemp[3];



if(tTemp[2] == 0) then

sHelpOutput = sHelpOutput..StrReplace(tStringTable[2]);

else

sOpHelpOutput = sOpHelpOutput..StrReplace(tStringTable[2]);

end

end



OldSendToAll = SendToAll;

UserDisconnected = LeaveJumble;

OpDisconnected = LeaveJumble;



SetTimer(1000);



ReadScoresFromFile();

SetScores();

end



function OnTimer()

if(bGamePaused) then

iTimeCount = iTimeCount + 1;



if(iTimeCount >= iPauseTime) then

StartJumblePhrase();

end

elseif(bGameRunning) then

iTimeCount = iTimeCount + 1;



if(iTimeCount == iHintTime) then

SendToAll(sBotName, sHintOutput);

elseif (iTimeCount == iGameEndTime - 10) then

SendToAll(sBotName, StrReplace(tStringTable[3]));

elseif (iTimeCount == iGameEndTime) then

StopJumblePhrase();

if(iGameNoReplyCount >= 5) then

StopJumbleGame();

end

else



end

else



end

end







function ChatArrival(curUser, sData)

local s, e, sNewData, chat, cmd, args = string.find(sData, "(%b<>%s+((%S+)%s*([^%|]*)))%|$");

local s, e, sTo = string.find(sData, "^%$To: (%S+)");



if(cmd == nil or (sTo and sTo ~= sBotName)) then return 0; end



sUserName = curUser.sName;



if(sTo) then

curUser.SendData = curUser.SendPM;

end



cmd = string.lower(cmd);



if(tCommands[cmd] and (tCommands[cmd][2] == 0 or curUser.bOperator)) then

curUser:SendData(sData);

tCommands[cmd][1](curUser, args);

return 1;

else

if (not(iChannelCount) and string.sub(sData,1,1) == "<") then

iGameNoReplyCount = 0;

end



if(iChannelCount and string.find(sData, "$To: "..sBotName, 1, 1) == 1 and cmd == "!me") then

sNewData = "* "..sUserName..string.sub(chat, 4);

end



if(bGameRunning and bGamePaused == nil and string.find(string.upper(chat), sActualPhrase, 1, 1)) then

SendToAll(sNewData);



iBonusTime = math.max(iBonusTimeLimit - iTimeCount, 0);



iScore = assert(loadstring(StrReplace(sScoreFormula)))();

iBonus = assert(loadstring(StrReplace(sBonusFormula)))();



if(tScoresByName[sUserName]) then

tScoresByName[sUserName][2] = tScoresByName[sUserName][2] + iScore + iBonus;

else

tScoresByName[sUserName] = {sUserName, iScore + iBonus};

table.insert(tScores, tScoresByName[sUserName]);

end



iRank = SetScores(sUserName);

iRankTotal = table.getn(tScores);

iUserScore = tScoresByName[sUserName][2];



WriteScoresToFile();



StopJumblePhrase();



if(iBonusTime ~= 0) then

SendToAll(sBotName, StrReplace(tStringTable[4]));

else

SendToAll(sBotName, StrReplace(tStringTable[5]));

end



iGameNoReplyCount = 0;



return 1;

else

if(iChannelCount and string.find(sData, "^$To: "..sBotName, 1, 1) == 1) then

if(tChannelUsers[sUserName] == nil) then

JoinJumble(curUser);

else

SendToAll(sNewData);

iGameNoReplyCount = 0;

end



return 1;

end

end



end

end



-- Command Functions --



function StartJumbleGame(curUser, args)

if(bGameRunning) then return; end

if(args ~= "") then

HubGameActive = 2

local s, e, args = string.find(args, "([%w%s]+)$");

args = "Jumble\\"..args..".txt";

local f,e = io.open(args,"r")

if f then

sJumbleWordsFile = args;

f:close(f)

end

end

OldSendToAll(sBotName, StrReplace(tStringTable[6]));

StartJumblePhrase();

SendToAll(sBotName, StrReplace(tStringTable[7]));



iGameNoReplyCount = 0;

end



function StopJumbleGame(curUser)

if not(bGameRunning) then return; end



if not(bGamePaused) then

StopJumblePhrase();

end



if(curUser) then

OldSendToAll(sBotName, StrReplace(tStringTable[8]));

else

OldSendToAll(sBotName, StrReplace(tStringTable[21]));

-- TODO: fix numbers

end



bGameRunning, bGamePaused = nil, nil;

iBonusTime, iLength = 0, 0;

StopTimer();

end



function DisplayJumblePhrase(curUser)

if(bGameRunning and not bGamePaused) then

if(curUser == nil) then

SendToAll(sBotName, StrReplace(tStringTable[9]));

else

curUser:SendData(sBotName, StrReplace(tStringTable[9]));

end

end

end



function DisplayJumbleHelp(curUser)

if(curUser.bOperator) then

curUser:SendData(sBotName, sHelpOutput..sOpHelpOutput);

else

curUser:SendData(sBotName, sHelpOutput);

end

end



function DisplayJumbleScores(curUser)

curUser:SendData(sBotName, sScoresOutput);

end



function DisplayMyJumbleScore(curUser)

iRank = tScoresByName[curUser.sName][3];

iRankTotal = table.getn(tScores);

iUserScore = tScoresByName[sUserName][2];



if(tScoresByName[curUser.sName]) then

curUser:SendData(sBotName, StrReplace(tStringTable[10]));

else

curUser:SendData(sBotName, StrReplace(tStringTable[11]));

end

end



function DisplayJumbleHint(curUser)

if(iTimeCount >= iHintTime) then

curUser:SendData(sBotName, sHintOutput);

end

end



function JoinJumble(curUser)

if(iChannelCount and tChannelUsers[curUser.sName] == nil) then

SendToAll(sBotName, StrReplace(tStringTable[12]));



curUser:SendPM(sBotName, StrReplace(tStringTable[13]));

curUser.SendData = curUser.SendPM;



DisplayJumblePhrase(curUser);

DisplayJumbleHint(curUser);



tChannelUsers[curUser.sName] = 1;

iChannelCount = iChannelCount + 1;

end

end



function LeaveJumble(curUser)

if(iChannelCount and tChannelUsers[curUser.sName]) then

sUserName = curUser.sName;

SendToAll(sBotName, StrReplace(tStringTable[14]));



tChannelUsers[curUser.sName] = nil;

iChannelCount = iChannelCount - 1;



if(iChannelCount <= 0) then

iChannelCount = 0;

StopJumbleGame();

end

end

end



function SetPrivateJumbleGame(curUser)

if(iChannelCount == nil) then

SendToAll = SendToAllInChannel;

iChannelCount = 0;

end

end



function SetPublicJumbleGame(curUser)

if(iChannelCount) then

SendToAll = OldSendToAll;

tChannelUsers = {};

iChannelCount = nil;

end

end



-- Jumble Phrase Functions --



function JumbleString(str)

local tStr = { n = 0; };

local newString = "";



string.gsub(str, "(.)", function(c) table.insert(tStr, c); end);



math.randomseed(os.clock());



-- Fisher-Yates shuffle

for n = table.getn(tStr), 1, -1 do

local pos = math.random(n);

newString = tStr[pos].." "..newString;

tStr[pos] = tStr[n];

end



return newString;

end



function JumblePhrase(phr)

return string.sub(string.gsub(phr, "(%S+)", function (w) return JumbleString(w).."  "; end), 1, -2);

end



function StartJumblePhrase()

local hFile,Er = io.open(sJumbleWordsFile, "r");

if(hFile == nil) then

SendToAll(sBotName, "Error opening "..sJumbleWordsFile);

return;

end

local _, phr = nil, nil;

local iFileSize = hFile:seek("end")

math.randomseed(os.clock());

while(phr == nil) do

hFile:seek("set", math.random(iFileSize)-1);

 _, phr = hFile:read( "*l", "*l");

end

hFile:close();

sActualPhrase = string.upper(phr);

sNoSpacePhrase = string.gsub(sActualPhrase, "%s", "");

sJumblePhrase = JumblePhrase(sActualPhrase);

iLength = string.len(sNoSpacePhrase);



SetJumbleHint();



SendToAll(sBotName, StrReplace(tStringTable[9]));



iTimeCount = 0;

bGameRunning = 1;

bGamePaused = nil;

StopTimer(); StartTimer();

end



function StopJumblePhrase()

SendToAll(sBotName, StrReplace(tStringTable[15]));

sActualPhrase, sNoSpacePhrase, sJumblePhrase = nil, nil, nil;



iTimeCount = 0;

bGamePaused = 1;

iGameNoReplyCount = iGameNoReplyCount + 1;

end



-- String Functions --



function StrReplace(sString)

sString = string.gsub(sString, "%$(%w+)", function (w)

if(string.sub(w,1,1) == "$") then

return string.sub(w,2,-1);

else

return _G[w] or "nil";

end

end);



return sString;

end



-- Score Functions --



function SetScores(sName)

local iCount = table.getn(tScores);

iDisplayCount = iDisplayScores or iCount



if(iDisplayScores) then

sScoresOutput = StrReplace(tStringTable[16]);

else

sScoresOutput = StrReplace(tStringTable[17]);

end



if(iCount == 0) then

sScoresOutput = StrReplace(tStringTable[18]);

else

table.sort(tScores, function(a, b) return a[2] > b[2]; end);



for i = 1, iCount, 1 do

tScores[i][3] = i;-- set ranks for all users

end



for i = 1, math.min(iDisplayCount, iCount), 1 do

iPos = i;

sUserName = tScores[iPos][1];

iUserScore = tScores[iPos][2];

sScoresOutput = sScoresOutput..StrReplace(tStringTable[19]);

end

end



sUserName = sName;



if(sName) then

return tScoresByName[sName][3];

end

end



function ReadScoresFromFile()

dofile(sJumbleScoresFile);



for i = 1, table.getn(tScores), 1 do

tScoresByName[tScores[i][1]] = tScores[i];

end

end

function ToArrival(user, data)

ChatArrival(user, data)

end

function WriteScoresToFile()

local hFile,Er = io.open(sJumbleScoresFile, "w");

hFile:write("tScores = {\n");

for i = 1, table.getn(tScores), 1 do

hFile:write("["..i.."] = {"..string.format("%q", tScores[i][1])..","..tScores[i][2].."},\n");

end

hFile:write("n="..table.getn(tScores).."\n");

hFile:write("};");

hFile:close();

end



-- Hint Functions --



function SetJumbleHint()

local tRevealArray = { };



local iReveal = assert(loadstring(StrReplace(sHintFormula)))();



local iPos = nil;



while(iReveal > 0) do

repeat iPos = math.random(iLength); until tRevealArray[iPos] == nil



tRevealArray[iPos] = 1;

iReveal = iReveal - 1;

end



tRevealArray.iPos = 1;



sHint = string.gsub(sActualPhrase, "(%S)", function (c) 

if (c == nil) then return ""; end



local out, tTemp = nil, tRevealArray;



if(tTemp[tTemp.iPos]) then

out = c;

else

out = sHintChar;

end



tTemp.iPos = tTemp.iPos + 1;



return out.." ";

end);

sHint = string.sub(sHint, 1, -2);



sHintOutput = StrReplace(tStringTable[20]);

end



-- Channel Functions --



function SendToAllInChannel(sSender, sRawOutput)

if(sSender) then

local _;



if(sRawOutput == nil) then

sRawOutput = sSender;

_, _, sSender = string.find(sRawOutput, "^%<(.-)%>");

else

sRawOutput = "<"..sSender.."> "..sRawOutput;

end



for nick, val in tChannelUsers do

if(nick ~= sSender) then

SendToNick(nick, "$To: "..nick.." From: "..sBotName.." $"..sRawOutput);

end

end

end

end

bastya_elvtars

JumbleFever has already been converted. The anti-advertising script can be substituted with Lucifer.
Please search the forum before you ask.
Everything could have been anything else and it would have just as much meaning.

SMF spam blocked by CleanTalk