MyINFO modification from Lua API
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

MyINFO modification from Lua API

Started by PPK, 06 August, 2011, 23:42:11

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

PPK

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.
"Most of you are familiar with the virtues of a programmer. There are three, of course: laziness, impatience, and hubris." - Larry Wall

KillerInstinct


pHaTTy

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
Resistance is futile!

PPK

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  ::)
"Most of you are familiar with the virtues of a programmer. There are three, of course: laziness, impatience, and hubris." - Larry Wall

bastya_elvtars

Everything could have been anything else and it would have just as much meaning.

WAJIM

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

Dessamator

Excellent idea, would be useful for many MyInfo related scripts, which currently fight with the data the server sends them.
Ignorance is Bliss.

Hamachi

Nice ide what version will it be add ?

PPK

"Most of you are familiar with the virtues of a programmer. There are three, of course: laziness, impatience, and hubris." - Larry Wall

PPK

"Most of you are familiar with the virtues of a programmer. There are three, of course: laziness, impatience, and hubris." - Larry Wall

SMF spam blocked by CleanTalk