HOW-TO : Write your own Bot = Lesson 3 - Page 2
 

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 3

Started by pHaTTy, 22 October, 2003, 12:58:12

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

pHaTTy

ok time to run thru it so you can see the mistakes and save for the next lesson

--you had this

Bot = "Keiko" 
NEWCON = 1 

function Main() 
frmHub:RegBot(Bot) 
end 

function NewUserConnected(user) 
if NEWCON then 
user:SendData ("A User has connected") 
else 
end 

function OpConnected() 
if user.iprofile then 
user:senddata(Bot,"Hello" ..user.sName.. "How are you") 
return 1 
else 
SendToAll("A Op has entered") 
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 == "!version" then 
user:SendData(Bot,"This bot is Learn to write a bot version: "..version) 
return 1 
elseif cmd == "!help" then 
user:SendData(Bot,"This is where the help text would go, but im not gonna waste my time :P") 
return 1 
end 
end 
end 
end 
end


ok


----this is fine
Bot = "Keiko" 
NEWCON = 1 

function Main() 
frmHub:RegBot(Bot) 
end 
--------------------
function NewUserConnected(user) 
if NEWCON==1 then  -- this needed to equal something
user:SendData (Bot,"A User has connected") --bot name/not important
else 
end 
end -- missing an end
-----------------------

function OpConnected(user)  -- missing user
if user.iprofile==0 then --the user profile for the profiles.dat file
user:SendData(Bot,"Hello " ..user.sName.. " How are you") --cap sensitive for senddata
return 1 
else 
SendToAll("A Op has entered") 
end 
end --another 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 == "!version" then 
user:SendData(Bot,"This bot is Learn to write a bot version: "..version) 
return 1 
elseif cmd == "!help" then 
user:SendData(Bot,"This is where the help text would go, but im not gonna waste my time :P") 
return 1 
end 
end 
end 
end

there ya go now you can study and learn from it, wait until next lesson i will start asap, and try make it alot better and longer ;)

-War3zMantis
Resistance is futile!

xokas

almost there yep :)))

pHaTTy

yep ;) both doin good for only the third lesson, and this is the simple stuff, better to come yet ;)
Resistance is futile!

xokas

let me have them let me have them :P i take them all out :) just kiding

raz

i admit dat i should of got "end" but i needed a bit of help on the other 2. which i didn't know

pHaTTy

well has this helped you understadn it better? :)
Resistance is futile!

raz

this just shows that it ain't easy and u shouldn't try 2 get it done quickly cuz u might skip something. post next one up 2morrow. safe chat wid u 2morrrow.

pHaTTy

hehe well if i get time i will start a redo of lesson 4 but make better, as i did put 2 in one, i was in a rush so i will spreadt it out and make a better lesson 4 ;)
Resistance is futile!

xokas

for me the next one can come anytime!let them cum to me! :P

Skrollster

#34
if you use the tag [code ] and [/code] then it's much esier to read the code, use tab as well so the code looks like this:

Bot = "(Keiko)" -- missing "" to show that it is a string
NEWCON = 1

Main()
	frmHub:RegBot(Bot) -- spelling misstake on Bot
end

function NewUserConnected(CurUser)
	if NEWCON == 1 then -- use dubble equal signs then compareing
	user:SendData ("A User has connected") -- missed a " at the end of the text string
	else
	end
end -- missing end

function OpConnected()
	if user.iProfile == 0 then -- need duble '=' again and iProfile is case sensitive
		user:SendData(Bot,"Hello..user.sName..How are you") --Case sensitive function call + missing ')' in the end
		return 1
	else
		SendToAll(Bot,"A Op has entered") -- function name senttoall ned to be SendToAll, case sensitive
	end
end -- missing end

function Data Arrival(CurUser,data)
	if strsub(data, 1, 1) == "<" then
		data=strsub(data,1,strlen(data)-1)
		s,e,cmd = strfind(data,"%b<>%s+(%S+)") -- regular exp. wasn't used correctly and missing cmd variable

		if cmd == "!version" then -- missing one '=' again
			user:SendData(Bot,"This bot is Learn to write a bot version: "..version) --misspelled bot again and missing a declaration of version before using it..
			return 1	
		elseif cmd == "!help" then -- missing one '=' again
			user:SendData(Bot,"This is where the help text wud go, bt im not gonna waste my time :P") -- misspelled bot again
			return 1
		end
	end
end -- missing an end

and not like

Bot = "(Keiko)" -- missing "" to show that it is a string
NEWCON = 1

Main()
   frmHub:RegBot(Bot) -- spelling misstake on Bot
end

function NewUserConnected(CurUser)
   if NEWCON == 1 then -- use dubble equal signs then compareing
   user:SendData ("A User has connected") -- missed a " at the end of the text string
   else
   end
end -- missing end

function OpConnected()
   if user.iProfile == 0 then -- need duble '=' again and iProfile is case sensitive
      user:SendData(Bot,"Hello..user.sName..How are you") --Case sensitive function call + missing ')' in the end
      return 1
   else
      SendToAll(Bot,"A Op has entered") -- function name senttoall ned to be SendToAll, case sensitive
   end
end -- missing end

function Data Arrival(CurUser,data)
   if strsub(data, 1, 1) == "<" then
      data=strsub(data,1,strlen(data)-1)
      s,e,cmd = strfind(data,"%b<>%s+(%S+)") -- regular exp. wasn't used correctly and missing cmd variable

      if cmd == "!version" then -- missing one '=' again
         user:SendData(Bot,"This bot is Learn to write a bot version: "..version) --misspelled bot again and missing a declaration of version before using it..
         return 1   
      elseif cmd == "!help" then -- missing one '=' again
         user:SendData(Bot,"This is where the help text wud go, bt im not gonna waste my time :P") -- misspelled bot again
         return 1
      end
   end
end -- missing an end

//Skrollster

xokas

tkhx for the hint skrollster! gonna try to do better on the nexts times! tkhx a lot again

AlwaysConnected

QuoteOriginally posted by xokas
tkhx for the hint skrollster! gonna try to do better on the nexts times! tkhx a lot again

Weclome back Xokas aka ...... :)
and phatty go on with the lessons :)

its great :D

xokas

hey hey hey! is it a star? a plane?its superman? maybe a flying saucer? RUN PEOPLE IT'S AC!  





h? h? h?! im back indeed AC, nice to see ya around here too!  :]

pHaTTy

QuoteOriginally posted by Skrollster
if you use the tag [code ] and [/code] then it's much esier to read the code, use tab as well so the code looks like this:

Bot = "(Keiko)" -- missing "" to show that it is a string
NEWCON == 1

Main()
	frmHub:RegBot(Bot) -- spelling misstake on Bot
end

function NewUserConnected(CurUser)
	if NEWCON == 1 then -- use dubble equal signs then compareing
	user:SendData ("A User has connected") -- missed a " at the end of the text string
	else
	end
end -- missing end

function OpConnected()
	if user.iProfile == 0 then -- need duble '=' again and iProfile is case sensitive
		user:SendData(Bot,"Hello..user.sName..How are you") --Case sensitive function call + missing ')' in the end
		return 1
	else
		SendToAll(Bot,"A Op has entered") -- function name senttoall ned to be SendToAll, case sensitive
	end
end -- missing end

function Data Arrival(CurUser,data)
	if strsub(data, 1, 1) == "<" then
		data=strsub(data,1,strlen(data)-1)
		s,e,cmd = strfind(data,"%b<>%s+(%S+)") -- regular exp. wasn't used correctly and missing cmd variable

		if cmd == "!version" then -- missing one '=' again
			user:SendData(Bot,"This bot is Learn to write a bot version: "..version) --misspelled bot again and missing a declaration of version before using it..
			return 1	
		elseif cmd == "!help" then -- missing one '=' again
			user:SendData(Bot,"This is where the help text wud go, bt im not gonna waste my time :P") -- misspelled bot again
			return 1
		end
	end
end -- missing an end

and not like

Bot = "(Keiko)" -- missing "" to show that it is a string
NEWCON == 1

Main()
   frmHub:RegBot(Bot) -- spelling misstake on Bot
end

function NewUserConnected(CurUser)
   if NEWCON == 1 then -- use dubble equal signs then compareing
   user:SendData ("A User has connected") -- missed a " at the end of the text string
   else
   end
end -- missing end

function OpConnected()
   if user.iProfile == 0 then -- need duble '=' again and iProfile is case sensitive
      user:SendData(Bot,"Hello..user.sName..How are you") --Case sensitive function call + missing ')' in the end
      return 1
   else
      SendToAll(Bot,"A Op has entered") -- function name senttoall ned to be SendToAll, case sensitive
   end
end -- missing end

function Data Arrival(CurUser,data)
   if strsub(data, 1, 1) == "<" then
      data=strsub(data,1,strlen(data)-1)
      s,e,cmd = strfind(data,"%b<>%s+(%S+)") -- regular exp. wasn't used correctly and missing cmd variable

      if cmd == "!version" then -- missing one '=' again
         user:SendData(Bot,"This bot is Learn to write a bot version: "..version) --misspelled bot again and missing a declaration of version before using it..
         return 1   
      elseif cmd == "!help" then -- missing one '=' again
         user:SendData(Bot,"This is where the help text wud go, bt im not gonna waste my time :P") -- misspelled bot again
         return 1
      end
   end
end -- missing an end

//Skrollster


hehehe Skrollster :P

whats this

NEWCON == 1 :P

NEWCON = 1
Resistance is futile!

pHaTTy

QuoteOriginally posted by AlwaysConnected
QuoteOriginally posted by xokas
tkhx for the hint skrollster! gonna try to do better on the nexts times! tkhx a lot again

Weclome back Xokas aka ...... :)
and phatty go on with the lessons :)

its great :D


yep sure course i will m8, just installing linux for the next few hours, bloody drivers brrrrrrrrrrrrrr
Resistance is futile!

xokas

Phatty move ya phatty ass! c'mon! ehehehhe
just kidding

pHaTTy

QuoteOriginally posted by xokas
Phatty move ya phatty ass! c'mon! ehehehhe
just kidding

You cheeky tw@ :P

nah have liux to install, seems bill wants to be a tw@ iand i dont like windows, so fk it, goodbye windows ehehehehe
Resistance is futile!

raz

yes phatty so whens the next lesson coming i am ready for this time i was in a hurry last time cuz i had 2 go 2 my otha house. put lesson 4 on. i am waiting for it.

Skrollster

QuoteOriginally posted by (uk-kingdom)pH?tt?
hehehe Skrollster :P

whats this

NEWCON == 1 :P

NEWCON = 1

i still corrected more buggs then you knew where there :P

pHaTTy

Resistance is futile!

Skrollster

this is your fix:

----this is fine
Bot = "Keiko" 
NEWCON = 1 

function Main() 
	frmHub:RegBot(Bot) 
end 

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

function NewUserConnected(user) 
	if NEWCON==1 then  -- this needed to equal something
		user:SendData (Bot,"A User has connected") --bot name/not important
	else 
	end 
end -- missing an end

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

function OpConnected(user)  -- missing user
	if user.iprofile==0 then --the user profile for the profiles.dat file
		user:SendData(Bot,"Hello " ..user.sName.. " How are you") --cap sensitive for senddata
		return 1 
	else 
		SendToAll("A Op has entered") 
	end 
end --another 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 == "!version" then 
			user:SendData(Bot,"This bot is Learn to write a bot version: "..version) 
			return 1 
		elseif cmd == "!help" then 
			user:SendData(Bot,"This is where the help text would go, but im not gonna waste my time :P") 
			return 1 
		end 
	end 
end 
end

and this is mine:

Bot = "(Keiko)" -- missing "" to show that it is a string
NEWCON = 1

Main()
	frmHub:RegBot(Bot) -- spelling misstake on Bot
end

function NewUserConnected(CurUser)
	if NEWCON == 1 then -- use dubble equal signs then compareing
	user:SendData ("A User has connected") -- missed a " at the end of the text string
	else
	end
end -- missing end

function OpConnected()
	if user.iProfile == 0 then -- need duble '=' again and iProfile is case sensitive
		user:SendData(Bot,"Hello..user.sName..How are you") --Case sensitive function call + missing ')' in the end
		return 1
	else
		SendToAll(Bot,"A Op has entered") -- function name senttoall ned to be SendToAll, case sensitive
	end
end -- missing end

function Data Arrival(CurUser,data)
	if strsub(data, 1, 1) == "<" then
		data=strsub(data,1,strlen(data)-1)
		s,e,cmd = strfind(data,"%b<>%s+(%S+)") -- regular exp. wasn't used correctly and missing cmd variable

		if cmd == "!version" then -- missing one '=' again
			user:SendData(Bot,"This bot is Learn to write a bot version: "..version) --misspelled bot again and missing a declaration of version before using it..
			return 1	
		elseif cmd == "!help" then -- missing one '=' again
			user:SendData(Bot,"This is where the help text wud go, bt im not gonna waste my time :P") -- misspelled bot again
			return 1
		end
	end
end -- missing an end

you have one end too much, haven't declared version, using iprofile instead of iProfile.. probably more, but i don't have time..

raz

so when is the next lesson coming. put it up 2day  :D

pHaTTy

well i have an excuse, im tired, not slept in 4 days agen brrrrrrrrrrrrrrrrr, my big 2 day sleep coming up lol
Resistance is futile!

Optimus

mmm, testing this bot and still giving errorssss

gone give a update

btw,

function NewUserConnected(CurUser)  --// mmm (CurUser)

user:SendData ("A User has connected") --// mm (user)

---- some 1 forgot the part (function)

Main()
must be
function Main()

---- And a other 1

function Data Arrival(user,data)
must be
function DataArrival(user,data)

---- you are asking for a version?

user:SendData(Bot,"This bot is Learn to write a bot version: "..version)

Syntax Error: attempt to concat global `version' (a nil value)

so there needs to be something like: version = "0.3"

----- Last 1, function OpConnected()    -    must be function OpConnected(user)

bla bla  :D

Optimus

New try....


Bot = "(Keiko)"

version = "0.3"
NEWCON = 1

function Main()
   frmHub:RegBot(Bot)
end

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

function OpConnected(user)
   if user.iProfile == 0 then
      user:SendData(Bot,"Hello Master "..user.sName.." How are you")
      return 1
   else
      SendToAll(Bot,"A Op has entered")
   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 == "!version" then
         user:SendData(Bot,"This bot is Learn to write a bot version: "..version)
         return 1   
      elseif cmd == "!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

SMF spam blocked by CleanTalk