feat(core): add basic listener to check for a chat command
TODO: authorization module Signed-off-by: zontreck <tarapiccari@gmail.com>
This commit is contained in:
parent
144d2ae9ed
commit
39865ec859
3 changed files with 42 additions and 1 deletions
|
@ -77,3 +77,13 @@ integer VersionNumberCompare(string sInput, string sCompare)
|
|||
/*
|
||||
END VERSION CODE
|
||||
*/
|
||||
|
||||
|
||||
string getDefaultPrefix() {
|
||||
string ret = "";
|
||||
string ownerName = llGetUsername(llGetOwner());
|
||||
|
||||
ret = llToLower(llGetSubString(ownerName, 0, 1));
|
||||
|
||||
return ret;
|
||||
}
|
|
@ -66,6 +66,8 @@ key g_kSession;
|
|||
string g_sBOM;
|
||||
|
||||
integer g_iLocked;
|
||||
integer g_iListenZero;
|
||||
string g_sPrefix;
|
||||
|
||||
|
||||
string UPDATER_SHIM = "NuUpdate Shim [AC]";
|
||||
|
|
|
@ -9,6 +9,8 @@ default
|
|||
state_entry()
|
||||
{
|
||||
LM(LINK_SIGNAL_CALLBACKS, OP_CALLBACK_CHECK_STATUS, EMPTY_JSON);
|
||||
|
||||
g_iListenZero = llListen(0, "", "", "");
|
||||
}
|
||||
|
||||
link_message(integer iSender, integer iNum, string sMsg, key kID)
|
||||
|
@ -36,6 +38,8 @@ default
|
|||
if(sNamespace == "global") {
|
||||
if(sKey == "locked") {
|
||||
g_iLocked = (integer)sVal;
|
||||
} else if(sKey == "prefix") {
|
||||
g_sPrefix = sVal;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -43,4 +47,29 @@ default
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
listen(integer iChannel, string sName, key kID, string sMsg)
|
||||
{
|
||||
if(g_sPrefix == "") {
|
||||
g_sPrefix = getDefaultPrefix();
|
||||
LM(LINK_SIGNAL_SETTINGS, OP_SETTINGS_WRITE, ["key", "global_prefix", "value", g_sPrefix]);
|
||||
}
|
||||
|
||||
integer iCommand =0;
|
||||
|
||||
if(llGetSubString(sMsg,1,2) == g_sPrefix && llGetSubString(sMsg, 0,0) == "*") {
|
||||
// Likely is a command
|
||||
// We prepend an asterisk to make sure a command is intended to be a command, and not normal text
|
||||
iCommand=1;
|
||||
} else if(llGetSubString(sMsg, 1,2) == "**" && llGetSubString(sMsg,0,0) == "*") {
|
||||
// Three stars is a wildcard
|
||||
|
||||
iCommand=1;
|
||||
}
|
||||
|
||||
if(!iCommand) return;
|
||||
|
||||
// TODO: Check user authorization
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue