Trying to make a Talkbot....
 

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

Trying to make a Talkbot....

Started by Madman, 20 April, 2004, 06:23:17

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Madman

Hi, this is my first try to make a bot...I never made a script before =)
Just doing to this bot beacuse, to practise lua =)

What the script does...
write hi, and the  bot answers...

The problem...
When somebody writes hi, nobody see that..

What i want is that it should look like this
[06:14] hi
[06:15] Hi how are you?

But it only show =(
[06:15] Hi how are you?

So what should i change so everybody see the command hi?

And how do i make a or function, so it responds "Hi how are you?" on these words, Hi, Hello, and Hej

--// Test of TalkBot made of Madman

Bot = "TalkBot"

--// This function is fired at the serving start
function Main()
	frmHub:RegBot(Bot)
end

--// This function is fired when a new user finishes the login
function NewUserConnected(curUser)
	SendToAll(Bot, "The User "..curUser.sName.." has connected to the hub")
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 == "hi" then
user:SendData(Bot,"Hi how are you?")
return 1
end
end
end

Hope you guys understand =)
Well now i am of to work...
And yeah.. dont post a whole, script, just post the changes, so i can learn as mush as possibole =)
Thanks
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

kepp

QuoteOriginally posted by madman
Hi, this is my first try to make a bot...I never made a script before =)
Just doing to this bot beacuse, to practise lua =)

What the script does...
write hi, and the  bot answers...

The problem...
When somebody writes hi, nobody see that..

What i want is that it should look like this
[06:14] hi
[06:15] Hi how are you?

But it only show =(
[06:15] Hi how are you?

So what should i change so everybody see the command hi?

And how do i make a or function, so it responds "Hi how are you?" on these words, Hi, Hello, and Hej

--// Test of TalkBot made of Madman

Bot = "TalkBot"

--// This function is fired at the serving start
function Main()
	frmHub:RegBot(Bot)
end

--// This function is fired when a new user finishes the login
function NewUserConnected(curUser)
	SendToAll(Bot, "The User "..curUser.sName.." has connected to the hub")
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 == "hi" then
user:SendData(Bot,"Hi how are you?")
return 1
end
end
end

Hope you guys understand =)
Well now i am of to work...
And yeah.. dont post a whole, script, just post the changes, so i can learn as mush as possibole =)
Thanks

Hey madMan

You see this line "user:SendData(Bot,"Hi how are you?")"

and compare it to "SendToAll(Bot, "The User "..curUser.sName.." has connected to the hub")
" which is right by the way!!
Guarding    

Madman

#2
Thanks kepp, i changed to send to all, but that did not work, so i changed the return 1 to return 0, so now it works...

Now i just need to make some kind of an or function..
so it answer with the same answer, when a user writes hi, hello or hej...
But i have no idea to do that.. but hopefully i will find out =)

*edit*
whoo, i got it working =)

No or function... but it works :p
catch ya l8r =)
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

SMF spam blocked by CleanTalk