HOW-TO: Write your own bot = Lesson 6
 

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

HOW-TO: Write your own bot = Lesson 6

Started by pHaTTy, 14 November, 2003, 17:31:48

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

pHaTTy

ok lesson 5 we had at the end

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) == "<" then 
		data=strsub(data,1,strlen(data)-1) 
		s,e,cmd = strfind(data,"%b<>%s+(%S+)") 
		if cmd == prefix.."version" then 
			user:SendData(Bot,"This bot is Learn to write a bot version: "..version.." by Phatty") 
		return 1 
		elseif cmd == prefix.."help" then 
			user:SendData(Bot,"This is where the help text wud go, bt im not gonna waste my time :P") 
		return 1 
		end 
	end
end

now i dont know about you but im sick of keep changing

the This is lesson blablah

so........

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 "..version.."--")
		SendToAll(Bot,"-------------------------------")
	elseif randomtimer == 2 then
		SendToAll(Bot,"-----------------------------------------")
		SendToAll(Bot,"--This lesson bot was created by Phatty--")
		SendToAll(Bot,"-----------------------------------------")
	end
end

now we are going to sup up the user connect msg's a little

function OpConnected(user) 
thisisthevariable = random(5)
	if thisisthevariable == 1 then
		SendToAll(Bot,user.sName.." has entered the hub") 

	elseif thisisthevariable == 2 then
		SendToAll(Bot,user.sName.." has entered, feel his wrath")  

	elseif thisisthevariable == 3 then
		SendToAll(Bot,user.sName.." is one of the big bosses, who just entered") 

	elseif thisisthevariable == 4 then
		SendToAll(Bot,user.sName.." has sneaked into the hub")  

	elseif thisisthevariable == 5 then
		SendToAll(Bot,user.sName.." has just kicked down the door") 
	end
end


so now we have

Bot = "Keiko" 

version = "0.5" 
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 "..version.."--")
		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,user.sName.." has entered the hub") 

	elseif thisisthevariable == 2 then
		SendToAll(Bot,user.sName.." has entered, feel his wrath")  

	elseif thisisthevariable == 3 then
		SendToAll(Bot,user.sName.." is one of the big bosses, who just entered") 

	elseif thisisthevariable == 4 then
		SendToAll(Bot,user.sName.." has sneaked into the hub")  

	elseif thisisthevariable == 5 then
		SendToAll(Bot,user.sName.." has just kicked down the door") 
	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+)") 
		if cmd == prefix.."version" then 
			user:SendData(Bot,"This bot is Learn to write a bot version: "..version.." by Phatty") 
		return 1 
		elseif cmd == prefix.."help" then 
			user:SendData(Bot,"This is where the help text wud go, bt im not gonna waste my time :P") 
		return 1 
		end 
	end
end

ok now we will add a profile idx in one of the entrances

function OpConnected(user) 
Pillock = GetProfileName(user.iProfile)
thisisthevariable = random(5)
	if thisisthevariable == 1 then
		SendToAll(Bot,user.sName.." has entered the hub") 

	elseif thisisthevariable == 2 then
		SendToAll(Bot,Pillock.." "..user.sName..",has entered, feel his wrath")  

	elseif thisisthevariable == 3 then
		SendToAll(Bot,user.sName.." is one of the big bosses, who just entered") 

	elseif thisisthevariable == 4 then
		SendToAll(Bot,user.sName.." has sneaked into the hub")  

	elseif thisisthevariable == 5 then
		SendToAll(Bot,user.sName.." has just kicked down the door") 
	end
end

now i dont know about you but i hate using SendToAll("Blablahblah")

so i will name it SendC ("Whatever")

Bot = "Keiko" 

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

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

function OnTimer()
randomtimer = random(2) --only 2 data's
	if randomtimer == 1 then
		SendC(Bot,"-------------------------------")
		SendC(Bot,"--Write your own bot lesson "..version.."--")
		SendC(Bot,"-------------------------------")
	elseif randomtimer == 2 then
		SendC(Bot,"-----------------------------------------")
		SendC(Bot,"--This lesson bot was created by Phatty--")
		SendC(Bot,"-----------------------------------------")
	end
end

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

function OpConnected(user) 
Pillock = GetProfileName(user.iProfile)
thisisthevariable = random(5)
	if thisisthevariable == 1 then
		SendC(Bot,user.sName.." has entered the hub") 

	elseif thisisthevariable == 2 then
		SendC(Bot,Pillock.." "..user.sName..",has entered, feel his wrath")  

	elseif thisisthevariable == 3 then
		SendC(Bot,user.sName.." is one of the big bosses, who just entered") 

	elseif thisisthevariable == 4 then
		SendC(Bot,user.sName.." has sneaked into the hub")  

	elseif thisisthevariable == 5 then
		SendC(Bot,user.sName.." has just kicked down the door") 
	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+)") 
		if cmd == prefix.."version" then 
			user:SendData(Bot,"This bot is Learn to write a bot version: "..version.." by Phatty") 
		return 1 
		elseif cmd == prefix.."help" then 
			user:SendData(Bot,"This is where the help text wud go, bt im not gonna waste my time :P") 
		return 1 
		end 
	end
end

thats all there is for this subject, til next time cya ;)

-phatz
Resistance is futile!

SMF spam blocked by CleanTalk