PtokaX forum

Archive => Archived 4.0 boards => Finished Lua 4 scripts => Topic started by: ((UKSN))shad_dow on 24 July, 2004, 23:50:43

Title: Addy-Bot by Shad_dow?
Post by: ((UKSN))shad_dow on 24 July, 2004, 23:50:43
--// Addy-bot by Shad_dow?
--// with hnts/tips by Plop and Hawk

--//description
--// save place for user to palce addys ,
--// they type !add (1 , 2 ,3 )
--// then !list to see addys

--// example , !add therapyuk 1  
--// !list   > bot replys in pm > User Shad_dow? added therapyuk.styes.net
--// depending on the number , diceds what gets add to it 1 = styes.net 2 = no-ip.com etc

--// use in Therapy-X V2.1 cos of the anti-advertising :)

Bot = "addy-test"

Hubslist = "Hublist.txt"

tAddys = {
[1]="styes.net",
[2]="no-ip.com",
[3]="beer.net"
}

function DataArrival(curUser,data)
if (strsub(data,1,1)=="<") or (strsub(data,1,5+strlen(Bot))=="$To: "..Bot) then
data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data,"%b<>%s+(%S+)")

if (cmd == "!add")   then
doaddy(curUser,data)
return 1
                elseif (cmd == "!list") then
readaddy(curUser,data)
return 1                                    
end
end
end

function doaddy(curUser,data)
local s,e,cmd,hub,unit = strfind(data, "%b<>%s+(%S+)%s+(%S+)%s+(%d+)")
if hub == nil and unit == nil then
curUser:SendData(Bot,"Syntex is !add [hub name] [reason] ")
else
local add = tAddys[tonumber(unit)]
                if add == nil then
curUser:SendData(Bot,"addy not found")
else
SendPmToNick(curUser.sName,Bot,"You wrote this into the news txt: "..hub.."."..add.." ")
SendToAll(Bot, "User "..curUser.sName.." added "..hub.."."..add.." ")                                          
appendto(Hubslist)
write("User "..curUser.sName.." added "..hub.."."..add.."\r\n")
writeto()
end
end
end

function readaddy(curUser,data)
readfrom(Hubslist)
local message = ""
while 1 do
local line = read()
if line == nil then
break
else
message = message..line.."\r\n"
end
end
curUser:SendPM(Bot,message)
end
Title:
Post by: D-J Valhala on 25 July, 2004, 00:45:17
what that Bot do? can you explane please  ?(
 :D
Title:
Post by: ((UKSN))shad_dow on 25 July, 2004, 01:13:46
Quote[00:12] !add therapy 2

[00:12] You wrote this into the addy file: theyapyuk.no-ip.com


 



id adds styes.net, no-ip.com,beer.net  instaed of the number on to any hub addy u add to the hubsddy file

simaler to a links bot

yours shad
Title:
Post by: D-J Valhala on 25 July, 2004, 01:44:13
nice  :D
Title:
Post by: ((UKSN))shad_dow on 25 July, 2004, 16:46:56
Thank U Mutor :)

just trying to keep it all alive  ;)
Title: Newer Version (now with add to table ,save/load table)
Post by: ((UKSN))shad_dow on 30 July, 2004, 21:47:26
--// Addy-Bot by shad_dow
--// help by plop and hawk
--// read fuction corrected by hawk
--// write table correct by Optimus
--// Serialize Function by [UKNOWN]

--//REMBER to crate a floder called Links in the scripts folder ,all text files the script will create :)



Bot = "Addy-Bot"


ZGAME = "Links/game.txt"
BMOVIE = "Links/movie.txt"
EMUSIC = "Links/music.txt"


UrlFile = "Links/addys.txt"


tAddys = {
[1]="3utilities.com",
[2]="bounceme.net",
[3]="hopto.org",
[4]="myftp.biz",
[5]="myftp.org",
[6]="myvnc.com",
[7]="no-ip.biz",
[8]="no-ip.com",
[9]="no-ip.info",
[10]="no-ip.org",
[11]="redirectme.net",
[12]="servebeer.com",
[13]="servecounterstrike.com",
[14]="serveftp.com",
[15]="servegame.com",
[16]="servehalflife.com",
[17]="servehttp.com",
[18]="servemp3.com",
[19]="servepics.com",
[20]="servequake.com",
[21]="sytes.net",
[22]="zapto.org",
[23]="ciscofreak.com",
[24]="damnserver.com",
[25]="ditchyourip.com",
[26]="dnsiskinky.com",
[27]="geekgalaxy.com",
[28]="net-freaks.com",
[29]="no-ip.ca",
[30]="no-ip.co.uk",
[31]="no-ip.net",
[32]="point2this.com",
[33]="securityexploits.com",
[34]="securitytactics.com",
[35]="servehumour.com",
[36]="servep2p.com",
[37]="servesarcasm.com",
[38]="stufftoread.com",
[39]="unusualperson.com",
[40]="workisboring.com" }

function Main()
frmHub:RegBot(Bot)
LoadFromFile(UrlFile)
end

function DataArrival(curUser,data)
if (strsub(data,1,5+strlen(Bot))=="$To: "..Bot) then
data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data,"%b<>%s+(%S+)")

if (cmd == "game") or (cmd == "movie") or (cmd == "music") then
doaddy(curUser,data)
return 1
                elseif (cmd == "MusicsHubs") then
                     Readmusic(curUser)

                      return 1
elseif (cmd == "MoviesHubs") then
                     ReadMOVIE(curUser)
                      return 1
elseif (cmd == "GamesHubs") then
                     ReadGame(curUser)
                      return 1

                elseif (cmd == "!linkshelp") then
                        dohelp(curUser)
                           return 1
                elseif (cmd == "!add") then
                          donewurl(curUser,data)
return 1
             

                                   
end
end
end


function doaddy(curUser,data)
local s,e,cmd,hub,unit = strfind( data, "%b<>%s+(%S+)%s+(%S+)%s+(%d+)" )

if hub == nil and unit == nil then
curUser:SendData(Bot,"Syntex is "..cmd.." [hub name] [reason] ")
else
local add = tAddys[tonumber(unit)]
                if add == nil then
                                    curUser:SendData(Bot,"addy not found")

else

SendPmToNick(curUser.sName,Bot,"You added this but to the links directory : "..hub.."."..add.." ")
                             SendToAll(Bot, "User "..curUser.sName.." added a New Hub ,Pm "..Bot.." with !linkshelp ")                                          
appendto("Links/"..cmd..".txt")
write("**********************************\r\n")
write(" \r\n")
write("User "..curUser.sName.." added dchub://"..hub.."."..add.."\r\n")
write(" \r\n")
writeto()

                                   


end
end
end

function ReadGame(curUser)
readfrom(ZGAME)
local message = ""
while 1 do
local line = read()
if line == nil then break
else
message = message..line.."\r\n"
end
end
curUser:SendPM(Bot,message)
end

function Readmusic(curUser)
             
readfrom(EMUSIC)
local message = ""
while 1 do
local line = read()
if line == nil then break
else
message = message..line.."\r\n"
end
end
curUser:SendPM(Bot,message)
end



             
function ReadMOVIE(curUser)
readfrom(BMOVIE)
local message = ""
while 1 do
local line = read()
if line == nil then break
else
message = message..line.."\r\n"
end
end
curUser:SendPM(Bot,message)
end



             


function dohelp(curUser,data)

curUser:SendData(Bot,"help not ready yet  ")
end



function donewurl(curUser,data)
local s,e,newurl = strfind(data, "%b<>%s+%S+%s*(%S*)")

if newurl ~= "" then
tinsert (tAddys, newurl)
SendToAll(Bot, "New "..newurl.." is added!")
SaveToFile(UrlFile, tAddys, "tAddys")
return 1
end
end


function Serialize(tTable, sTableName, sTab)
assert(tTable, "tTable equals nil");
assert(sTableName, "sTableName equals nil");

assert(type(tTable) == "table", "tTable must be a table!");
assert(type(sTableName) == "string", "sTableName must be a string!");

sTab = sTab or "";
sTmp = ""

sTmp = sTmp..sTab..sTableName.." = {\n"

for key, value in tTable do
local sKey = (type(key) == "string") and format("[%q]",key) or format("[%d]",key);

if(type(value) == "table") then
sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
else
local sValue = (type(value) == "string") and format("%q",value) or tostring(value);
sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
end

sTmp = sTmp..",\n"
end

sTmp = sTmp..sTab.."}\r\n"
return sTmp
end

function SaveToFile(file , table , tablename)
writeto(file)
write(Serialize(table, tablename))
writeto()
end

function LoadFromFile(UrlFile)
if (readfrom(UrlFile) ~= nil) then
readfrom(UrlFile)
dostring(read("*all"))
readfrom()
end
end
Title:
Post by: ((UKSN))shad_dow on 16 November, 2004, 10:22:02

--// Addy-Bot V1.2 by shad_dow
--// help by plop and hawk
--// read fuction corrected by hawk
--// write table correct by Optimus
"--// Serialize Function by RabitWombat (thx Nerbos)
--// table help from Mutor and Plop

--//REMBER to crate a floder called Links in the scripts folder ,all text files the script will create :)

--// still to do , Help function

Bot = "Addy-Bot"


hubbase = "Links/hubs.txt"


UrlFile = "Links/addys.txt"


tAddys = {
[1]="3utilities.com",
[2]="bounceme.net",
[3]="hopto.org",
[4]="myftp.biz",
[5]="myftp.org",
[6]="myvnc.com",
[7]="no-ip.biz",
[8]="no-ip.com",
[9]="no-ip.info",
[10]="no-ip.org",
[11]="redirectme.net",
[12]="servebeer.com",
[13]="servecounterstrike.com",
[14]="serveftp.com",
[15]="servegame.com",
[16]="servehalflife.com",
[17]="servehttp.com",
[18]="servemp3.com",
[19]="servepics.com",
[20]="servequake.com",
[21]="sytes.net",
[22]="zapto.org",
[23]="ciscofreak.com",
[24]="damnserver.com",
[25]="ditchyourip.com",
[26]="dnsiskinky.com",
[27]="geekgalaxy.com",
[28]="net-freaks.com",
[29]="no-ip.ca",
[30]="no-ip.co.uk",
[31]="no-ip.net",
[32]="point2this.com",
[33]="securityexploits.com",
[34]="securitytactics.com",
[35]="servehumour.com",
[36]="servep2p.com",
[37]="servesarcasm.com",
[38]="stufftoread.com",
[39]="unusualperson.com",
[40]="workisboring.com" }

function Main()
frmHub:RegBot(Bot)
LoadFromFile(UrlFile)
end

function DataArrival(curUser,data)
if (strsub(data,1,5+strlen(Bot))=="$To: "..Bot) then
data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data,"%b<>%s+(%S+)")

if (cmd == "!addhub") then
dogameaddy(curUser,data)
return 1
                elseif (cmd == "!hubs") then
                     Readhubs(curUser, data)

                      return 1


                elseif (cmd == "!linkshelp") then
                        dohelp(curUser)
                           return 1
                elseif (cmd == "!adddomain") then
                          donewurl(curUser,data)
return 1
                 elseif (cmd == "!listdomains") then
                 showlist(curUser, data)
return 1
                 elseif (cmd == "!totaldomains") then
                   showtotal(curUser, data)
return 1
                     
                 
             

                                   
end
end
end


function dogameaddy(curUser,data)
local s,e,cmd,hub,unit = strfind( data, "%b<>%s+(%S+)%s+(%S+)%s+(%d+)" )

if hub == nil and unit == nil then
curUser:SendData(Bot,"Syntex is !game [hub name] [reason] ")
else
local add = tAddys[tonumber(unit)]
                if add == nil then
                                    curUser:SendData(Bot,"addy not found")

else

SendPmToNick(curUser.sName,Bot,"You added this Hub to the links directory : "..hub.."."..add.." ")
                             SendToAll(Bot, "User "..curUser.sName.." added a New Hub ,Pm "..Bot.." with !linkshelp ")                                          
appendto(hubbase)
write("**********************************\r\n")
write(" \r\n")
write("User "..curUser.sName.." added dchub://"..hub.."."..add.."\r\n")
write(" \r\n")
--writeto()

                                   


end
end
end

function Readhubs(curUser, data)
readfrom(hubbase)
local message = ""
while 1 do
local line = read()
if line == nil then break
else
message = message..line.."\r\n"
end
end
curUser:SendPM(Bot,message)
end



function donewurl(curUser,data)
local s,e,newurl = strfind(data, "%b<>%s+%S+%s*(%S*)")

if newurl ~= "" then
tinsert (tAddys, newurl)
SendToAll(Bot, "New "..newurl.." is added!")
SaveToFile(UrlFile, tAddys, "tAddys")
return 1
end
end


function Serialize(tTable, sTableName, sTab)
assert(tTable, "tTable equals nil");
assert(sTableName, "sTableName equals nil");

assert(type(tTable) == "table", "tTable must be a table!");
assert(type(sTableName) == "string", "sTableName must be a string!");

sTab = sTab or "";
sTmp = ""

sTmp = sTmp..sTab..sTableName.." = {\n"

for key, value in tTable do
local sKey = (type(key) == "string") and format("[%q]",key) or format("[%d]",key);

if(type(value) == "table") then
sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
else
local sValue = (type(value) == "string") and format("%q",value) or tostring(value);
sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
end

sTmp = sTmp..",\n"
end

sTmp = sTmp..sTab.."}\r\n"
return sTmp
end

function SaveToFile(file , table , tablename)
writeto(file)
write(Serialize(table, tablename))
writeto()
end

function LoadFromFile(UrlFile)
if (readfrom(UrlFile) ~= nil) then
readfrom(UrlFile)
dostring(read("*all"))
readfrom()
end
end



function showlist(curUser, data)


for key,value in tAddys do --- do a loop for aslong as there are key's with value's in the table.
   
curUser:SendPM(Bot,"Domain Number "..key.." and has the value: ".. value)

end
end

function showtotal(curUser, data)
local n = getn(tAddys)  
local str = "***[ There are  ( "..n.." ) Domains in "..Bot.." ]***\r\n"  
curUser:SendPM(Bot,str)
end


yours

shad , ( create to understand tables)
Title:
Post by: nErBoS on 16 November, 2004, 12:44:45
Hi,

"--// Serialize Function by RabitWombat"

Keep it going  :))

Best regards, nErBoS
Title:
Post by: ((UKSN))shad_dow on 16 November, 2004, 14:14:52
hi nerbous

cheers for finding out who did the Serialize for me and Thank u for the support and i will keep it going :)

yours

shad

(script been edited on creadits)