User:Decimus Schomer/Scripts/SL Emailer

From The SchomEmunity Wiki
< User:Decimus Schomer‎ | Scripts
Revision as of 20:55, 13 January 2008 by Rebecca (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Decimus' user page | Decimus' talk page | Decimus' scripts | Decimus' script libraries | Decimus' projects
Main scripts page | Toggling Rotate script | UUID-getter scripts | Texture changer | Channel spier | Chatbot | Jump slab | Emailer | Fractal viewer | Grammar analyser | SPD viewer


About

This pair of scripts allows you to send an email to an arbitrary (picked by the sender) email address. To set it up, simply copy these scripts into the same prim.

How it works

It works by, when you touch it, telling you to input a subject (which it waits for 30s for, then doesn't continue if you don't type one by then), then tells you to input a message (which it also waits for 30s to receive), then sends an email via the second script (to stop the first script being too laggy)

Script 1

// SL emailer - send emails from within SL
// Copyright (C) 2007 Decimus Schomer
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

integer l;
integer st = 0;
string subj;
string to;

default
{
    touch_start(integer total_number)
    {
        if (st)
            llSay(0, "Sorry, but the emailer is currently busy.");
        key k = llDetectedKey(0);
        llSay(0, "Hello, " + llDetectedName(0) + ". Please say the address the message should go to.");
        st = 1;
        l = llListen(0, "", k, "");
        llSetTimerEvent(30);
    }
    
    timer()
    {
        llSay(0, "Your request has expired.");
        llListenRemove(l);
        llSetTimerEvent(0);
        st = 0;
    }
    
    listen(integer channel, string name, key id, string msg)
    {
        if (st == 3)
        {
            llMessageLinked(LINK_THIS, 0, llList2CSV([name, to, subj, msg]), NULL_KEY);
            llListenRemove(l);
            llSetTimerEvent(0);
            st = 0;
        }
        else if (st == 2)
        {
            subj = msg;
            st = 3;
            llSay(0, "Now type your message body.");
            llSetTimerEvent(30);
        }
        else
        {
            to = msg;
            st = 2;
            llSay(0, "Now type your message's subject.");
            llSetTimerEvent(30);
        }
    }
}

Script 2

default
{
    link_message(integer sender, integer n, string str, key k)
    {
        list l = llCSV2List(str);
        llSay(0, "Sending message...");
        llSetObjectName("SL emailer (" + llList2String(l, 0) + ")");
        llEmail(llList2String(l, 1), llList2String(l, 2), llList2String(l, 3));
        llSetObjectName("SL emailer");
        llSay(0, "...Sent!");
    }
}