PtokaX forum

Development Section => HOW-TO's => HOW-TO requests => Topic started by: Mardeg on 05 November, 2006, 16:43:22

Title: Capturing kick reason from clientside kicks
Post by: Mardeg on 05 November, 2006, 16:43:22
From Changelog - 0.3.5.2:
QuoteFixed: Missing kick message when op kick user from inbuild client kick.
Anyone done this successfully with the latest PtokaX?
My code from previous versions just looked like this:

function KickArrival(user, Data)
_, _, kcom, knick = string.find(data,"(%S+)%s+(%S+)")
if GetItemByName(knick) then
local arg = GetItemByName(knick)
if (not arg.bRegistered) then arg:TimeBan(20)
elseif GetProfileName(arg.iProfile) == Reg then
SendPmToNick(arg.sName, user.sName, "Client-based kick. Reason upcapturable")
elseif arg.iProfile <= user.iProfile then
SendPmToNick(user.sName,arg.sName, "Looks like that backfired on you. Only kick users with lower levels than yourself next time.")
user:Disconnect()
return 1
end
arg:Disconnect()
return 1
end


possibly as easy as changing one line? (no-one volunteered for testing):
_, _, kcom, knick, kreason = string.find(data,"(%S+)%s+(%S+)%s+(%.*)")
Title: Re: Capturing kick reason from clientside kicks
Post by: Herodes on 05 November, 2006, 17:00:53
You could always do :
--- Incoming string: $Kick SomeNick for being a very bad boy....|
--- the regular expression:
local nick, reason = (data:sub(1 , -2)):match("^%$Kick%s(%S+)%s(.*)$")
--- simplified...
local nick,reason = string.match( string.sub(data, 1, -2), "^%$Kick%s(%S+)%s(.*)$" )

I hope this gives you some hints :)
Title: Re: Capturing kick reason from clientside kicks
Post by: bastya_elvtars on 06 November, 2006, 16:39:05
Umm, the order of the clientkick is fixed. You can probably use a coroutine.