HOW-TO : Write your own Bot = Lesson 3
 

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

Lesson 3 ;)
Blocking the inbuilt functions,
Blocking the functions is using the data arrival as the data is arriving
example

function DataArrival(user,data)
   if (strfind(data, "$Kick")) then
   return 1
   end
end


the above will block kick, but remember it will on block the inbuilt right click
blocking a scripted kick is alot different, anyways, try and stop ban by yourself ;)
hint, it can be accomplished by blocking !ban


Start Learning now.......;)
Ok i have wrote a little task, i am gonna write a script then brake it so it doesnt work...
Then i want you to try fix it and post back, i will make it simple(only newbies please) ;)

Bot = Keiko

Main()
frmHub:RegBotName()
end

function NewUserConnected()
SendToAll ("A User has connected)
end

function OpConnected()
sendtoall("A Op has entered")
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+)")

	if cmd == !version then
			user:SendData(Bot,"This bot is Learn to write a bot version: "..version)
			return 1	
		end
	end
end

Ok i have made lots of common mistakes (on purpose) :P
So now i wait for you to try and fix them and post back ;)
Also include the mistakes you have found and fixed, tell me how you realised the mistake and how fixed
Remember im here to help, so if you follow this you will be writing your own scripts in no time ;)

l8rr,,

-phatty


PS : If you are a good scripter, and dying to post back, send me as pm :P

heheehe
Resistance is futile!

raz

first mistake is u don't have a version. e.g. version = "0.2 by ".

Main()
frmHub:RegBotName()
end

the second is dat u can't start a script wid main u need 2 have function in front of it. e.g. functionMain(), and u can't have reg bot name because that won't know the name of the bot. so u will have 2 take "Name" off and put "bot" in brackets.e.g.


function Main()
frmHub:RegBot(Bot)
end

pHaTTy

yep thats it ur getting there, now for the rest, keep going :) wd

there is 2 more mistakes ;)
Resistance is futile!

Skrollster

A realy good example, i think i'll have to write a lesson later on, then it get more complex ( then i get my comp up and running that is, i guess it has got quite complex by then)

:)

pHaTTy

Resistance is futile!

servaks

Very nice...

/shipis
My hub is back! (yeeeeeey)

hub.servaks.com


pHaTTy

QuoteOriginally posted by servaks
Very nice...

/shipis

ahh but have you spotted the other 2 common mistakes ;)
Resistance is futile!

pHaTTy

ooops btw theres 3 more mistakes i forgot to say one lol ;)
Resistance is futile!

servaks

My hub is back! (yeeeeeey)

hub.servaks.com


xokas

The others mistakes are:

1->

function Data Arrival(CurUser,data)

the correct sintax is :


function DataArrival(CurUser,data)


2->

if cmd == !version then

the correct sintax is:

if cmd == "!version" then






i guess it's pretty those! i hope i haven't missed any



xokas over&out

pHaTTy

youve missed one more ;)
Resistance is futile!

raz

u r still missing out.

1)
function NewUserConnected()
SendToAll ("A User has connected)
end

u r missing user which should be in barackets after newuser connected.which should be
function NewUserConnected(user)

and then u r missing Bot which should be in brackets.
SendToAll(Bot,.  and den in the brackets u have a user  has connected which should end in brackets and also have  "..user.sName..",  2 show the name of the user.
this is what it should look like.

function NewUserConnected(user)
SendToAll(Bot,"Welcome our new guest "..user.sName..", enyot your stay")
end

pHaTTy

yep well done for the last fixe function ;)

more to coem on next lesson
Resistance is futile!

xokas

grrrr i have spoted that one but it missed me! maybe next time!

raz

the other 1 is in op connected in brackets u need user e.g. function OpConnected(user).
some of the letters in sendtoall have 2 be capital e.g. SendToAll.
and u need bot in bracketse.g. SendToAll(Bot,
it should all like something like this
function OpConnected(user)
SendToAll(Bot,"Welcome the op "..user.sName..", enjoy your stay")
end

shouldn't it be enjoy  not enjot.

pHaTTy

lol yep sure heheeh, well done
Resistance is futile!

raz

so when  r u posting up the next step 2 creating a bot. the thing is i wnat 2 advance my skills. at the moment i don't know nothing about the sciprts not a lot.so dats y i want 2 learn dem.

pHaTTy

ok for a continue on this lesson i will write a bigger one for to let the other keep up here we go, i will make more mistakes, and try hiding a few ;)

Bot = (Keiko)
NEWCON == 1

Main()
frmHub:RegBot(Bos)
end

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

function OpConnected()
if user.iprofile = 0 then
user:senddata(Bot"Hello..user.sName..How are you"
return 1
else
sendtoall("A Op has entered")
end

function Data Arrival(CurUser,data)
if strsub(data, 1, 1) == "<" then
	data=strsub(data,1,strlen(data)-1)
	s,e,= strfind(data,"%b<>%")

	if cmd = "!version" then
			user:SendData(Bos,"This bot is Learn to write a bot version: "..version)
		return 1	
	elseif cmd = "!help" then
			user:SendData(Bos,"This si where the help text wud go, bt im not gonna waste my time :P")
		return 1	


	end
end

ok theres at least 15-16 erros on this one, good luck ;)
Resistance is futile!

pHaTTy

btw, have a go, but paste the full thing with all the errors you spot fixed, and please use the [code ] brackets around the code please :o)
Resistance is futile!

raz

i have done it is it right can u have a look.i am sorry but i don't know how 2 do the code thing.


Bot = (Keiko)
version = "0.2 by phatty"
NEWCON = 1

function Main()
frmHub:RegBot(Bot)
end

function NewUserConnected(user)
if NEWCON then
SendToAll(Bot, "A User has connected")
end

function OpConnected(user)
user.iprofile =
SendData(Bot, "Hello..user.sName..How are you")
SendToAll(Bot, "The 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<>%")

   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
end

raz

have a look is it right. if it is just give another 1 dat didn't look dat hard.

xokas

i have this! if some mistake or error tell me so i can learn ! tkhx



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







i just haven't figured out that one:

function OpConnected()
if user.iprofile  then

pHaTTy

QuoteOriginally posted by raz
have a look is it right. if it is just give another 1 dat didn't look dat hard.

i can see 5 mistakes
Resistance is futile!

raz

wat is newcon? wat does it do?

xokas

grrrr one mistake! i missed this


version = "botversion"

SMF spam blocked by CleanTalk