PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: Caduceus on 06 January, 2005, 15:55:59

Title: Return answer from robocop-bot
Post by: Caduceus on 06 January, 2005, 15:55:59
Hi!

I'm looking for a way to notify users not to speak to the hubbot e.g. when they recieve a pop-up window from login or when they are warned.

I'm having a lot of n00b-users in my hub... and i sometimes see from the CMD screen in ptokax that they are replying/talking to the bot...  :rolleyes:

Anyone knows how?  ?(

Tnx! :)
Title:
Post by: [UK]Madman on 06 January, 2005, 16:29:54
This shud work....


sBot = "Name Bot Here"

function Main()
frmHub:RegBot(sBot) -- delete this if your using same name as another bot!
end

function DataArrival(Curuser,data)
data = strsub(data,1,strlen(data)-1)

s,e,sTo= strfind(data, "$TO:%s+(%S+)")           -- find out who the pm is to
     if not GetItemByName(sTo) then           -- this checks to see if the target of the PM is actually a proper user
          Curuser:SendPM(sBot, "Are you MAD?!? Your talking to an automated bot!!")
     end
end

Title:
Post by: Caduceus on 06 January, 2005, 16:47:29
Thanx for quick reply [UK]Madman,

There seems to be some problem tho:

Syntax error: bad argument #1 to `strfind' (string expected, got nil)
stack traceback:
   1:  function `strfind' [C]
   2:  function `DataArrival' at line 10 [file `..._0.330_15.25 (+RC9.0c)\scripts\talkingtobot.lua']

I'm sorry, i'm a complete n00b with lua... don't know the error...

Quote---
sBot = "[?Cerberus?]"

function Main()
-- frmHub:RegBot(sBot) -- delete this if your using same name as another bot!
end

function DataArrival(Curuser,data)
data = strsub(data,1,strlen(data)-1)

s,e,sTo= strfind(sData, "$TO:%s+(%S+)")           -- find out who the pm is to
     if not GetItemByName(sTo) then           -- this checks to see if the target of the PM is actually a proper user
          Curuser:SendPM(sBot, "Are you MAD?!? Your talking to yourself as "..sTo.." is only a bot!!")
     end
end
---
Title:
Post by: [UK]Madman on 06 January, 2005, 17:00:49
Apologies, first post ammended, I mistakenly used sData unstead of data for the strfind function.
Title:
Post by: Caduceus on 06 January, 2005, 17:08:43
Yes... it is better, but still a problem:

Syntax error: attempt to concat global `sTo' (a nil value)
stack traceback:
   1:  function `DataArrival' at line 12 [file `..._0.330_15.25 (+RC9.0c)\scripts\talkingtobot.lua']

QuotesBot = "[?Cerberus?]"

-- function Main()
-- frmHub:RegBot(sBot) -- delete this if your using same name as another bot!
-- end

function DataArrival(Curuser,data)
data = strsub(data,1,strlen(data)-1)

s,e,sTo= strfind(data, "$TO:%s+(%S+)")           -- find out who the pm is to
     if not GetItemByName(sTo) then           -- this checks to see if the target of the PM is actually a proper user
          Curuser:SendPM(sBot, "Are you MAD?!? Your talking to yourself as "..sTo.." is only a bot!!")
     end
end
Title:
Post by: [UK]Madman on 06 January, 2005, 17:20:53
Edited again, might get it right in a min ! lol
Title:
Post by: Caduceus on 06 January, 2005, 17:28:47
Yes! thanx [UK]Madman!

it now works... however (i know i am a pain in the behind)...

I get the message too when i talk in OpChat & VipChat...

is it possible to set the script so that it only gives the reply when spoken to the sBot?

Tnx again :)
Title:
Post by: [UK]Madman on 06 January, 2005, 17:33:51
OOppsss, forgot about that, knew it seemed to easy!!  I borrowed the code from another bot im writing that warns users there getting a bots filelist .. forgot you talk to OpChat and VipChat!!

replace
if not GetItemByName(sTo) then

with
if sTo == sBot then
Title:
Post by: Caduceus on 06 January, 2005, 17:49:08
hmmm... No errors, but now it gives no reply at all anymore  :( :

QuotesBot = "[?Cerberus?]"

-- function Main()
-- frmHub:RegBot(sBot) -- delete this if your using same name as another bot!
-- end

function DataArrival(Curuser,data)
data = strsub(data,1,strlen(data)-1)

s,e,sTo= strfind(data, "$TO:%s+(%S+)")           -- find out who the pm is to
     if sTo == sBot then
          Curuser:SendPM(sBot, "Are you MAD?!? Your talking to an automated bot!!")
     end
end
Title:
Post by: Caduceus on 06 January, 2005, 20:04:45
Does [UK]Madman or someone else have a solution to this?
Title:
Post by: [UK]Madman on 06 January, 2005, 20:11:36
Home from work and this is now tested and working fine :o)

sBot = "Bot Name"

-- function Main()
-- frmHub:RegBot(sBot) -- delete this if your using same name as another bot!
-- end

function DataArrival(Curuser,data)
data = strsub(data,1,strlen(data)-1)

s,e,sTo= strfind(data, "$To:%s+(%S+)") -- find out who the pm is to
if sTo == sBot then
Curuser:SendPM(sBot, "Are you MAD?!? Your trying to talk to "..sTo.." whos only a bot!!")
end
end

Was stupid mistake in the patern matching!
Title:
Post by: Caduceus on 06 January, 2005, 20:19:54
Thanx a load [UK]Madman!
Works pretty well this way!

:D

U made me very happy :) tnx again!  :D
Title:
Post by: [UK]Madman on 06 January, 2005, 20:25:52
Got there in the end . lol

Glad it works ok :o)