PtokaX forum

Development Section => Your Developing Problems => Topic started by: JoshJ on 30 April, 2004, 00:30:38

Title: Need some help with fixing this...
Post by: JoshJ on 30 April, 2004, 00:30:38
Ok guys I started do this script last nite and I basically want to be able to have like previous have done with bots having descriptions but being able to change it within the hub running...problem is that I did it late last nite and I screwed it up somewhere. Any help would be appreciated..

Botname = "InfoBot" -- Name of the bot
BotMail = "none" -- Email Address shown in user list beside the botname.
BotSpeed = "56kbps" -- 56kbps/Cable/DSL/LAN(T1)/LAN(T3)
BotDesc = "Howdy" -- Description of bot
kb = 1024
mb = 1024 * 1024
gb = 1024 * 1024 * 1024
BotShare = 5 * mb -- use numbers below to choose kb, mb, or gb
BotTag = "<++ V:0.401,M:A,H:0/0/1,S:1>" -- A dc++ style tag can be put here (if you want users to believe its a real user)
BotShareFrmt = BotShare / 1048576
BotInfo = 1
MIS = "$MyINFO $ALL "..Botname.." "..BotDesc..BotTag.."$ $"..BotSpeed..strchar( 1 ).."$"..BotMail.."$"..BotShare.."$"

function Main()
frmHub:RegBot(Botname)
if (BotInfo == 1) then
MIS = "$MyINFO $ALL "..Botname.." "..BotDesc..BotTag.."$ $"..BotSpeed..strchar( 1 ).."$"..BotMail.."$"..BotShare.."$"
else
end
end

function NewUserConnected(user)
user:SendData(Botname, "Welcome to "..frmHub:GetHubName().."!")
if (BotInfo == 1) then
user:SendData(MIS)
else
end
end

function OpConnected(user)
if (BotInfo == 0) then
user:SendData(Botname, "We have a problem! Bot descriptions info have been disabled!")
else
user:SendData(MIS)
end
end

function DataArrival(user,data)
if strsub(data, 1, 1) == "<" then
data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data,"%b<>%s+(%S+)") -- this converts it into cmd (the incoming data)

if cmd == "showinfo" then
user:SendData(Botname, "The following are statistics of InfoBot:\r\n")
user:SendData(Botname, "The current Botname is set to: "..Botname)
user:SendData(Botname, "The current description of "..Botname.." is set to: "..BotDesc)
user:SendData(Botname, "The current tag that "..Botname.." uses is set to: "..BotTag)
user:SendData(Botname, "The current e-mail address that "..Botname.." has is set to: "..BotMail)
user:SendData(Botname, "The current share amount that "..Botname.." has is set to: "..BotShareFrmt.." MB")
user:SendData(Botname, "The bot info script is now set to: "..BotInfo.." -- (0 = off, 1 = on)")
return 1
elseif cmd == "setmail" then
SetMail(user,data)
elseif cmd == "setdesc" then
SetDesc(user,data)
end
end
end

function SetMail(user,data)
if user.bOperator then
BotMail = mail
local s,e,cmd,mail = strfind(data,"%s+(%S+)%s+(.*)")
user:SendData(Botname, "The InfoBot E-mail address has been changed to: "..mail)
if mail == nil then
user:SendData(Botname, "No email address for the bot was chosen, action cancelled!")
else
user:SendData(Botname, "You do not have permission to do that!")
end
end
end

function SetDesc(user,data)
local s,e,cmd,desc = strfind(data,"%s+(%S+)%s+(.*)")
if user.bOperator then
BotDesc = desc
user:SendData(Botname, "The InfoBot description has been changed to: "..BotDesc)
if desc == nil then
user:SendData(Botname, "No description was chosen, action cancelled!")
else
user:SendData(Botname, "You do not have permission to do that!")
end
end
end

Thanks Guys.

P.S. : Forgot to state that the error message I get when typing the commands is as follows:
Syntax Error: attempt to concat global `BotDesc' (a nil value)
Syntax Error: attempt to concat global `mail' (a nil value)
Title:
Post by: nEgativE on 30 April, 2004, 06:37:34
Maybe this lines.. i don't know.

MIS = "$MyINFO $ALL "..Botname.." "..BotDesc..BotTag.." $ $"..BotSpeed..strchar( 1 ).."$"..BotMail.."$"..BotShare.."$"

user:SendData(Botname, "The InfoBot E-mail address has been changed to: "..mail )

1 --> "..BotDesc.." "..BotTag.."

2 --> "..BotMail.."
Title:
Post by: [UK]Madman on 04 May, 2004, 17:21:04
Im not an expert, so plz tell me if im wrong  :P

But it look like your saying Botmail = mail before you have grabbed "mail"


function SetMail(user,data)
if user.bOperator then
BotMail = mail   <<<<< declaring Botmail = mail
local s,e,cmd,mail = strfind(data,"%s+(%S+)%s+(.*)") <<<<< finding what mail actually is

so maybe this would work better


function SetMail(user,data)
if user.bOperator == Nil then
user:SendData(Botname, "You do not have permission to do that!")
else
local s,e,cmd,mail = strfind(data, "%s+(%S+)%s+(.*)")
if mail == nil then
user:SendData (Botname, "No email address for the bot was chosen, action cancelled!")
else
user:SendData(Botname, "The InfoBot E-mail address has been changed to: "..mail)
BotMail = mail
end
end
end


Id also make the second function SetDesc same kind of format.