diff options
| -rw-r--r-- | src/kvirc/kvs/KviKvsCoreFunctions.cpp | 2 | ||||
| -rw-r--r-- | src/kvirc/kvs/KviKvsCoreFunctions.h | 2 | ||||
| -rw-r--r-- | src/kvirc/kvs/KviKvsCoreFunctions_gl.cpp | 124 |
3 files changed, 127 insertions, 1 deletions
diff --git a/src/kvirc/kvs/KviKvsCoreFunctions.cpp b/src/kvirc/kvs/KviKvsCoreFunctions.cpp index 6e3cf9c64..6d21bc739 100644 --- a/src/kvirc/kvs/KviKvsCoreFunctions.cpp +++ b/src/kvirc/kvs/KviKvsCoreFunctions.cpp @@ -70,6 +70,7 @@ namespace KviKvsCoreFunctions _REGFNC("flatten",flatten) _REGFNC("fmtlink",fmtlink) // g_l + _REGFNC("gender",gender); _REGFNC("globals",globals); _REGFNC("hash",hash); // _REGFNC("inputText",inputText); @@ -81,6 +82,7 @@ namespace KviKvsCoreFunctions _REGFNC("iconName",iconName); _REGFNC("int",integer) _REGFNC("integer",integer) + _REGFNC("isBot",isBot) _REGFNC("isEmpty",isEmpty) _REGFNC("isEventEnabled",isEventEnabled) _REGFNC("isMainWindowActive",isMainWindowActive) diff --git a/src/kvirc/kvs/KviKvsCoreFunctions.h b/src/kvirc/kvs/KviKvsCoreFunctions.h index 606869efe..f73e9c73d 100644 --- a/src/kvirc/kvs/KviKvsCoreFunctions.h +++ b/src/kvirc/kvs/KviKvsCoreFunctions.h @@ -76,6 +76,7 @@ namespace KviKvsCoreFunctions KVSCF(flatten); KVSCF(fmtlink); // g_l + KVSCF(gender); KVSCF(globals); KVSCF(hash); KVSCF(inputText); @@ -86,6 +87,7 @@ namespace KviKvsCoreFunctions KVSCF(iconName); KVSCF(integer); KVSCF(isAnyConsoleConnected); + KVSCF(isBot); KVSCF(isEmpty); KVSCF(isEventEnabled); KVSCF(isNumeric); diff --git a/src/kvirc/kvs/KviKvsCoreFunctions_gl.cpp b/src/kvirc/kvs/KviKvsCoreFunctions_gl.cpp index 1ec8e12f0..0dcb5393f 100644 --- a/src/kvirc/kvs/KviKvsCoreFunctions_gl.cpp +++ b/src/kvirc/kvs/KviKvsCoreFunctions_gl.cpp @@ -40,11 +40,75 @@ #include "KviKvsEventManager.h" #include "KviKvsEventHandler.h" #include "KviLagMeter.h" - +#include "KviIrcUserEntry.h" #include <QRegExp> namespace KviKvsCoreFunctions { + +///////////////////////////////////////////////////////////////////////////////////////// + +/* + @doc: gender + @type: + function + @title: + $gender + @short: + Returns the gender of the specified user + @syntax: + <string> $gender(<nickname:string>) + @description: + Returns the gender, or 'unknown' if not setted from remote user, of the specified IRC user IF it is known.[br] + The gender is known if [fnc]$isWellKnown[/fnc] returns 1.[br] + The gender is generally known if the user is on a channel with you + or has an open query with you.[br] + Detailed explaination:[br] + KVIrc has an internal database of users that are currently + visible by *this client*: this includes users on open channels + and queries.[br] The other IRC users are NOT in the database: + this means that KVIrc knows NOTHING about them and can't return + any information immediately. In this case this function will return + an EMPTY string.[br] + If a user is in the database, at least his nickname is known.[br] + The username and hostname are known only if the server provides that information + spontaneously or after a KVIrc request.[br] + KVIrc requests user information for all the users in open queries + and channels. This information takes some time to be retrieved, + in this interval of time KVIrc knows only the user's nickname. + This function will return the string "*" in this case.[br] + @seealso: + [fnc]$isWellKnown[/fnc], [fnc]$hostname[/fnc], [fnc]$realname[/fnc], [cmd]$username[/cmd] +*/ + +KVSCF(gender) +{ + QString szNick; + + KVSCF_PARAMETERS_BEGIN + KVSCF_PARAMETER("nick",KVS_PT_NONEMPTYSTRING,0,szNick) + KVSCF_PARAMETERS_END + + if(KVSCF_pContext->window()->console()) + { + if(KVSCF_pContext->window()->console()->isConnected()) + { + KviIrcUserEntry * e = KVSCF_pContext->window()->connection()->userDataBase()->find(szNick); + if(e) + { + QString szGender; + if(e->gender()==KviIrcUserEntry::Male) szGender = "male"; + else if(e->gender()==KviIrcUserEntry::Female) szGender = "female"; + else szGender = "unknown"; + KVSCF_pRetBuffer->setString(szGender); + return true; + } + } + } + + KVSCF_pRetBuffer->setNothing(); + return true; +} /////////////////////////////////////////////////////////////////////////////////////////////// /* @@ -445,6 +509,64 @@ namespace KviKvsCoreFunctions return true; } + ///////////////////////////////////////////////////////////////////////////////////////// + + /* + @doc: isbot + @type: + function + @title: + $isbot + @short: + Returns 1 if the user is a bot. Otherwise return 0. + @syntax: + <string> $isbot(<nickname:string>) + @description: + Returns 1 if the user is a bot. Otherwise return 0.[br] + This info is known if [fnc]$isWellKnown[/fnc] returns 1.[br] + This info is generally known if the user is on a channel with you + or has an open query with you.[br] + Detailed explaination:[br] + KVIrc has an internal database of users that are currently + visible by *this client*: this includes users on open channels + and queries.[br] The other IRC users are NOT in the database: + this means that KVIrc knows NOTHING about them and can't return + any information immediately. In this case this function will return + an EMPTY string.[br] + If a user is in the database, at least his nickname is known.[br] + The username and hostname are known only if the server provides that information + spontaneously or after a KVIrc request.[br] + KVIrc requests user information for all the users in open queries + and channels. This information takes some time to be retrieved, + in this interval of time KVIrc knows only the user's nickname. + This function will return the string "*" in this case.[br] + @seealso: + [fnc]$isWellKnown[/fnc], [fnc]$hostname[/fnc], [fnc]$realname[/fnc], [cmd]$username[/cmd] + */ + + KVSCF(isBot) + { + QString szNick; + + KVSCF_PARAMETERS_BEGIN + KVSCF_PARAMETER("nick",KVS_PT_NONEMPTYSTRING,0,szNick) + KVSCF_PARAMETERS_END + + if(KVSCF_pContext->window()->console()) + { + if(KVSCF_pContext->window()->console()->isConnected()) + { + KviIrcUserEntry * e = KVSCF_pContext->window()->connection()->userDataBase()->find(szNick); + if(e) + { + KVSCF_pRetBuffer->setBoolean(e->isBot()); + return true; + } + } + } + KVSCF_pRetBuffer->setNothing(); + return true; + } /////////////////////////////////////////////////////////////////////////////////////////////// /* |
