corrade-lsl-templates – Diff between revs 29 and 41
?pathlinks?
Rev 29 | Rev 41 | |||
---|---|---|---|---|
1 | /////////////////////////////////////////////////////////////////////////// |
1 | /////////////////////////////////////////////////////////////////////////// |
|
2 | // Copyright (C) Wizardry and Steamworks 2016 - License: CC BY 2.0 // |
2 | // Copyright (C) Wizardry and Steamworks 2016 - License: CC BY 2.0 // |
|
3 | /////////////////////////////////////////////////////////////////////////// |
3 | /////////////////////////////////////////////////////////////////////////// |
|
4 | // |
4 | // |
|
5 | // A module that invites people to the group members. |
5 | // A module that invites people to the group members. |
|
6 | // |
6 | // |
|
7 | /////////////////////////////////////////////////////////////////////////// |
7 | /////////////////////////////////////////////////////////////////////////// |
|
8 | |
8 | |
|
9 | /////////////////////////////////////////////////////////////////////////// |
9 | /////////////////////////////////////////////////////////////////////////// |
|
10 | // Copyright (C) 2014 Wizardry and Steamworks - License: CC BY 2.0 // |
10 | // Copyright (C) 2015 Wizardry and Steamworks - License: CC BY 2.0 // |
|
11 | /////////////////////////////////////////////////////////////////////////// |
11 | /////////////////////////////////////////////////////////////////////////// |
|
12 | string wasKeyValueGet(string k, string data) { |
12 | string wasKeyValueGet(string k, string data) { |
|
13 | if(llStringLength(data) == 0) return ""; |
13 | if(llStringLength(data) == 0) return ""; |
|
14 | if(llStringLength(k) == 0) return ""; |
14 | if(llStringLength(k) == 0) return ""; |
|
15 | list a = llParseString2List(data, ["&", "="], []); |
15 | list a = llParseStringKeepNulls(data, ["&", "="], []); |
|
16 | integer i = llListFindList(a, [ k ]); |
16 | integer i = llListFindList(llList2ListStrided(a, 0, -1, 2), [ k ]); |
|
17 | if(i != -1) return llList2String(a, i+1); |
17 | if(i != -1) return llList2String(a, 2*i+1); |
|
18 | return ""; |
18 | return ""; |
|
19 | } |
19 | } |
|
20 | |
20 | |
|
21 | /////////////////////////////////////////////////////////////////////////// |
21 | /////////////////////////////////////////////////////////////////////////// |
|
22 | // Copyright (C) 2013 Wizardry and Steamworks - License: CC BY 2.0 // |
22 | // Copyright (C) 2013 Wizardry and Steamworks - License: CC BY 2.0 // |
|
23 | /////////////////////////////////////////////////////////////////////////// |
23 | /////////////////////////////////////////////////////////////////////////// |
|
24 | string wasKeyValueEncode(list data) { |
24 | string wasKeyValueEncode(list data) { |
|
25 | list k = llList2ListStrided(data, 0, -1, 2); |
25 | list k = llList2ListStrided(data, 0, -1, 2); |
|
26 | list v = llList2ListStrided(llDeleteSubList(data, 0, 0), 0, -1, 2); |
26 | list v = llList2ListStrided(llDeleteSubList(data, 0, 0), 0, -1, 2); |
|
27 | data = []; |
27 | data = []; |
|
28 | do { |
28 | do { |
|
29 | data += llList2String(k, 0) + "=" + llList2String(v, 0); |
29 | data += llList2String(k, 0) + "=" + llList2String(v, 0); |
|
30 | k = llDeleteSubList(k, 0, 0); |
30 | k = llDeleteSubList(k, 0, 0); |
|
31 | v = llDeleteSubList(v, 0, 0); |
31 | v = llDeleteSubList(v, 0, 0); |
|
32 | } while(llGetListLength(k) != 0); |
32 | } while(llGetListLength(k) != 0); |
|
33 | return llDumpList2String(data, "&"); |
33 | return llDumpList2String(data, "&"); |
|
34 | } |
34 | } |
|
35 | |
35 | |
|
36 | /////////////////////////////////////////////////////////////////////////// |
36 | /////////////////////////////////////////////////////////////////////////// |
|
37 | // Copyright (C) 2011 Wizardry and Steamworks - License: CC BY 2.0 // |
37 | // Copyright (C) 2011 Wizardry and Steamworks - License: CC BY 2.0 // |
|
38 | /////////////////////////////////////////////////////////////////////////// |
38 | /////////////////////////////////////////////////////////////////////////// |
|
39 | // http://was.fm/secondlife/wanderer |
39 | // http://was.fm/secondlife/wanderer |
|
40 | vector wasCirclePoint(float radius) { |
40 | vector wasCirclePoint(float radius) { |
|
41 | float x = llPow(-1, 1 + (integer) llFrand(2)) * llFrand(radius*2); |
41 | float x = llPow(-1, 1 + (integer) llFrand(2)) * llFrand(radius*2); |
|
42 | float y = llPow(-1, 1 + (integer) llFrand(2)) * llFrand(radius*2); |
42 | float y = llPow(-1, 1 + (integer) llFrand(2)) * llFrand(radius*2); |
|
43 | if(llPow(x,2) + llPow(y,2) <= llPow(radius,2)) |
43 | if(llPow(x,2) + llPow(y,2) <= llPow(radius,2)) |
|
44 | return <x, y, 0>; |
44 | return <x, y, 0>; |
|
45 | return wasCirclePoint(radius); |
45 | return wasCirclePoint(radius); |
|
46 | } |
46 | } |
|
47 | |
47 | |
|
48 | /////////////////////////////////////////////////////////////////////////// |
48 | /////////////////////////////////////////////////////////////////////////// |
|
49 | // Copyright (C) 2015 Wizardry and Steamworks - License: CC BY 2.0 // |
49 | // Copyright (C) 2015 Wizardry and Steamworks - License: CC BY 2.0 // |
|
50 | /////////////////////////////////////////////////////////////////////////// |
50 | /////////////////////////////////////////////////////////////////////////// |
|
51 | // escapes a string in conformance with RFC1738 |
51 | // escapes a string in conformance with RFC1738 |
|
52 | string wasURLEscape(string i) { |
52 | string wasURLEscape(string i) { |
|
53 | string o = ""; |
53 | string o = ""; |
|
54 | do { |
54 | do { |
|
55 | string c = llGetSubString(i, 0, 0); |
55 | string c = llGetSubString(i, 0, 0); |
|
56 | i = llDeleteSubString(i, 0, 0); |
56 | i = llDeleteSubString(i, 0, 0); |
|
57 | if(c == "") jump continue; |
57 | if(c == "") jump continue; |
|
58 | if(c == " ") { |
58 | if(c == " ") { |
|
59 | o += "+"; |
59 | o += "+"; |
|
60 | jump continue; |
60 | jump continue; |
|
61 | } |
61 | } |
|
62 | if(c == "\n") { |
62 | if(c == "\n") { |
|
63 | o += "%0D" + llEscapeURL(c); |
63 | o += "%0D" + llEscapeURL(c); |
|
64 | jump continue; |
64 | jump continue; |
|
65 | } |
65 | } |
|
66 | o += llEscapeURL(c); |
66 | o += llEscapeURL(c); |
|
67 | @continue; |
67 | @continue; |
|
68 | } while(i != ""); |
68 | } while(i != ""); |
|
69 | return o; |
69 | return o; |
|
70 | } |
70 | } |
|
71 | |
71 | |
|
72 | /////////////////////////////////////////////////////////////////////////// |
72 | /////////////////////////////////////////////////////////////////////////// |
|
73 | // Copyright (C) 2015 Wizardry and Steamworks - License: CC BY 2.0 // |
73 | // Copyright (C) 2015 Wizardry and Steamworks - License: CC BY 2.0 // |
|
74 | /////////////////////////////////////////////////////////////////////////// |
74 | /////////////////////////////////////////////////////////////////////////// |
|
75 | list wasCSVToList(string csv) { |
75 | list wasCSVToList(string csv) { |
|
76 | list l = []; |
76 | list l = []; |
|
77 | list s = []; |
77 | list s = []; |
|
78 | string m = ""; |
78 | string m = ""; |
|
79 | do { |
79 | do { |
|
80 | string a = llGetSubString(csv, 0, 0); |
80 | string a = llGetSubString(csv, 0, 0); |
|
81 | csv = llDeleteSubString(csv, 0, 0); |
81 | csv = llDeleteSubString(csv, 0, 0); |
|
82 | if(a == ",") { |
82 | if(a == ",") { |
|
83 | if(llList2String(s, -1) != "\"") { |
83 | if(llList2String(s, -1) != "\"") { |
|
84 | l += m; |
84 | l += m; |
|
85 | m = ""; |
85 | m = ""; |
|
86 | jump continue; |
86 | jump continue; |
|
87 | } |
87 | } |
|
88 | m += a; |
88 | m += a; |
|
89 | jump continue; |
89 | jump continue; |
|
90 | } |
90 | } |
|
91 | if(a == "\"" && llGetSubString(csv, 0, 0) == a) { |
91 | if(a == "\"" && llGetSubString(csv, 0, 0) == a) { |
|
92 | m += a; |
92 | m += a; |
|
93 | csv = llDeleteSubString(csv, 0, 0); |
93 | csv = llDeleteSubString(csv, 0, 0); |
|
94 | jump continue; |
94 | jump continue; |
|
95 | } |
95 | } |
|
96 | if(a == "\"") { |
96 | if(a == "\"") { |
|
97 | if(llList2String(s, -1) != a) { |
97 | if(llList2String(s, -1) != a) { |
|
98 | s += a; |
98 | s += a; |
|
99 | jump continue; |
99 | jump continue; |
|
100 | } |
100 | } |
|
101 | s = llDeleteSubList(s, -1, -1); |
101 | s = llDeleteSubList(s, -1, -1); |
|
102 | jump continue; |
102 | jump continue; |
|
103 | } |
103 | } |
|
104 | m += a; |
104 | m += a; |
|
105 | @continue; |
105 | @continue; |
|
106 | } while(csv != ""); |
106 | } while(csv != ""); |
|
107 | // postcondition: length(s) = 0 |
107 | // postcondition: length(s) = 0 |
|
108 | return l + m; |
108 | return l + m; |
|
109 | } |
109 | } |
|
110 | |
110 | |
|
111 | /////////////////////////////////////////////////////////////////////////// |
111 | /////////////////////////////////////////////////////////////////////////// |
|
112 | // Copyright (C) 2015 Wizardry and Steamworks - License: CC BY 2.0 // |
112 | // Copyright (C) 2015 Wizardry and Steamworks - License: CC BY 2.0 // |
|
113 | /////////////////////////////////////////////////////////////////////////// |
113 | /////////////////////////////////////////////////////////////////////////// |
|
114 | string wasListToCSV(list l) { |
114 | string wasListToCSV(list l) { |
|
115 | list v = []; |
115 | list v = []; |
|
116 | do { |
116 | do { |
|
117 | string a = llDumpList2String( |
117 | string a = llDumpList2String( |
|
118 | llParseStringKeepNulls( |
118 | llParseStringKeepNulls( |
|
119 | llList2String( |
119 | llList2String( |
|
120 | l, |
120 | l, |
|
121 | 0 |
121 | 0 |
|
122 | ), |
122 | ), |
|
123 | ["\""], |
123 | ["\""], |
|
124 | [] |
124 | [] |
|
125 | ), |
125 | ), |
|
126 | "\"\"" |
126 | "\"\"" |
|
127 | ); |
127 | ); |
|
128 | if(llParseStringKeepNulls( |
128 | if(llParseStringKeepNulls( |
|
129 | a, |
129 | a, |
|
130 | [" ", ",", "\n", "\""], [] |
130 | [" ", ",", "\n", "\""], [] |
|
131 | ) != |
131 | ) != |
|
132 | (list) a |
132 | (list) a |
|
133 | ) a = "\"" + a + "\""; |
133 | ) a = "\"" + a + "\""; |
|
134 | v += a; |
134 | v += a; |
|
135 | l = llDeleteSubList(l, 0, 0); |
135 | l = llDeleteSubList(l, 0, 0); |
|
136 | } while(l != []); |
136 | } while(l != []); |
|
137 | return llDumpList2String(v, ","); |
137 | return llDumpList2String(v, ","); |
|
138 | } |
138 | } |
|
139 | |
139 | |
|
140 | /////////////////////////////////////////////////////////////////////////// |
140 | /////////////////////////////////////////////////////////////////////////// |
|
141 | // Copyright (C) 2015 Wizardry and Steamworks - License: CC BY 2.0 // |
141 | // Copyright (C) 2015 Wizardry and Steamworks - License: CC BY 2.0 // |
|
142 | /////////////////////////////////////////////////////////////////////////// |
142 | /////////////////////////////////////////////////////////////////////////// |
|
143 | // unescapes a string in conformance with RFC1738 |
143 | // unescapes a string in conformance with RFC1738 |
|
144 | string wasURLUnescape(string i) { |
144 | string wasURLUnescape(string i) { |
|
145 | return llUnescapeURL( |
145 | return llUnescapeURL( |
|
146 | llDumpList2String( |
146 | llDumpList2String( |
|
147 | llParseString2List( |
147 | llParseString2List( |
|
148 | llDumpList2String( |
148 | llDumpList2String( |
|
149 | llParseString2List( |
149 | llParseString2List( |
|
150 | i, |
150 | i, |
|
151 | ["+"], |
151 | ["+"], |
|
152 | [] |
152 | [] |
|
153 | ), |
153 | ), |
|
154 | " " |
154 | " " |
|
155 | ), |
155 | ), |
|
156 | ["%0D%0A"], |
156 | ["%0D%0A"], |
|
157 | [] |
157 | [] |
|
158 | ), |
158 | ), |
|
159 | "\n" |
159 | "\n" |
|
160 | ) |
160 | ) |
|
161 | ); |
161 | ); |
|
162 | } |
162 | } |
|
163 | |
163 | |
|
164 | // configuration data |
164 | // configuration data |
|
165 | string configuration = ""; |
165 | string configuration = ""; |
|
166 | // callback URL |
166 | // callback URL |
|
167 | string URL = ""; |
167 | string URL = ""; |
|
168 | // store message over state. |
168 | // store message over state. |
|
169 | string data = ""; |
169 | string data = ""; |
|
170 | string firstname = ""; |
170 | string firstname = ""; |
|
171 | string lastname = ""; |
171 | string lastname = ""; |
|
172 | |
172 | |
|
173 | default { |
173 | default { |
|
174 | state_entry() { |
174 | state_entry() { |
|
175 | llOwnerSay("[Invite] Starting..."); |
175 | llOwnerSay("[Invite] Starting..."); |
|
176 | llSetTimerEvent(10); |
176 | llSetTimerEvent(10); |
|
177 | } |
177 | } |
|
178 | link_message(integer sender, integer num, string message, key id) { |
178 | link_message(integer sender, integer num, string message, key id) { |
|
179 | if(id != "configuration") return; |
179 | if(id != "configuration") return; |
|
180 | llOwnerSay("[Invite] Got configuration..."); |
180 | llOwnerSay("[Invite] Got configuration..."); |
|
181 | configuration = message; |
181 | configuration = message; |
|
182 | state listen_group; |
182 | state listen_group; |
|
183 | } |
183 | } |
|
184 | timer() { |
184 | timer() { |
|
185 | llOwnerSay("[Invite] Requesting configuration..."); |
185 | llOwnerSay("[Invite] Requesting configuration..."); |
|
186 | llMessageLinked(LINK_THIS, 0, "configuration", NULL_KEY); |
186 | llMessageLinked(LINK_THIS, 0, "configuration", NULL_KEY); |
|
187 | } |
187 | } |
|
188 | on_rez(integer num) { |
188 | on_rez(integer num) { |
|
189 | llResetScript(); |
189 | llResetScript(); |
|
190 | } |
190 | } |
|
191 | changed(integer change) { |
191 | changed(integer change) { |
|
192 | if((change & CHANGED_INVENTORY) || |
192 | if((change & CHANGED_INVENTORY) || |
|
193 | (change & CHANGED_REGION_START) || |
193 | (change & CHANGED_REGION_START) || |
|
194 | (change & CHANGED_OWNER)) { |
194 | (change & CHANGED_OWNER)) { |
|
195 | llResetScript(); |
195 | llResetScript(); |
|
196 | } |
196 | } |
|
197 | } |
197 | } |
|
198 | state_exit() { |
198 | state_exit() { |
|
199 | llSetTimerEvent(0); |
199 | llSetTimerEvent(0); |
|
200 | } |
200 | } |
|
201 | } |
201 | } |
|
202 | |
202 | |
|
203 | state listen_group { |
203 | state listen_group { |
|
204 | state_entry() { |
204 | state_entry() { |
|
205 | // DEBUG |
205 | // DEBUG |
|
206 | llOwnerSay("[Invite] Waiting for group messages..."); |
206 | llOwnerSay("[Invite] Waiting for group messages..."); |
|
207 | } |
207 | } |
|
208 | link_message(integer sender, integer num, string message, key id) { |
208 | link_message(integer sender, integer num, string message, key id) { |
|
209 | // We only care about notifications now. |
209 | // We only care about notifications now. |
|
210 | if(id != "notification") |
210 | if(id != "notification") |
|
211 | return; |
211 | return; |
|
212 | |
212 | |
|
213 | // This script only processes group notifications. |
213 | // This script only processes group notifications. |
|
214 | if(wasKeyValueGet("type", message) != "group") |
214 | if(wasKeyValueGet("type", message) != "group") |
|
215 | return; |
215 | return; |
|
216 | |
216 | |
|
217 | // Get the sent message. |
217 | // Get the sent message. |
|
218 | data = wasURLUnescape( |
218 | data = wasURLUnescape( |
|
219 | wasKeyValueGet( |
219 | wasKeyValueGet( |
|
220 | "message", |
220 | "message", |
|
221 | message |
221 | message |
|
222 | ) |
222 | ) |
|
223 | ); |
223 | ); |
|
224 | |
224 | |
|
225 | // Check if this is an eggdrop command. |
225 | // Check if this is an eggdrop command. |
|
226 | if(llGetSubString(data, 0, 0) != |
226 | if(llGetSubString(data, 0, 0) != |
|
227 | wasKeyValueGet("command", configuration)) |
227 | wasKeyValueGet("command", configuration)) |
|
228 | return; |
228 | return; |
|
229 | |
229 | |
|
230 | // Check if the command matches the current module. |
230 | // Check if the command matches the current module. |
|
231 | list command = llParseString2List(data, [" "], []); |
231 | list command = llParseString2List(data, [" "], []); |
|
232 | if(llList2String(command, 0) != |
232 | if(llList2String(command, 0) != |
|
233 | wasKeyValueGet("command", configuration) + "invite") |
233 | wasKeyValueGet("command", configuration) + "invite") |
|
234 | return; |
234 | return; |
|
235 | |
235 | |
|
236 | // Remove command. |
236 | // Remove command. |
|
237 | command = llDeleteSubList(command, 0, 0); |
237 | command = llDeleteSubList(command, 0, 0); |
|
238 | |
238 | |
|
239 | // Dump the rest of the message. |
239 | // Dump the rest of the message. |
|
240 | data = llDumpList2String(command, " "); |
240 | data = llDumpList2String(command, " "); |
|
241 | |
241 | |
|
242 | // Get an URL. |
242 | // Get an URL. |
|
243 | state url; |
243 | state url; |
|
244 | } |
244 | } |
|
245 | on_rez(integer num) { |
245 | on_rez(integer num) { |
|
246 | llResetScript(); |
246 | llResetScript(); |
|
247 | } |
247 | } |
|
248 | changed(integer change) { |
248 | changed(integer change) { |
|
249 | if((change & CHANGED_INVENTORY) || |
249 | if((change & CHANGED_INVENTORY) || |
|
250 | (change & CHANGED_REGION_START) || |
250 | (change & CHANGED_REGION_START) || |
|
251 | (change & CHANGED_OWNER)) { |
251 | (change & CHANGED_OWNER)) { |
|
252 | llResetScript(); |
252 | llResetScript(); |
|
253 | } |
253 | } |
|
254 | } |
254 | } |
|
255 | } |
255 | } |
|
256 | |
256 | |
|
257 | state url { |
257 | state url { |
|
258 | state_entry() { |
258 | state_entry() { |
|
259 | // DEBUG |
259 | // DEBUG |
|
260 | llOwnerSay("[Invite] Requesting URL..."); |
260 | llOwnerSay("[Invite] Requesting URL..."); |
|
261 | llRequestURL(); |
261 | llRequestURL(); |
|
262 | } |
262 | } |
|
263 | http_request(key id, string method, string body) { |
263 | http_request(key id, string method, string body) { |
|
264 | if(method != URL_REQUEST_GRANTED) return; |
264 | if(method != URL_REQUEST_GRANTED) return; |
|
265 | URL = body; |
265 | URL = body; |
|
266 | // DEBUG |
266 | // DEBUG |
|
267 | llOwnerSay("[Invite] Got URL..."); |
267 | llOwnerSay("[Invite] Got URL..."); |
|
268 | state search; |
268 | state search; |
|
269 | } |
269 | } |
|
270 | on_rez(integer num) { |
270 | on_rez(integer num) { |
|
271 | llResetScript(); |
271 | llResetScript(); |
|
272 | } |
272 | } |
|
273 | changed(integer change) { |
273 | changed(integer change) { |
|
274 | if((change & CHANGED_INVENTORY) || |
274 | if((change & CHANGED_INVENTORY) || |
|
275 | (change & CHANGED_REGION_START) || |
275 | (change & CHANGED_REGION_START) || |
|
276 | (change & CHANGED_OWNER)) { |
276 | (change & CHANGED_OWNER)) { |
|
277 | llResetScript(); |
277 | llResetScript(); |
|
278 | } |
278 | } |
|
279 | } |
279 | } |
|
280 | } |
280 | } |
|
281 | |
281 | |
|
282 | state search { |
282 | state search { |
|
283 | state_entry() { |
283 | state_entry() { |
|
284 | // DEBUG |
284 | // DEBUG |
|
285 | llOwnerSay("[Invite] Searching for agent."); |
285 | llOwnerSay("[Invite] Searching for agent."); |
|
286 | llInstantMessage( |
286 | llInstantMessage( |
|
287 | wasKeyValueGet( |
287 | wasKeyValueGet( |
|
288 | "corrade", |
288 | "corrade", |
|
289 | configuration |
289 | configuration |
|
290 | ), |
290 | ), |
|
291 | wasKeyValueEncode( |
291 | wasKeyValueEncode( |
|
292 | [ |
292 | [ |
|
293 | "command", "directorysearch", |
293 | "command", "directorysearch", |
|
294 | "group", wasURLEscape( |
294 | "group", wasURLEscape( |
|
295 | wasKeyValueGet( |
295 | wasKeyValueGet( |
|
296 | "group", |
296 | "group", |
|
297 | configuration |
297 | configuration |
|
298 | ) |
298 | ) |
|
299 | ), |
299 | ), |
|
300 | "password", wasURLEscape( |
300 | "password", wasURLEscape( |
|
301 | wasKeyValueGet( |
301 | wasKeyValueGet( |
|
302 | "password", |
302 | "password", |
|
303 | configuration |
303 | configuration |
|
304 | ) |
304 | ) |
|
305 | ), |
305 | ), |
|
306 | "type", "people", |
306 | "type", "people", |
|
307 | "name", wasURLEscape(data), |
307 | "name", wasURLEscape(data), |
|
308 | /*"sift", wasURLEscape( |
308 | /*"sift", wasURLEscape( |
|
309 | wasListToCSV( |
309 | wasListToCSV( |
|
310 | [ |
310 | [ |
|
311 | "match", |
311 | "match", |
|
312 | wasURLEscape("(?i),?([^,$]*" + data +"[^,$]*),?") |
312 | wasURLEscape("(?i),?([^,$]*" + data +"[^,$]*),?") |
|
313 | ] |
313 | ] |
|
314 | ) |
314 | ) |
|
315 | ),*/ |
315 | ),*/ |
|
316 | "callback", wasURLEscape(URL) |
316 | "callback", wasURLEscape(URL) |
|
317 | ] |
317 | ] |
|
318 | ) |
318 | ) |
|
319 | ); |
319 | ); |
|
320 | llSetTimerEvent(60); |
320 | llSetTimerEvent(60); |
|
321 | } |
321 | } |
|
322 | http_request(key id, string method, string body) { |
322 | http_request(key id, string method, string body) { |
|
323 | llHTTPResponse(id, 200, "OK"); |
323 | llHTTPResponse(id, 200, "OK"); |
|
324 | if(wasKeyValueGet("command", body) != "directorysearch" || |
324 | if(wasKeyValueGet("command", body) != "directorysearch" || |
|
325 | wasKeyValueGet("success", body) != "True") { |
325 | wasKeyValueGet("success", body) != "True") { |
|
326 | // DEBUG |
326 | // DEBUG |
|
327 | llOwnerSay("[Invite] Unable to search for agent: " + |
327 | llOwnerSay("[Invite] Unable to search for agent: " + |
|
328 | wasURLUnescape( |
328 | wasURLUnescape( |
|
329 | wasKeyValueGet("error", body) |
329 | wasKeyValueGet("error", body) |
|
330 | ) |
330 | ) |
|
331 | ); |
331 | ); |
|
332 | llReleaseURL(URL); |
332 | llReleaseURL(URL); |
|
333 | state listen_group; |
333 | state listen_group; |
|
334 | } |
334 | } |
|
335 | |
335 | |
|
336 | list first_last = llParseString2List(data, [" "], []); |
336 | list first_last = llParseString2List(data, [" "], []); |
|
337 | firstname = llList2String(first_last, 0); |
337 | firstname = llList2String(first_last, 0); |
|
338 | lastname = llList2String(first_last, 1); |
338 | lastname = llList2String(first_last, 1); |
|
339 | |
339 | |
|
340 | list found_agent = wasCSVToList( |
340 | list found_agent = wasCSVToList( |
|
341 | wasURLUnescape( |
341 | wasURLUnescape( |
|
342 | wasKeyValueGet("data", body) |
342 | wasKeyValueGet("data", body) |
|
343 | ) |
343 | ) |
|
344 | ); |
344 | ); |
|
345 | |
345 | |
|
346 | if(llToUpper( |
346 | if(llToUpper( |
|
347 | llList2String( |
347 | llList2String( |
|
348 | found_agent, |
348 | found_agent, |
|
349 | llListFindList( |
349 | llListFindList( |
|
350 | found_agent, |
350 | found_agent, |
|
351 | (list)"FirstName" |
351 | (list)"FirstName" |
|
352 | ) + 1 |
352 | ) + 1 |
|
353 | ) |
353 | ) |
|
354 | ) != llToUpper(firstname) || |
354 | ) != llToUpper(firstname) || |
|
355 | llToUpper( |
355 | llToUpper( |
|
356 | llList2String( |
356 | llList2String( |
|
357 | found_agent, |
357 | found_agent, |
|
358 | llListFindList( |
358 | llListFindList( |
|
359 | found_agent, |
359 | found_agent, |
|
360 | (list)"LastName" |
360 | (list)"LastName" |
|
361 | ) + 1 |
361 | ) + 1 |
|
362 | ) |
362 | ) |
|
363 | ) != llToUpper(lastname)) { |
363 | ) != llToUpper(lastname)) { |
|
364 | data = "Agent not found."; |
364 | data = "Agent not found."; |
|
365 | llReleaseURL(URL); |
365 | llReleaseURL(URL); |
|
366 | state tell; |
366 | state tell; |
|
367 | } |
367 | } |
|
368 | |
368 | |
|
369 | state invite; |
369 | state invite; |
|
370 | } |
370 | } |
|
371 | timer() { |
371 | timer() { |
|
372 | llReleaseURL(URL); |
372 | llReleaseURL(URL); |
|
373 | state listen_group; |
373 | state listen_group; |
|
374 | } |
374 | } |
|
375 | on_rez(integer num) { |
375 | on_rez(integer num) { |
|
376 | llResetScript(); |
376 | llResetScript(); |
|
377 | } |
377 | } |
|
378 | changed(integer change) { |
378 | changed(integer change) { |
|
379 | if((change & CHANGED_INVENTORY) || |
379 | if((change & CHANGED_INVENTORY) || |
|
380 | (change & CHANGED_REGION_START) || |
380 | (change & CHANGED_REGION_START) || |
|
381 | (change & CHANGED_OWNER)) { |
381 | (change & CHANGED_OWNER)) { |
|
382 | llResetScript(); |
382 | llResetScript(); |
|
383 | } |
383 | } |
|
384 | } |
384 | } |
|
385 | state_exit() { |
385 | state_exit() { |
|
386 | llSetTimerEvent(0); |
386 | llSetTimerEvent(0); |
|
387 | } |
387 | } |
|
388 | } |
388 | } |
|
389 | |
389 | |
|
390 | state invite { |
390 | state invite { |
|
391 | state_entry() { |
391 | state_entry() { |
|
392 | // DEBUG |
392 | // DEBUG |
|
393 | llOwnerSay("[Invite] inviting..."); |
393 | llOwnerSay("[Invite] inviting..."); |
|
394 | llInstantMessage( |
394 | llInstantMessage( |
|
395 | wasKeyValueGet( |
395 | wasKeyValueGet( |
|
396 | "corrade", |
396 | "corrade", |
|
397 | configuration |
397 | configuration |
|
398 | ), |
398 | ), |
|
399 | wasKeyValueEncode( |
399 | wasKeyValueEncode( |
|
400 | [ |
400 | [ |
|
401 | "command", "invite", |
401 | "command", "invite", |
|
402 | "group", wasURLEscape( |
402 | "group", wasURLEscape( |
|
403 | wasKeyValueGet( |
403 | wasKeyValueGet( |
|
404 | "group", |
404 | "group", |
|
405 | configuration |
405 | configuration |
|
406 | ) |
406 | ) |
|
407 | ), |
407 | ), |
|
408 | "password", wasURLEscape( |
408 | "password", wasURLEscape( |
|
409 | wasKeyValueGet( |
409 | wasKeyValueGet( |
|
410 | "password", |
410 | "password", |
|
411 | configuration |
411 | configuration |
|
412 | ) |
412 | ) |
|
413 | ), |
413 | ), |
|
414 | "firstname", firstname, |
414 | "firstname", firstname, |
|
415 | "lastname", lastname, |
415 | "lastname", lastname, |
|
416 | "soft", "True", |
416 | "soft", "True", |
|
417 | "verify", "False", |
417 | "verify", "False", |
|
418 | "callback", wasURLEscape(URL) |
418 | "callback", wasURLEscape(URL) |
|
419 | ] |
419 | ] |
|
420 | ) |
420 | ) |
|
421 | ); |
421 | ); |
|
422 | llSetTimerEvent(60); |
422 | llSetTimerEvent(60); |
|
423 | } |
423 | } |
|
424 | http_request(key id, string method, string body) { |
424 | http_request(key id, string method, string body) { |
|
425 | llHTTPResponse(id, 200, "OK"); |
425 | llHTTPResponse(id, 200, "OK"); |
|
426 | llReleaseURL(URL); |
426 | llReleaseURL(URL); |
|
427 | if(wasKeyValueGet("command", body) != "invite" || |
427 | if(wasKeyValueGet("command", body) != "invite" || |
|
428 | wasKeyValueGet("success", body) != "True") { |
428 | wasKeyValueGet("success", body) != "True") { |
|
429 | // DEBUG |
429 | // DEBUG |
|
430 | llOwnerSay("[Eject] Unable to invite agent: " + |
430 | llOwnerSay("[Eject] Unable to invite agent: " + |
|
431 | wasURLUnescape( |
431 | wasURLUnescape( |
|
432 | wasKeyValueGet("error", body) |
432 | wasKeyValueGet("error", body) |
|
433 | ) |
433 | ) |
|
434 | ); |
434 | ); |
|
435 | state listen_group; |
435 | state listen_group; |
|
436 | } |
436 | } |
|
437 | |
437 | |
|
438 | data = "Butters (Jym) was sent to pick them up!"; |
438 | data = "Butters (Jym) was sent to pick them up!"; |
|
439 | |
439 | |
|
440 | state tell; |
440 | state tell; |
|
441 | } |
441 | } |
|
442 | timer() { |
442 | timer() { |
|
443 | llReleaseURL(URL); |
443 | llReleaseURL(URL); |
|
444 | state listen_group; |
444 | state listen_group; |
|
445 | } |
445 | } |
|
446 | on_rez(integer num) { |
446 | on_rez(integer num) { |
|
447 | llResetScript(); |
447 | llResetScript(); |
|
448 | } |
448 | } |
|
449 | changed(integer change) { |
449 | changed(integer change) { |
|
450 | if((change & CHANGED_INVENTORY) || |
450 | if((change & CHANGED_INVENTORY) || |
|
451 | (change & CHANGED_REGION_START) || |
451 | (change & CHANGED_REGION_START) || |
|
452 | (change & CHANGED_OWNER)) { |
452 | (change & CHANGED_OWNER)) { |
|
453 | llResetScript(); |
453 | llResetScript(); |
|
454 | } |
454 | } |
|
455 | } |
455 | } |
|
456 | state_exit() { |
456 | state_exit() { |
|
457 | llSetTimerEvent(0); |
457 | llSetTimerEvent(0); |
|
458 | } |
458 | } |
|
459 | } |
459 | } |
|
460 | |
460 | |
|
461 | state tell { |
461 | state tell { |
|
462 | state_entry() { |
462 | state_entry() { |
|
463 | // DEBUG |
463 | // DEBUG |
|
464 | llOwnerSay("[Invite] Sending to group."); |
464 | llOwnerSay("[Invite] Sending to group."); |
|
465 | llInstantMessage( |
465 | llInstantMessage( |
|
466 | wasKeyValueGet( |
466 | wasKeyValueGet( |
|
467 | "corrade", |
467 | "corrade", |
|
468 | configuration |
468 | configuration |
|
469 | ), |
469 | ), |
|
470 | wasKeyValueEncode( |
470 | wasKeyValueEncode( |
|
471 | [ |
471 | [ |
|
472 | "command", "tell", |
472 | "command", "tell", |
|
473 | "group", wasURLEscape( |
473 | "group", wasURLEscape( |
|
474 | wasKeyValueGet( |
474 | wasKeyValueGet( |
|
475 | "group", |
475 | "group", |
|
476 | configuration |
476 | configuration |
|
477 | ) |
477 | ) |
|
478 | ), |
478 | ), |
|
479 | "password", wasURLEscape( |
479 | "password", wasURLEscape( |
|
480 | wasKeyValueGet( |
480 | wasKeyValueGet( |
|
481 | "password", |
481 | "password", |
|
482 | configuration |
482 | configuration |
|
483 | ) |
483 | ) |
|
484 | ), |
484 | ), |
|
485 | "entity", "group", |
485 | "entity", "group", |
|
486 | "message", wasURLEscape(data) |
486 | "message", wasURLEscape(data) |
|
487 | ] |
487 | ] |
|
488 | ) |
488 | ) |
|
489 | ); |
489 | ); |
|
490 | state listen_group; |
490 | state listen_group; |
|
491 | } |
491 | } |
|
492 | } |
492 | } |
|
493 | |
493 | |