HOW-TO : Write your own Bot = Lesson 3 - Page 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 2 Guests are viewing this topic.

klownietklowniet

In some programming languages one '=' is enough for an if test... *offtopic comment*
[ > DC - UniteD < ]


raz

so when is write you own bot = lesson 4 coming. been waiting 4 a little while now. ?(

pHaTTy

When i het some time, might be today, still sorting linux, its been a tw@ been told my modem not got the linux drivers for it out, so im getting someone to write some now, shud be done soon i hope :o)

Then i will start with lesson 4, as i got some plans for it ;)
Resistance is futile!

pHaTTy

btw heres a little extra

Bot = "Keiko" 

version = "0.3" 
NEWCON = 1 
prefix = "!"

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 == prefix.."version" then 
user:SendData(Bot,"This bot is Learn to write a bot version: "..version) 
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

but ill explain more on next lesson ;)

not so tired now :o)
Resistance is futile!

raz

i wish it gets done quickly, so i can create my own bot sooon. :P

SaintSinner

#56

Bot 
"Keiko"
version "voltron"

function Main()
frmHub:RegBot(Bot)
end

function NewUserConnected(user)
SendToAll(Bot"A User has connected, welcome "..user.sName.." stand up and cheer.")
end

function OpConnected(user)
SendToAll(Bot,"Master of all that is peersharing "..user.sName.." has entered the hub.")
end

function DataArrival(user,data
if 
strsub(data11) == "<" 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 

end 
end 
end 



ok i got some of it right off hand but the protions i was having problems with are
this is what i used:

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

end 
end 
end 


this was your nonworkingone:

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

	
	
end
	




i added the "" to the version

i cant see the diffrence is the two functions.
can you point it out.
   


pHaTTy

Resistance is futile!

SaintSinner

QuoteOriginally posted by (uk-kingdom)pH?tt?
Look at the ends



AAHHHHH
how could i have missed that
   


SaintSinner

what is the diffrence of
=
and
==

and when would you use them.
   


pHaTTy

user = 2


if user == 1 then
Resistance is futile!

SaintSinner

ok guys i know im behind
i was left back in prekindergarden.....heeheee :D  :D

but i cannot get
!version or
!help to show what is in the script
!version show errors and !help
shows the ptokax inbuilt commands
with error
"Syntax Error: attempt to index global `user' (a nil value)"
 so the return1
is not working and i tried it with my script and
skrollster's

function DataArrival(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	
		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
   


NightLitch

your problem lies here:

function DataArrival(CurUser ,data)
(by the way this line is wrong, it should be:

function DataArrival(curUser ,data)

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

user :SendData(Bot,"This is where the help text wud go, bt im not gonna waste my time :P")

looking at various scripts you notice some use user
and some curUser...

in your case, you have in your function curUser
so all user Data sending should be entered with (curUser not user try that...

/NightLitch
//NL

SaintSinner

@NightLitch
yup that got it working
thanks

so for any new funtion
if you define the function with curUser
every string has to have curUser?
if yes
then curUser and user are basically the same thing?
except when in a function.
   


pHaTTy

ok for example if i make

function DataArrival(user,data)

then its

user:SendPM

if i made

function DataArrival(Num,Nuts)

then it wud be

Num:SendPM

hope that helps ;)
Resistance is futile!

SaintSinner

i dont think i ever caught what
NEWCON =1
means, im guessing if stands for new connection,
but why have that when you already have a
function for:
function NewUserConnected(user)
   


pHaTTy

NEWCON = 1 is not a function is a variable

look for if NEWCON == 1 then

then watch what it does, then try change NEWCON = 1 to NEWCON = 0 also check the first ever lesson it is explained somewhere along the lines.

you must be skipping because tere is alot you dont understand, and asking questions on things that is in the last lessons ;)

go back and read slowly and carefully ;)

-phatty
Resistance is futile!

SaintSinner

QuoteOriginally posted by (uk-kingdom)pH?tt?
NEWCON = 1 is not a function is a variable

look for if NEWCON == 1 then

then watch what it does, then try change NEWCON = 1 to NEWCON = 0 also check the first ever lesson it is explained somewhere along the lines.

you must be skipping because tere is alot you dont understand, and asking questions on things that is in the last lessons ;)

go back and read slowly and carefully ;)

-phatty



lol i am reading slowly and carefully
and i go over the lessons over and over and over
again "..user.sName.." has the time to learn this
while i am at work.
the there is no explanation of what NEWCON is
it only shows up on one of the bots in lesson three
and then some butting heads between you and skrollster.

I enjoy your lessons and i appreciate that you do this, you really tailor it for nobbies like myself but you have to be prepared for questions. :D  :]  :))
i just dont want to write the code
i want to understand what it does?
   


pHaTTy

hahah ok, :o)

i will make a lesson of it, lesson 7 will be on them ;)
Resistance is futile!

Tarokkk

--Welcomes
   -- Users
   welcome_users = "Hi ?s ?rezd j?l magad"
   -- OPs
   welcome_op_1 = ""
   welcome_op_2 = ""
   welcome_op_3 = ""
   welcome_op_4 = ""
   welcome_op_5 = ""


function NewUserConnected(user)
if Connectusermess == 1 then
SendToAll(Bot, user.sName..""..welcome_users)
end
end
----------------
if ConnectOpmess == 1 then
   function OpConnected(user)
   Pillock = GetProfileName(user.iProfile)
        MessOp = random(5)
        SendToAll(Bot,_________) --<--This is the qestion  ?( ... What I have to write there ? welcome_op_(??? this is the number Mess OP)
        end
   end
end


----Thx

SMF spam blocked by CleanTalk