Adds discord relay plugin
This commit is contained in:
parent
6ad891e5ac
commit
5674233bf8
5 changed files with 65 additions and 46 deletions
|
@ -1,41 +0,0 @@
|
|||
#include "Common.lsl"
|
||||
|
||||
|
||||
|
||||
SendUserMessage(string sMessage, integer iError) {
|
||||
integer iUseTitle=1;
|
||||
if(llStringLength(sMessage) > 255) iUseTitle=0;
|
||||
|
||||
string sJson = llList2Json(JSON_OBJECT, [
|
||||
"content", JSON_NULL,
|
||||
"attachments", llList2Json(JSON_ARRAY, []),
|
||||
"username", "Farm Servers",
|
||||
"avatar_url", "https://media.discordapp.net/attachments/836451385733021706/1238977979141591081/second-life-icon-25-3810850605.png?ex=66413fa9&is=663fee29&hm=f92e5dceb842992fcc56cfde3dce306da91412eb12f3ca8ebfab4ed2c163115a&=&format=webp&quality=lossless&width=500&height=500",
|
||||
"embeds", llList2Json(JSON_ARRAY, [
|
||||
llList2Json(JSON_OBJECT, [
|
||||
"footer", llList2Json(JSON_OBJECT, [
|
||||
"text", "Aria's Creations Discord Relay v" + VERSION
|
||||
]),
|
||||
"timestamp", llGetTimestamp()
|
||||
])
|
||||
])
|
||||
]);
|
||||
|
||||
if(iUseTitle)
|
||||
sJson = llJsonSetValue(sJson, ["embeds", 0, "title"], sMessage);
|
||||
else sJson = llJsonSetValue(sJson, ["embeds", 0, "description"], sMessage);
|
||||
|
||||
llHTTPRequest(g_sNotifyURL, [HTTP_METHOD, "POST", HTTP_MIMETYPE, "application/json"], sJson);
|
||||
|
||||
llSay(0, "Message Sent!");
|
||||
}
|
||||
|
||||
|
||||
|
||||
default
|
||||
{
|
||||
state_entry()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
|
@ -3,6 +3,10 @@
|
|||
string API_SERVER;
|
||||
integer g_iActive = 1;
|
||||
integer g_iRegistered=0;
|
||||
integer g_iError=0;
|
||||
string g_kPayload;
|
||||
string g_sItem;
|
||||
|
||||
|
||||
default {
|
||||
state_entry() {
|
||||
|
@ -74,16 +78,31 @@ default {
|
|||
// Deliver if we have the item
|
||||
if(llGetInventoryType(sRequest) != INVENTORY_NONE) {
|
||||
llGiveInventory(sID, sRequest);
|
||||
llWhisper(999, sPayload);
|
||||
g_iError=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Log this as an error in delivery
|
||||
llWhisper(998, sPayload);
|
||||
g_iError=1;
|
||||
}
|
||||
|
||||
g_sItem = sRequest;
|
||||
|
||||
g_kPayload = llRequestUsername(sID);
|
||||
|
||||
llSleep(0.25);
|
||||
llMessageLinked(LINK_SET, 0, "", "");
|
||||
}
|
||||
}
|
||||
|
||||
dataserver(key kID, string sData) {
|
||||
if(kID == g_kPayload) {
|
||||
llSay(0x9CB9, llList2Json(JSON_OBJECT, [
|
||||
"user", sData,
|
||||
"msg", "Delivery of item '" + g_sItem + "'",
|
||||
"author", "Relay",
|
||||
"title", "Farm Delivery Server"
|
||||
]));
|
||||
}
|
||||
}
|
||||
}
|
28
LSL/raw/plugin_discord.lsl
Normal file
28
LSL/raw/plugin_discord.lsl
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
Discord Relay Plugin
|
||||
*/
|
||||
|
||||
#include "Common.lsl"
|
||||
|
||||
default
|
||||
{
|
||||
state_entry()
|
||||
{
|
||||
llListen(0x9CB9, "", "", "");
|
||||
}
|
||||
|
||||
listen(integer c,string n,key i, string m) {
|
||||
if(llGetOwnerKey(i) == llGetOwner()) {
|
||||
llMessageLinked(LINK_SET, 888, llList2Json(JSON_OBJECT, [
|
||||
"system", FALSE,
|
||||
"message", llList2Json(JSON_OBJECT, [
|
||||
"username", llJsonGetValue(m, ["user"]),
|
||||
"content", llJsonGetValue(m, ["msg"]),
|
||||
"color", 2067276,
|
||||
"author", llJsonGetValue(m, ["author"]),
|
||||
"title", llJsonGetValue(m,["title"])
|
||||
])
|
||||
]), NULL_KEY);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -17,6 +17,8 @@ string API_SERVER;
|
|||
integer g_iTree;
|
||||
integer g_iTreeStump;
|
||||
integer g_iSapling;
|
||||
integer g_iRequestedSapling;
|
||||
integer g_iRezzedObject;
|
||||
|
||||
vector g_vInitialSapling = <0.59996, 0.56265, 1.01659>;
|
||||
vector g_vInitialTree = <0.77864, 0.90290, 1.38959>;
|
||||
|
@ -148,6 +150,13 @@ default
|
|||
string sJson = llList2String(lPar,1);
|
||||
g_sServerID = llJsonGetValue(sJson, ["id"]);
|
||||
requestProductForDelivery(SAPLING_NAME, g_kAv);
|
||||
llSleep(2);
|
||||
|
||||
g_iRequestedSapling=1;
|
||||
if(g_iRezzedObject){
|
||||
llRemoveInventory("Service Daemon [AC]");
|
||||
llRemoveInventory(llGetScriptName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -155,7 +164,7 @@ default
|
|||
if(llGetUnixTime() > g_iLastUsedWater+5)
|
||||
llWhisper(global_ingredients, xtea_encrypt_string(llList2Json(JSON_OBJECT, ["cmd", "query"])));
|
||||
|
||||
integer iGrowTime = 120;
|
||||
integer iGrowTime = 240;
|
||||
#ifdef DEBUG
|
||||
iGrowTime = 1;
|
||||
#endif
|
||||
|
@ -218,8 +227,11 @@ default
|
|||
"dies", 1
|
||||
])));
|
||||
|
||||
llRemoveInventory("Service Daemon [AC]");
|
||||
llRemoveInventory(llGetScriptName());
|
||||
g_iRezzedObject=1;
|
||||
if(g_iRequestedSapling) {
|
||||
llRemoveInventory("Service Daemon [AC]");
|
||||
llRemoveInventory(llGetScriptName());
|
||||
}
|
||||
}
|
||||
|
||||
listen(integer c,string n,key i,string m) {
|
||||
|
|
1
LSL/src/Farm Server Relay Plugin [AC].lsl
Normal file
1
LSL/src/Farm Server Relay Plugin [AC].lsl
Normal file
|
@ -0,0 +1 @@
|
|||
#include "../raw/plugin_discord.lsl"
|
Loading…
Add table
Add a link
Reference in a new issue