PtokaX forum

Development Section => HOW-TO's => Topic started by: Corayzon on 12 May, 2004, 05:33:07

Title: How To :: Handle Banned Users and Resend Banned Messages
Post by: Corayzon on 12 May, 2004, 05:33:07
heya guys...just figured something good...dont know y i didnt pick up on it earlier but...

u know when a user is banned from a hub they get the default ban message '<-cSlave-> Your nick is banned!'...

well here is how to handle it so u can add your own ban messages and skip this one...


if strsub(data, 1, 13) == "$ValidateNick" then
if checkBanned(user.sName, user.sIP) then
local sReason = getBanReason(user.sName, user.sIP)
user:SendData(sBot, "*** you were banned from here because: " .. sReason or "none")
DisconnectByName(user.sName)
return 1
end
return
end

now this isnt a working example but im sure u get the flow...

checkBanned() checks the ban list for the username
getBanReason() gets the extra text added to the ban reason

-=NozaroK=-
Title:
Post by: kp on 12 May, 2004, 09:36:11
might be good for when having a small hub but nothing for big hubs would only use more memory, or if you read from file will always read from disc each time a user that is banned connects.
Title:
Post by: Corayzon on 12 May, 2004, 10:19:55
it also loops twice in this example but anways...

this doesnt work for ip bans due to ptokax seems to check the ban on socket_connect so if it matchs a ip, bang...but for nick bans it also check $ValNick so...

so cant get hold of the process for a ip ban even tring $key, the first thing a client might send...

so this class's it as quiet ineffective unless u want to bother basicly rewriting the perm banning system to accomindate...

one thing i would like to see though, is a empty server, that only has the socket events and the socket class with a main and exit function...

u could then write a application server for anything, i mainly think this cause i like working with lua...

anyways, im lost :P
Title:
Post by: kp on 12 May, 2004, 13:02:22
good to know that ptokax disconnects on socket.
A dc server with minimum of function and maximum of script support, sounds nice indeed.

If you stop using ptokax functions, then actually it only, also checks the $MyINFO if the the first letters from the nick correspond to the curUser.sName and the stats, so it is almost only the server.

As you like LUA a lot you should also check out BCDC++
it is a client that supports lua 5 scripts.
Title:
Post by: Corayzon on 12 May, 2004, 13:57:58
ive heard about bcdc++ but havnt really come across anything to complex about it...i guess i should just download it and see...

anyways...i came across this the other day and have been just writing up mi own little server (but vb syntax suks for handling strings!)...and its helped me alot with when i should be checking what client info and where...

and as u said...checking the info string username matchs the user object username is a good idea =]

http://wza.digitalbrains.com/DC/doc/Command_Types_(client_to_server).html