PtokaX forum

Archive => Archived 5.1 boards => Request for scripts => Topic started by: BoyKind on 25 July, 2006, 20:28:14

Title: Skip word " hub "
Post by: BoyKind on 25 July, 2006, 20:28:14
I want a script that when a unreg user types the word " hub " , to skip the whole message, if it's possible :) Just like in an advertising bot, but I don't want the bot to kick the user that says "hub" in my HUB(MC and PM), I want the bot to skip the message silently ... Thx
Title: Re: Skip word " hub "
Post by: Madman on 26 July, 2006, 13:04:12

-- Say Hub
-- Made by Madman, 06-07-26
-- Requested by BoyKind

function ChatArrival(curUser, data)
local data = string.sub(data, 1, -2)
if not curUser.bRegistered then
if string.find(data, "hub") then
return 1
end
end
end

ToArrival = ChatArrival


It don't get any more silent then this, not even the one that types hub will kno it's blocked...
Title: Re: Skip word " hub "
Post by: Herodes on 26 July, 2006, 16:59:56
-- Say "What"?
-- Made by Madman, 06-07-26
--- optimised by Herodes
-- Requested by BoyKind

local wordie = " hub "
function ChatArrival(user, data)
return ((string.find(data, wordie) and (not user.bRegistered))
end

ToArrival = ChatArrival
Hmm .. just some inspirational conceptual optimisation .. It could be not working ..
Title: Re: Skip word " hub "
Post by: jiten on 26 July, 2006, 17:16:03
As there's no need to string.sub 'data', here's part of the code:

ChatArrival = function(user, data)
if string.find(data, "hub") and not user.bRegistered then
return 1
end
end
Title: Re: Skip word " hub "
Post by: bastya_elvtars on 26 July, 2006, 17:19:21
If you don't string.sub, better beware of the | et al., and it's also wise to convert to lowercase:

ChatArrival = function(user, data)
  if string.find(string.lower(data), "hub",1,true) and not user.bRegistered then
    return 1
  end
end
Title: Re: Skip word " hub "
Post by: jiten on 26 July, 2006, 17:27:15
Quote from: bastya_elvtars on 26 July, 2006, 17:19:21
If you don't string.sub, better beware of the | et al.

The endpipe won't affect the string.find, as long as we don't try to parse the vars.

Quote, and it's also wise to convert to lowercase:

True, though it was just an example :P
Title: Re: Skip word " hub "
Post by: BoyKind on 26 July, 2006, 17:33:37
Thanks Madman :D
Title: Re: Skip word " hub "
Post by: bastya_elvtars on 26 July, 2006, 17:44:47
Quote from: jiten on 26 July, 2006, 17:27:15
The endpipe won't affect the string.find, as long as we don't try to parse the vars.

Yeah, you're right, I simply like failsafe methods. :-)
Title: Re: Skip word " hub "
Post by: Markitos on 26 July, 2006, 20:34:10
Quote from: Herodes on 26 July, 2006, 16:59:56
just some inspirational conceptual optimisation .. It could be not working ..
It isn't =)...Correct code above
-- Say "What"?
-- Made by Madman, 06-07-26
--- optimised by Herodes
-- Requested by BoyKind

local wordie = " hub"
function ChatArrival(user, data)
return ((string.find(data, wordie)) and (not user.bRegistered)),1
end

ToArrival = ChatArrival

Title: Re: Skip word " hub "
Post by: Madman on 26 July, 2006, 23:27:19

-- Say Hub
-- Made by Madman, 06-07-26
-- Requested by BoyKind
-- Optimized, useing ideas by some weirdos on the forum ;)

function ChatArrival(curUser, data)
if string.find(string.lower(data), "hub") and not curUser.bRegistered then
return 1
end
end

ToArrival = ChatArrival


Here you are gone for a few hours.. and ppl pops more ideas then what a popcorn bag *pops*.

BoyKind, my first post only blocks hub and not HUB, this blocks both =)
Title: Re: Skip word " hub "
Post by: bastya_elvtars on 26 July, 2006, 23:30:05
Quote from: Madman on 26 July, 2006, 23:27:19
-- Optimized, useing ideas by some weirdos on the forum ;)

Hehehehehe... :-D
Title: Re: Skip word " hub "
Post by: BoyKind on 27 July, 2006, 06:40:44
:) thx
Title: Re: Skip word " hub "
Post by: Herodes on 27 July, 2006, 07:32:54
hehe nice ending to a nice story :)
Title: Re: Skip word " hub "
Post by: Markitos on 27 July, 2006, 08:35:42
indeed...