added many default placeholders. see #153
This commit is contained in:
parent
829a68fb02
commit
969360e89f
3 changed files with 30 additions and 8 deletions
|
|
@ -619,6 +619,10 @@
|
||||||
"message": "Recipients",
|
"message": "Recipients",
|
||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
|
"placeholder_cc_list": {
|
||||||
|
"message": "CC list",
|
||||||
|
"description": ""
|
||||||
|
},
|
||||||
"placeholder_author": {
|
"placeholder_author": {
|
||||||
"message": "Author",
|
"message": "Author",
|
||||||
"description": ""
|
"description": ""
|
||||||
|
|
|
||||||
|
|
@ -113,33 +113,44 @@ export class mzta_Menus {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// let mail_subject = await getMailSubject(tabs[0]);
|
|
||||||
// console.log(">>>>>>>>>>>>>>> mail_subject: " + mail_subject);
|
|
||||||
|
|
||||||
let fullPrompt = '';
|
let fullPrompt = '';
|
||||||
if(!placeholdersUtils.hasPlaceholder(curr_prompt.text)){
|
if(!placeholdersUtils.hasPlaceholder(curr_prompt.text)){
|
||||||
// no placeholders, do as usual
|
// no placeholders, do as usual
|
||||||
fullPrompt = curr_prompt.text + (String(curr_prompt.need_signature) == "1" ? " " + await this.getDefaultSignature():"") + " " + chatgpt_lang + " \"" + (selection_text=='' ? body_text : selection_text) + "\" ";
|
fullPrompt = curr_prompt.text + (String(curr_prompt.need_signature) == "1" ? " " + await this.getDefaultSignature():"") + " " + chatgpt_lang + " \"" + (selection_text=='' ? body_text : selection_text) + "\" ";
|
||||||
}else{
|
}else{
|
||||||
let mail_subject = await getMailSubject(tabs[0]);
|
|
||||||
// we have at least a placeholder, do the magic!
|
// we have at least a placeholder, do the magic!
|
||||||
let currPHs = await placeholdersUtils.extractPlaceholders(curr_prompt.text);
|
let currPHs = await placeholdersUtils.extractPlaceholders(curr_prompt.text);
|
||||||
// console.log(">>>>>>>>>> currPHs: " + JSON.stringify(currPHs));
|
// console.log(">>>>>>>>>> currPHs: " + JSON.stringify(currPHs));
|
||||||
let finalSubs = {};
|
let finalSubs = {};
|
||||||
|
let curr_messages = await browser.mailTabs.getSelectedMessages();
|
||||||
|
let curr_message = curr_messages.messages[0];
|
||||||
for(let currPH of currPHs){
|
for(let currPH of currPHs){
|
||||||
switch(currPH.id){
|
switch(currPH.id){
|
||||||
case 'mail_body':
|
case 'mail_body':
|
||||||
finalSubs['mail_body'] = body_text;
|
finalSubs['mail_body'] = body_text;
|
||||||
break;
|
break;
|
||||||
case 'html_body': console.log(">>>>>>>>>> html_body: " + msg_text.html);
|
case 'html_body':
|
||||||
finalSubs['html_body'] = msg_text.html;
|
finalSubs['html_body'] = msg_text.html;
|
||||||
break;
|
break;
|
||||||
case 'mail_subject':
|
case 'mail_subject':
|
||||||
|
let mail_subject = await getMailSubject(tabs[0]);
|
||||||
finalSubs['mail_subject'] = mail_subject;
|
finalSubs['mail_subject'] = mail_subject;
|
||||||
break;
|
break;
|
||||||
case 'selected_text':
|
case 'selected_text':
|
||||||
finalSubs['selected_text'] = selection_text;
|
finalSubs['selected_text'] = selection_text;
|
||||||
break;
|
break;
|
||||||
|
case 'author':
|
||||||
|
finalSubs['author'] = curr_message.author;
|
||||||
|
break;
|
||||||
|
case 'recipients':
|
||||||
|
finalSubs['recipients'] = curr_message.recipients.join(", ");
|
||||||
|
break;
|
||||||
|
case 'cc_list':
|
||||||
|
finalSubs['cc_list'] = curr_message.ccList.join(", ");
|
||||||
|
break;
|
||||||
|
case 'junk_score':
|
||||||
|
finalSubs['junk_score'] = curr_message.junkScore;
|
||||||
|
break;
|
||||||
default: // TODO Manage custom placeholders https://github.com/micz/ThunderAI/issues/156
|
default: // TODO Manage custom placeholders https://github.com/micz/ThunderAI/issues/156
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -69,21 +69,28 @@ const defaultPlaceholders = [
|
||||||
is_default: "1",
|
is_default: "1",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'junk_score', //TODO
|
id: 'junk_score',
|
||||||
name: "__MSG_placeholder_junk_score__",
|
name: "__MSG_placeholder_junk_score__",
|
||||||
text: "",
|
text: "",
|
||||||
type: 1,
|
type: 1,
|
||||||
is_default: "1",
|
is_default: "1",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'recipients', //TODO
|
id: 'recipients',
|
||||||
name: "__MSG_placeholder_recipients__",
|
name: "__MSG_placeholder_recipients__",
|
||||||
text: "",
|
text: "",
|
||||||
type: 0,
|
type: 0,
|
||||||
is_default: "1",
|
is_default: "1",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'author', //TODO
|
id: 'cc_list',
|
||||||
|
name: "__MSG_placeholder_cc_list__",
|
||||||
|
text: "",
|
||||||
|
type: 0,
|
||||||
|
is_default: "1",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'author',
|
||||||
name: "__MSG_placeholder_author__",
|
name: "__MSG_placeholder_author__",
|
||||||
text: "",
|
text: "",
|
||||||
type: 0,
|
type: 0,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue