improved menu, moved email functionality to a separate file

This commit is contained in:
2026-01-27 14:32:10 +08:00
parent c067d031f8
commit 561f0ae501
5 changed files with 216 additions and 283 deletions

View File

@ -184,140 +184,6 @@ OnVanished
"\0\s[0]Пока, %(reference0).\e"
}
//**** Mail Checking *******************************************************************
//The next set of functions have to do with checking your email. This function is a slippery little thing - I've had people test it following my directions and have it work, but I've never actually gotten it to report back the right amount of emails myself. Very frustrating. But perhaps you'll have more luck with it, haha.
//Girl and Triangle can't actually read your email, they can just tell you how many emails you have. I've seen ghosts that can read the HEADERS of email, but I still don't think ghosts can actually display the contents of an email. You should be using your actual email client for that. It's still kind of a neat feature though.
/**
* When you first tell the ghost to check your email. An intro statement, if you will.
* reference2 - name of the server being checked
*/
OnBIFFBegin
{
"\0\s[0]Ага, предоставь это Люме.\e"
"\0\s[0]Почта? Сейчас проверю.\e"
"\0\s[0]\f[name,Hymmnos,hymmnos.ttf]\f[height,16]j.w. mea ADDR => \f[default]\n\n%(reference2)\e"
}
/**
* Email number successfully retieved.
* reference0 - number of emails
* reference2 - name of the server being checked
* reference7 - the senders and titles delimited by C_BYTE1 characters
* see: https://ukagakadreamteam.github.io/ukadoc/manual/list_shiori_event.html
*/
OnBIFFComplete
{
if reference0 == 0
{
"\0\s[0]%(username), в ящике пусто. Наверное лучше проверить позже.\e"
"\0\s[0]Ничего нового.\e"
}
elseif reference0 > 0 && reference0 < 13
{
"\0\s[0]Ответ от сервера получен, пришло %( OnCorrectEmailNumberSuffix( reference0 % 10 ) ). Посмотрим?"
"\0\s[0]Передача данных завершена. На сервере %( OnCorrectEmailNumberSuffix( reference0 % 10 ) )."
"\0\s[0]Письма из Хогвартса там всё ещё нет, но есть %( OnCorrectEmailNumberSuffix( reference0 % 10 ) ) новых писем. Сейчас зачитаю..."
--
"\n\n\![set,autoscroll,disable]\_q%( OnPrintMailAsList( reference7 ) )\e"
}
elseif reference0 > 12 && reference0 < 100
{
"\0\s[0]%(reference0) новых писем, довольно много. Давай не будем читать каждое.\e"
}
elseif reference0 > 99
{
"\0\s[0]%(reference0) новых писем? %(username), давно ты в последний раз проверял свой почтовый ящик?\e"
"\0\s[0]%(reference0) новых писем. Наверное, тебе всё таки стоит начать их читать.\e"
}
}
/**
* Function that prints a string of email senders and titles as unordered list
* _argv[0] - a string of entries in format "SenderName <Sender@email.eg> Message title" separated by SOH(U+0001) chars
* returns formatted headers as list
* : last modifier will ensure only last return candidate gets returned
*/
OnPrintMailAsList : last
{
_headers = SPLIT(_argv[0],"")
_letters = ""
_headerRegex = "\s*(\S+)\s*<([^>]+)>\s(.*)" // Name <email@example.com> Message title
foreach _headers; _header
{
if RE_MATCH(_header,_headerRegex) > 0
{
_letterTitle = SHIORI3FW.EscapeAllTags(RE_GETSTR[3])
if RE_GETSTR[3] == ""
{
_letterTitle = "<не указано>"
}
_letters += "От: %(RE_GETSTR[1]) \nАдрес: %(RE_GETSTR[2]) \nТема: '%(_letterTitle)'\n\n"
}
}
_letters // returning formatted string
}
/**
* _argv[0] - number of emails recieved
* returns a string representing a correct russian ending for a word "letter" for given number
*/
OnCorrectEmailNumberSuffix
{
case _argv[0]
{
when 1
{
"одно новое письмо"
}
when 2-4
{
"%(_argv[0]) новых письма"
}
when 0,5,6,7,8,9
{
"%(_argv[0]) новых писем"
}
}
}
//Various error messages that can happen when your ghost tries to connect to an email account. Replace the dialogue as appropriate.
OnBIFFFailure
{
if reference0 == "timeout" //If the connection times out.
{
"\0\s[0]The connection has timed out.\e"
}
elseif reference0 == "kick" //If the account blocks the ghost from accessing it. I think gmail may do this at first to try and protect your account from unapproved applications using it. It gives you the option to change the setting in the warning email they send you about it.
{
"\0\s[0]We can't access the account.\e"
}
elseif reference0 == "defect" //If the information put into the POP menu is wrong.
{
"\0\s[0]The email account was not set up properly.\w8\1\s[10]It can be reset at the POP menu.\w8\![open,configurationdialog]\e"
//Note that this ends with \![open,configurationdialog]. This will open up the preferences menu I described above automatically. More on \! functions in the walkthrough. You can delete the \! tag here if you want to.
}
else //if there's some other kind of error.
{
"\0\s[0]We can't connect to the account.\w8\1\s[10]The error returned is '%(reference[0])'.\e"
//reference0 here stores the error message the email server would have given the ghost, hopefully.
}
}
//**** Network Update *****************************************************************
//The following functions are for the Network Update of your ghost, where it will connect to your website, check for new files, and update itself. This is a handy feature, but tricky to set up. If you have no intention of using Network Update, you can disregard these, but it won't hurt to fill them out anyway just in case. More details about how to set up Network Update are in the walkthrough (http://www.ashido.com/ukagaka/).