mirror of
https://github.com/kolbytn/mindcraft.git
synced 2025-08-27 17:33:02 +02:00
Update conversation.js
This commit is contained in:
parent
37af374de3
commit
b0803ca184
1 changed files with 8 additions and 21 deletions
|
@ -7,8 +7,6 @@ let agent;
|
||||||
let agent_names = settings.profiles.map((p) => JSON.parse(readFileSync(p, 'utf8')).name);
|
let agent_names = settings.profiles.map((p) => JSON.parse(readFileSync(p, 'utf8')).name);
|
||||||
let agents_in_game = [];
|
let agents_in_game = [];
|
||||||
|
|
||||||
let self_prompter_paused = false;
|
|
||||||
|
|
||||||
class Conversation {
|
class Conversation {
|
||||||
constructor(name) {
|
constructor(name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
@ -97,7 +95,7 @@ class ConversationManager {
|
||||||
this._clearMonitorTimeouts();
|
this._clearMonitorTimeouts();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!self_prompter_paused) {
|
if (!agent.self_prompter.isPaused()) {
|
||||||
this.endConversation(convo_partner);
|
this.endConversation(convo_partner);
|
||||||
agent.handleMessage('system', `${convo_partner} disconnected, conversation has ended.`);
|
agent.handleMessage('system', `${convo_partner} disconnected, conversation has ended.`);
|
||||||
}
|
}
|
||||||
|
@ -125,9 +123,8 @@ class ConversationManager {
|
||||||
const convo = this._getConvo(send_to);
|
const convo = this._getConvo(send_to);
|
||||||
convo.reset();
|
convo.reset();
|
||||||
|
|
||||||
if (agent.self_prompter.on) {
|
if (agent.self_prompter.isActive()) {
|
||||||
await agent.self_prompter.stop();
|
await agent.self_prompter.pause();
|
||||||
self_prompter_paused = true;
|
|
||||||
}
|
}
|
||||||
if (convo.active)
|
if (convo.active)
|
||||||
return;
|
return;
|
||||||
|
@ -191,9 +188,8 @@ class ConversationManager {
|
||||||
convo.queue(received);
|
convo.queue(received);
|
||||||
|
|
||||||
// responding to conversation takes priority over self prompting
|
// responding to conversation takes priority over self prompting
|
||||||
if (agent.self_prompter.on){
|
if (agent.self_prompter.isActive()){
|
||||||
await agent.self_prompter.stopLoop();
|
await agent.self_prompter.pause();
|
||||||
self_prompter_paused = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_scheduleProcessInMessage(sender, received, convo);
|
_scheduleProcessInMessage(sender, received, convo);
|
||||||
|
@ -235,7 +231,7 @@ class ConversationManager {
|
||||||
if (this.activeConversation.name === sender) {
|
if (this.activeConversation.name === sender) {
|
||||||
this._stopMonitor();
|
this._stopMonitor();
|
||||||
this.activeConversation = null;
|
this.activeConversation = null;
|
||||||
if (self_prompter_paused && !this.inConversation()) {
|
if (agent.self_prompter.isPaused() && !this.inConversation()) {
|
||||||
_resumeSelfPrompter();
|
_resumeSelfPrompter();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -246,7 +242,7 @@ class ConversationManager {
|
||||||
for (const sender in this.convos) {
|
for (const sender in this.convos) {
|
||||||
this.endConversation(sender);
|
this.endConversation(sender);
|
||||||
}
|
}
|
||||||
if (self_prompter_paused) {
|
if (agent.self_prompter.isPaused()) {
|
||||||
_resumeSelfPrompter();
|
_resumeSelfPrompter();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -258,14 +254,6 @@ class ConversationManager {
|
||||||
this.endConversation(sender);
|
this.endConversation(sender);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
scheduleSelfPrompter() {
|
|
||||||
self_prompter_paused = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
cancelSelfPrompter() {
|
|
||||||
self_prompter_paused = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const convoManager = new ConversationManager();
|
const convoManager = new ConversationManager();
|
||||||
|
@ -360,8 +348,7 @@ function _tagMessage(message) {
|
||||||
|
|
||||||
async function _resumeSelfPrompter() {
|
async function _resumeSelfPrompter() {
|
||||||
await new Promise(resolve => setTimeout(resolve, 5000));
|
await new Promise(resolve => setTimeout(resolve, 5000));
|
||||||
if (self_prompter_paused && !convoManager.inConversation()) {
|
if (agent.self_prompter.isPaused() && !convoManager.inConversation()) {
|
||||||
self_prompter_paused = false;
|
|
||||||
agent.self_prompter.start();
|
agent.self_prompter.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue