-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b428c2a
commit fafcf86
Showing
5 changed files
with
222 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Discord Webhook Client Api. | ||
|
||
Discord webhook example for Second Life/Opensimulator | ||
|
||
Allows you to post messages to your Discord server from Second Life or Opensimulator objects. | ||
|
||
This script is aimed at developers, not the general public, even though you are more than welcome to use it. | ||
|
||
See https://discordapp.com/developers/docs/resources/webhook for more information on how to format json | ||
|
||
In Second Life: | ||
Get it delivered to your inventory: https://marketplace.secondlife.com/p/Discord-Webhook-Api-Client/13515102 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
theme: jekyll-theme-midnight |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
key REQUEST_KEY; | ||
|
||
string WEBHOOK_CHANNEL = ""; | ||
string WEBHOOK_TOKEN = ""; | ||
string WEBHOOK_URL = "https://discordapp.com/api/webhooks/"; | ||
integer WEBHOOK_WAIT = TRUE; | ||
|
||
string slurl(key AvatarID) | ||
{ | ||
string regionname = llGetRegionName(); | ||
vector pos = llList2Vector(llGetObjectDetails(AvatarID, [ OBJECT_POS ]), 0); | ||
|
||
return "http://maps.secondlife.com/secondlife/" | ||
+ llEscapeURL(regionname) + "/" | ||
+ (string)llRound(pos.x) + "/" | ||
+ (string)llRound(pos.y) + "/" | ||
+ (string)llRound(pos.z) + "/"; | ||
} | ||
|
||
key PostToDiscord(key AvatarID, string Message) | ||
{ | ||
string SLURL = slurl(AvatarID); | ||
list json = [ | ||
"username", llGetObjectName() + "", | ||
"embeds", | ||
llList2Json(JSON_ARRAY, | ||
[ | ||
llList2Json(JSON_OBJECT, | ||
[ | ||
"color", "100000", | ||
"title", "More info (uses url setting as link)", | ||
"description", llGetUsername(AvatarID) + ": " + Message + "\nProfile: http://my.secondlife.com/" + llGetUsername(AvatarID) + "\nLocation: " + SLURL, | ||
"url", SLURL | ||
]) | ||
]), | ||
"avatar_url", "https://my-secondlife-agni.akamaized.net/users/" + llGetUsername(AvatarID) + "/sl_image.png" | ||
]; | ||
string query_string = ""; | ||
if (WEBHOOK_WAIT) | ||
query_string += "?wait=true"; | ||
|
||
return llHTTPRequest(WEBHOOK_URL + WEBHOOK_CHANNEL + "/" + WEBHOOK_TOKEN + query_string, | ||
[ | ||
HTTP_METHOD, "POST", | ||
HTTP_MIMETYPE, "application/x-www-form-urlencoded", | ||
HTTP_VERIFY_CERT,TRUE, | ||
HTTP_VERBOSE_THROTTLE, TRUE, | ||
HTTP_PRAGMA_NO_CACHE, TRUE ], llList2Json(JSON_OBJECT, json)); | ||
} | ||
|
||
default | ||
{ | ||
state_entry() | ||
{ | ||
|
||
} | ||
|
||
touch_start(integer total_number) | ||
{ | ||
REQUEST_KEY = PostToDiscord(llDetectedKey(0), "Help point info from script :P"); | ||
} | ||
http_response(key request_id, integer status, list metadata, string body) | ||
{ | ||
if(REQUEST_KEY == request_id) | ||
{ | ||
if (WEBHOOK_WAIT) | ||
llOwnerSay(body); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
key REQUEST_KEY; | ||
|
||
string WEBHOOK_CHANNEL = ""; | ||
string WEBHOOK_TOKEN = ""; | ||
string WEBHOOK_URL = "https://discordapp.com/api/webhooks/"; | ||
integer WEBHOOK_WAIT = TRUE; | ||
|
||
string slurl(key AvatarID) | ||
{ | ||
string regionname = llGetRegionName(); | ||
vector pos = llList2Vector(llGetObjectDetails(AvatarID, [ OBJECT_POS ]), 0); | ||
|
||
return "http://maps.secondlife.com/secondlife/" | ||
+ llEscapeURL(regionname) + "/" | ||
+ (string)llRound(pos.x) + "/" | ||
+ (string)llRound(pos.y) + "/" | ||
+ (string)llRound(pos.z) + "/"; | ||
} | ||
|
||
key PostToDiscord(key AvatarID, string Message) | ||
{ | ||
list json = [ | ||
"username", llGetObjectName() + "", | ||
"content", llGetUsername(AvatarID) + ": " + Message + "\n\nProfile: http://my.secondlife.com/" + llGetUsername(AvatarID) + "\nLocation: " + slurl(AvatarID), | ||
"avatar_url", "https://my-secondlife-agni.akamaized.net/users/" + llGetUsername(AvatarID) + "/sl_image.png" | ||
]; | ||
string query_string = ""; | ||
if (WEBHOOK_WAIT) | ||
query_string += "?wait=true"; | ||
|
||
return llHTTPRequest(WEBHOOK_URL + WEBHOOK_CHANNEL + "/" + WEBHOOK_TOKEN + query_string, | ||
[ | ||
HTTP_METHOD, "POST", | ||
HTTP_MIMETYPE, "application/x-www-form-urlencoded", | ||
HTTP_VERIFY_CERT,TRUE, | ||
HTTP_VERBOSE_THROTTLE, TRUE, | ||
HTTP_PRAGMA_NO_CACHE, TRUE ], llList2Json(JSON_OBJECT, json)); | ||
} | ||
|
||
default | ||
{ | ||
state_entry() | ||
{ | ||
|
||
} | ||
|
||
touch_start(integer total_number) | ||
{ | ||
REQUEST_KEY = PostToDiscord(llDetectedKey(0), "Help point info from script :P"); | ||
} | ||
http_response(key request_id, integer status, list metadata, string body) | ||
{ | ||
if(REQUEST_KEY == request_id) | ||
{ | ||
if (WEBHOOK_WAIT) | ||
llOwnerSay(body); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
key REQUEST_KEY; | ||
|
||
string WEBHOOK_CHANNEL = ""; | ||
string WEBHOOK_TOKEN = ""; | ||
string WEBHOOK_URL = "https://discordapp.com/api/webhooks/"; | ||
integer WEBHOOK_WAIT = TRUE; | ||
|
||
string slurl(key AvatarID) | ||
{ | ||
string regionname = llGetRegionName(); | ||
vector pos = llList2Vector(llGetObjectDetails(AvatarID, [ OBJECT_POS ]), 0); | ||
|
||
return "http://maps.secondlife.com/secondlife/" | ||
+ llEscapeURL(regionname) + "/" | ||
+ (string)llRound(pos.x) + "/" | ||
+ (string)llRound(pos.y) + "/" | ||
+ (string)llRound(pos.z) + "/"; | ||
} | ||
|
||
key PostToDiscord(key AvatarID, string Message) | ||
{ | ||
string SLURL = slurl(AvatarID); | ||
list json = [ | ||
"username", llGetObjectName() + "", | ||
"embeds", | ||
llList2Json(JSON_ARRAY, | ||
[ | ||
llList2Json(JSON_OBJECT, | ||
[ | ||
"color", "100000", | ||
"title", "More info (uses url setting as link, also the authors name links to the url)", | ||
"description", llGetUsername(AvatarID) + ": " + Message + "\nProfile: http://my.secondlife.com/" + llGetUsername(AvatarID) + "\nLocation: " + SLURL, | ||
"url", SLURL, | ||
"author", llList2Json(JSON_OBJECT, | ||
[ | ||
"name", "Author Name", | ||
"icon_url", "https://my-secondlife-agni.akamaized.net/users/" + llGetUsername(AvatarID) + "/sl_image.png" | ||
]), | ||
"footer", llList2Json(JSON_OBJECT, | ||
[ | ||
"icon_url", "https://my-secondlife-agni.akamaized.net/users/" + llGetUsername(AvatarID) + "/sl_image.png", | ||
"text", "Any footer text" | ||
]) | ||
]) | ||
]), | ||
"avatar_url", "https://my-secondlife-agni.akamaized.net/users/alethiaisland.engineer/thumb_sl_image.png" | ||
]; | ||
string query_string = ""; | ||
if (WEBHOOK_WAIT) | ||
query_string += "?wait=true"; | ||
|
||
return llHTTPRequest(WEBHOOK_URL + WEBHOOK_CHANNEL + "/" + WEBHOOK_TOKEN + query_string, | ||
[ | ||
HTTP_METHOD, "POST", | ||
HTTP_MIMETYPE, "application/x-www-form-urlencoded", | ||
HTTP_VERIFY_CERT,TRUE, | ||
HTTP_VERBOSE_THROTTLE, TRUE, | ||
HTTP_PRAGMA_NO_CACHE, TRUE ], llList2Json(JSON_OBJECT, json)); | ||
} | ||
|
||
default | ||
{ | ||
state_entry() | ||
{ | ||
|
||
} | ||
|
||
touch_start(integer total_number) | ||
{ | ||
REQUEST_KEY = PostToDiscord(llDetectedKey(0), "Help point info from script :P"); | ||
} | ||
http_response(key request_id, integer status, list metadata, string body) | ||
{ | ||
if(REQUEST_KEY == request_id) | ||
{ | ||
if (WEBHOOK_WAIT) | ||
llOwnerSay(body); | ||
} | ||
} | ||
} |