In PtokaX Lua API is MyINFO processing not blockable. This thing don't allow to change user MyINFO without high upload usage caused by manual MyINFO broadcasting from Lua script. I want to change that, so i have proposal how it should be done. Of course as easy way looks to make MyINFO blockable, but that don't give scipt way how to send changed MyINFO in smart (and cpu/memory friendly) way...
So here is my proposal. API will get some call that will allow changes to MyINFO and PtokaX will use them on next MyINFO broadcast.
It can be something simple like Core.SetUserValue(tUser, nValueId, sNewValue) to allow change of description, tag, connection, email and maybe sharesize.
Example script adding country code to user description can looks like this:
function MyINFOArrival(tUser, sData)
sCountryCode = IP2Country.GetCountryCode(tUser.sIP)
if sCountryCode ~= nil then
Core.SetUserValue(tUser, 2, sCountryCode.." "..Core.GetUserValue(tUser, 2)) -- 2 is sDescription
end
end
This should be good enough, but maybe little improvement should be done.. so maybe improve previous call like Core.SetUserValue(tUser, nValueId, sNewFullMyinfoValue, sNewStripedMyInfoValue, bPermanent). We have here 2 more call params for good reason. This way script can handle what will be shown in full MyINFO and what will be shown in striped MyINFO. And more, we get bPermanent to make changes permanent so we don't need to do changes everytime user sends new MyINFO.
So again here is example script adding country code to user description:
function UserConnected(tUser)
sCountryCode = IP2Country.GetCountryCode(tUser.sIP)
if sCountryCode ~= nil then
if SetMan.GetBool(13) then -- 13 is Strip user description
Core.SetUserValue(tUser, 2, sCountryCode.." "..Core.GetUserValue(tUser, 2), sCountryCode, true) -- 2 is sDescription
else
Core.SetUserValue(tUser, 2, sCountryCode.." "..Core.GetUserValue(tUser, 2), sCountryCode.." "..Core.GetUserValue(tUser, 2), true) -- 2 is sDescription
end
end
end
So now my example script will add country code to user description on login permanently, script don't need to process MyINFO everytime is new one received... 8)
Please post opinions below.
sounds like a plan ;)
Quote from: PPK on 06 August, 2011, 23:42:11
So now my example script will add country code to user description on login permanently, script don't need to process MyINFO everytime is new one received... 8)
but if a user changes his/her description or tag whilst already logged in, it would be a useful feature since it could be used to modify badwords and so on, however what you would need to do is keep a copy of the original *unmodified* myinfo string, then when ptokax receives a new myinfo from the user, if it is the same as the original -> do nothing, if it is different to the original -> re-call lua function.
-pHaTTy
Quote from: pH?tt? on 08 August, 2011, 14:14:05
however what you would need to do is keep a copy of the original *unmodified* myinfo string, then when ptokax receives a new myinfo from the user, if it is the same as the original -> do nothing, if it is different to the original -> re-call lua function.
PtokaX already doing that, and it will not change ::)
Nice idea.
Great idea, PPK! ;D
Now I do the postponed sending $MyINFO (~100 ms after MyINFOArrival/UserConnected) myinfo for correction of the information on users. It adds superfluous commands. Core. SetUserValue - excellent replacement with mine hacks! :D
Excellent idea, would be useful for many MyInfo related scripts, which currently fight with the data the server sends them.
Nice ide what version will it be add ?
In release after 0.4.2.0 :P
Added http://forum.ptokax.org/index.php?topic=8857.0 :P