Development Section > HOW-TO's

HOW-TO: Write your own bot = Lesson 6

(1/1)

pHaTTy:
ok lesson 5 we had at the end


--- Code: ---
Bot = "Keiko"

version = "0.6"
NEWCON = 1
prefix = "!"
TimeMins = 5  --set it to 5 mins


function Main()
frmHub:RegBot(Bot)
SetTimer(TimeMins*60000)
StartTimer()
end

function OnTimer() --This is what will be sent on the timer
randomtimer = random(2) --only 2 data's
if randomtimer == 1 then
SendToAll(Bot,"-------------------------------")
SendToAll(Bot,"--Write your own bot lesson 5--")
SendToAll(Bot,"-------------------------------")
elseif randomtimer == 2 then
SendToAll(Bot,"-----------------------------------------")
SendToAll(Bot,"--This lesson bot was created by Phatty--")
SendToAll(Bot,"-----------------------------------------")
end
end

function NewUserConnected(user)
if NEWCON == 1 then
user:SendData (Bot,"A User has connected")
end
end

function OpConnected(user)
thisisthevariable = random(5)
if thisisthevariable == 1 then
SendToAll(Bot,"This is message 1")

elseif thisisthevariable == 2 then
SendToAll(Bot,"This is message 2")

elseif thisisthevariable == 3 then
SendToAll(Bot,"This is message 3")

elseif thisisthevariable == 4 then
SendToAll(Bot,"This is message 4")

elseif thisisthevariable == 5 then
SendToAll(Bot,"This is message 5")
end
end



function DataArrival(user,data)
if strsub(data, 1, 1) == "

Navigation

[0] Message Index

Go to full version